aboutsummaryrefslogtreecommitdiffstats
path: root/net/l2tp
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2012-06-28 16:15:13 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-29 03:52:32 -0400
commitb8c8430726e5bd552e01dacc5a44f3f83f7446ca (patch)
treee966e64a7bb8a2451048b7e73c0c4aa9a8db40a3 /net/l2tp
parenta777c892cea917b6c67c61f8dff47d8caae7b8a1 (diff)
net: l2tp_eth: provide tx_dropped counter
Change l2tp_xmit_skb() to return NET_XMIT_DROP in case skb is dropped. Use kfree_skb() instead dev_kfree_skb() for drop_monitor pleasure. Support tx_dropped counter for l2tp_eth Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: James Chapman <jchapman@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/l2tp')
-rw-r--r--net/l2tp/l2tp_core.c11
-rw-r--r--net/l2tp/l2tp_eth.c15
2 files changed, 16 insertions, 10 deletions
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index 32b2155e7ab4..393355d37b47 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -1128,6 +1128,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
1128 int headroom; 1128 int headroom;
1129 int uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0; 1129 int uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0;
1130 int udp_len; 1130 int udp_len;
1131 int ret = NET_XMIT_SUCCESS;
1131 1132
1132 /* Check that there's enough headroom in the skb to insert IP, 1133 /* Check that there's enough headroom in the skb to insert IP,
1133 * UDP and L2TP headers. If not enough, expand it to 1134 * UDP and L2TP headers. If not enough, expand it to
@@ -1137,8 +1138,8 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
1137 uhlen + hdr_len; 1138 uhlen + hdr_len;
1138 old_headroom = skb_headroom(skb); 1139 old_headroom = skb_headroom(skb);
1139 if (skb_cow_head(skb, headroom)) { 1140 if (skb_cow_head(skb, headroom)) {
1140 dev_kfree_skb(skb); 1141 kfree_skb(skb);
1141 goto abort; 1142 return NET_XMIT_DROP;
1142 } 1143 }
1143 1144
1144 new_headroom = skb_headroom(skb); 1145 new_headroom = skb_headroom(skb);
@@ -1156,7 +1157,8 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
1156 1157
1157 bh_lock_sock(sk); 1158 bh_lock_sock(sk);
1158 if (sock_owned_by_user(sk)) { 1159 if (sock_owned_by_user(sk)) {
1159 dev_kfree_skb(skb); 1160 kfree_skb(skb);
1161 ret = NET_XMIT_DROP;
1160 goto out_unlock; 1162 goto out_unlock;
1161 } 1163 }
1162 1164
@@ -1215,8 +1217,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
1215out_unlock: 1217out_unlock:
1216 bh_unlock_sock(sk); 1218 bh_unlock_sock(sk);
1217 1219
1218abort: 1220 return ret;
1219 return 0;
1220} 1221}
1221EXPORT_SYMBOL_GPL(l2tp_xmit_skb); 1222EXPORT_SYMBOL_GPL(l2tp_xmit_skb);
1222 1223
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 47b259fccd27..f9ee74deeac2 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -44,6 +44,7 @@ struct l2tp_eth {
44 struct list_head list; 44 struct list_head list;
45 atomic_long_t tx_bytes; 45 atomic_long_t tx_bytes;
46 atomic_long_t tx_packets; 46 atomic_long_t tx_packets;
47 atomic_long_t tx_dropped;
47 atomic_long_t rx_bytes; 48 atomic_long_t rx_bytes;
48 atomic_long_t rx_packets; 49 atomic_long_t rx_packets;
49 atomic_long_t rx_errors; 50 atomic_long_t rx_errors;
@@ -92,12 +93,15 @@ static int l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev)
92{ 93{
93 struct l2tp_eth *priv = netdev_priv(dev); 94 struct l2tp_eth *priv = netdev_priv(dev);
94 struct l2tp_session *session = priv->session; 95 struct l2tp_session *session = priv->session;
96 unsigned int len = skb->len;
97 int ret = l2tp_xmit_skb(session, skb, session->hdr_len);
95 98
96 atomic_long_add(skb->len, &priv->tx_bytes); 99 if (likely(ret == NET_XMIT_SUCCESS)) {
97 atomic_long_inc(&priv->tx_packets); 100 atomic_long_add(len, &priv->tx_bytes);
98 101 atomic_long_inc(&priv->tx_packets);
99 l2tp_xmit_skb(session, skb, session->hdr_len); 102 } else {
100 103 atomic_long_inc(&priv->tx_dropped);
104 }
101 return NETDEV_TX_OK; 105 return NETDEV_TX_OK;
102} 106}
103 107
@@ -108,6 +112,7 @@ static struct rtnl_link_stats64 *l2tp_eth_get_stats64(struct net_device *dev,
108 112
109 stats->tx_bytes = atomic_long_read(&priv->tx_bytes); 113 stats->tx_bytes = atomic_long_read(&priv->tx_bytes);
110 stats->tx_packets = atomic_long_read(&priv->tx_packets); 114 stats->tx_packets = atomic_long_read(&priv->tx_packets);
115 stats->tx_dropped = atomic_long_read(&priv->tx_dropped);
111 stats->rx_bytes = atomic_long_read(&priv->rx_bytes); 116 stats->rx_bytes = atomic_long_read(&priv->rx_bytes);
112 stats->rx_packets = atomic_long_read(&priv->rx_packets); 117 stats->rx_packets = atomic_long_read(&priv->rx_packets);
113 stats->rx_errors = atomic_long_read(&priv->rx_errors); 118 stats->rx_errors = atomic_long_read(&priv->rx_errors);