Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Eric Dumazet and committed by
David S. Miller
b8c84307 a777c892

+16 -10
+6 -5
net/l2tp/l2tp_core.c
··· 1128 1128 int headroom; 1129 1129 int uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0; 1130 1130 int udp_len; 1131 + int ret = NET_XMIT_SUCCESS; 1131 1132 1132 1133 /* Check that there's enough headroom in the skb to insert IP, 1133 1134 * UDP and L2TP headers. If not enough, expand it to ··· 1138 1137 uhlen + hdr_len; 1139 1138 old_headroom = skb_headroom(skb); 1140 1139 if (skb_cow_head(skb, headroom)) { 1141 - dev_kfree_skb(skb); 1142 - goto abort; 1140 + kfree_skb(skb); 1141 + return NET_XMIT_DROP; 1143 1142 } 1144 1143 1145 1144 new_headroom = skb_headroom(skb); ··· 1157 1156 1158 1157 bh_lock_sock(sk); 1159 1158 if (sock_owned_by_user(sk)) { 1160 - dev_kfree_skb(skb); 1159 + kfree_skb(skb); 1160 + ret = NET_XMIT_DROP; 1161 1161 goto out_unlock; 1162 1162 } 1163 1163 ··· 1217 1215 out_unlock: 1218 1216 bh_unlock_sock(sk); 1219 1217 1220 - abort: 1221 - return 0; 1218 + return ret; 1222 1219 } 1223 1220 EXPORT_SYMBOL_GPL(l2tp_xmit_skb); 1224 1221
+10 -5
net/l2tp/l2tp_eth.c
··· 44 44 struct list_head list; 45 45 atomic_long_t tx_bytes; 46 46 atomic_long_t tx_packets; 47 + atomic_long_t tx_dropped; 47 48 atomic_long_t rx_bytes; 48 49 atomic_long_t rx_packets; 49 50 atomic_long_t rx_errors; ··· 93 92 { 94 93 struct l2tp_eth *priv = netdev_priv(dev); 95 94 struct l2tp_session *session = priv->session; 95 + unsigned int len = skb->len; 96 + int ret = l2tp_xmit_skb(session, skb, session->hdr_len); 96 97 97 - atomic_long_add(skb->len, &priv->tx_bytes); 98 - atomic_long_inc(&priv->tx_packets); 99 - 100 - l2tp_xmit_skb(session, skb, session->hdr_len); 101 - 98 + if (likely(ret == NET_XMIT_SUCCESS)) { 99 + atomic_long_add(len, &priv->tx_bytes); 100 + atomic_long_inc(&priv->tx_packets); 101 + } else { 102 + atomic_long_inc(&priv->tx_dropped); 103 + } 102 104 return NETDEV_TX_OK; 103 105 } 104 106 ··· 112 108 113 109 stats->tx_bytes = atomic_long_read(&priv->tx_bytes); 114 110 stats->tx_packets = atomic_long_read(&priv->tx_packets); 111 + stats->tx_dropped = atomic_long_read(&priv->tx_dropped); 115 112 stats->rx_bytes = atomic_long_read(&priv->rx_bytes); 116 113 stats->rx_packets = atomic_long_read(&priv->rx_packets); 117 114 stats->rx_errors = atomic_long_read(&priv->rx_errors);