42
42
struct sock *tunnel_sock;
43
43
struct l2tp_session *session;
44
44
struct list_head list;
45
atomic_long_t tx_bytes;
46
atomic_long_t tx_packets;
47
atomic_long_t rx_bytes;
48
atomic_long_t rx_packets;
49
atomic_long_t rx_errors;
47
52
/* via l2tp_session_priv() */
88
93
struct l2tp_eth *priv = netdev_priv(dev);
89
94
struct l2tp_session *session = priv->session;
96
atomic_long_add(skb->len, &priv->tx_bytes);
97
atomic_long_inc(&priv->tx_packets);
91
99
l2tp_xmit_skb(session, skb, session->hdr_len);
93
dev->stats.tx_bytes += skb->len;
94
dev->stats.tx_packets++;
104
static struct rtnl_link_stats64 *l2tp_eth_get_stats64(struct net_device *dev,
105
struct rtnl_link_stats64 *stats)
107
struct l2tp_eth *priv = netdev_priv(dev);
109
stats->tx_bytes = atomic_long_read(&priv->tx_bytes);
110
stats->tx_packets = atomic_long_read(&priv->tx_packets);
111
stats->rx_bytes = atomic_long_read(&priv->rx_bytes);
112
stats->rx_packets = atomic_long_read(&priv->rx_packets);
113
stats->rx_errors = atomic_long_read(&priv->rx_errors);
99
118
static struct net_device_ops l2tp_eth_netdev_ops = {
100
119
.ndo_init = l2tp_eth_dev_init,
101
120
.ndo_uninit = l2tp_eth_dev_uninit,
102
121
.ndo_start_xmit = l2tp_eth_dev_xmit,
122
.ndo_get_stats64 = l2tp_eth_get_stats64,
105
125
static void l2tp_eth_dev_setup(struct net_device *dev)
107
127
ether_setup(dev);
108
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
128
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
129
dev->features |= NETIF_F_LLTX;
109
130
dev->netdev_ops = &l2tp_eth_netdev_ops;
110
131
dev->destructor = free_netdev;
115
136
struct l2tp_eth_sess *spriv = l2tp_session_priv(session);
116
137
struct net_device *dev = spriv->dev;
138
struct l2tp_eth *priv = netdev_priv(dev);
118
140
if (session->debug & L2TP_MSG_DATA) {
119
141
unsigned int length;
122
143
length = min(32u, skb->len);
123
144
if (!pskb_may_pull(skb, length))
126
147
pr_debug("%s: eth recv\n", session->name);
127
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
148
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, skb->data, length);
130
151
if (!pskb_may_pull(skb, sizeof(ETH_HLEN)))
141
162
if (dev_forward_skb(dev, skb) == NET_RX_SUCCESS) {
142
dev->stats.rx_packets++;
143
dev->stats.rx_bytes += data_len;
145
dev->stats.rx_errors++;
163
atomic_long_inc(&priv->rx_packets);
164
atomic_long_add(data_len, &priv->rx_bytes);
166
atomic_long_inc(&priv->rx_errors);
150
dev->stats.rx_errors++;
171
atomic_long_inc(&priv->rx_errors);