diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-09-30 17:06:55 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-05 17:47:55 -0400 |
commit | caf586e5f23cebb2a68cbaf288d59dbbf2d74052 (patch) | |
tree | 5c0dfcf5a14c55501f9225835c83abddb8d1876e /net/8021q | |
parent | a00eac0c459abecb539fb2a2abd3122dd7ca5d4a (diff) |
net: add a core netdev->rx_dropped counter
In various situations, a device provides a packet to our stack and we
drop it before it enters protocol stack :
- softnet backlog full (accounted in /proc/net/softnet_stat)
- bad vlan tag (not accounted)
- unknown/unregistered protocol (not accounted)
We can handle a per-device counter of such dropped frames at core level,
and automatically adds it to the device provided stats (rx_dropped), so
that standard tools can be used (ifconfig, ip link, cat /proc/net/dev)
This is a generalization of commit 8990f468a (net: rx_dropped
accounting), thus reverting it.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/8021q')
-rw-r--r-- | net/8021q/vlan.h | 2 | ||||
-rw-r--r-- | net/8021q/vlan_core.c | 2 | ||||
-rw-r--r-- | net/8021q/vlan_dev.c | 11 |
3 files changed, 6 insertions, 9 deletions
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h index b26ce343072c..8d9503ad01da 100644 --- a/net/8021q/vlan.h +++ b/net/8021q/vlan.h | |||
@@ -25,7 +25,6 @@ struct vlan_priority_tci_mapping { | |||
25 | * @rx_multicast: number of received multicast packets | 25 | * @rx_multicast: number of received multicast packets |
26 | * @syncp: synchronization point for 64bit counters | 26 | * @syncp: synchronization point for 64bit counters |
27 | * @rx_errors: number of errors | 27 | * @rx_errors: number of errors |
28 | * @rx_dropped: number of dropped packets | ||
29 | */ | 28 | */ |
30 | struct vlan_rx_stats { | 29 | struct vlan_rx_stats { |
31 | u64 rx_packets; | 30 | u64 rx_packets; |
@@ -33,7 +32,6 @@ struct vlan_rx_stats { | |||
33 | u64 rx_multicast; | 32 | u64 rx_multicast; |
34 | struct u64_stats_sync syncp; | 33 | struct u64_stats_sync syncp; |
35 | unsigned long rx_errors; | 34 | unsigned long rx_errors; |
36 | unsigned long rx_dropped; | ||
37 | }; | 35 | }; |
38 | 36 | ||
39 | /** | 37 | /** |
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index b6d55a9304f2..dee727ce0291 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c | |||
@@ -33,6 +33,7 @@ int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, | |||
33 | return polling ? netif_receive_skb(skb) : netif_rx(skb); | 33 | return polling ? netif_receive_skb(skb) : netif_rx(skb); |
34 | 34 | ||
35 | drop: | 35 | drop: |
36 | atomic_long_inc(&skb->dev->rx_dropped); | ||
36 | dev_kfree_skb_any(skb); | 37 | dev_kfree_skb_any(skb); |
37 | return NET_RX_DROP; | 38 | return NET_RX_DROP; |
38 | } | 39 | } |
@@ -123,6 +124,7 @@ vlan_gro_common(struct napi_struct *napi, struct vlan_group *grp, | |||
123 | return dev_gro_receive(napi, skb); | 124 | return dev_gro_receive(napi, skb); |
124 | 125 | ||
125 | drop: | 126 | drop: |
127 | atomic_long_inc(&skb->dev->rx_dropped); | ||
126 | return GRO_DROP; | 128 | return GRO_DROP; |
127 | } | 129 | } |
128 | 130 | ||
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index f6fbcc0f1af9..f54251edd40d 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
@@ -225,16 +225,15 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, | |||
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | if (unlikely(netif_rx(skb) == NET_RX_DROP)) { | 228 | netif_rx(skb); |
229 | if (rx_stats) | 229 | |
230 | rx_stats->rx_dropped++; | ||
231 | } | ||
232 | rcu_read_unlock(); | 230 | rcu_read_unlock(); |
233 | return NET_RX_SUCCESS; | 231 | return NET_RX_SUCCESS; |
234 | 232 | ||
235 | err_unlock: | 233 | err_unlock: |
236 | rcu_read_unlock(); | 234 | rcu_read_unlock(); |
237 | err_free: | 235 | err_free: |
236 | atomic_long_inc(&dev->rx_dropped); | ||
238 | kfree_skb(skb); | 237 | kfree_skb(skb); |
239 | return NET_RX_DROP; | 238 | return NET_RX_DROP; |
240 | } | 239 | } |
@@ -846,15 +845,13 @@ static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, st | |||
846 | accum.rx_packets += rxpackets; | 845 | accum.rx_packets += rxpackets; |
847 | accum.rx_bytes += rxbytes; | 846 | accum.rx_bytes += rxbytes; |
848 | accum.rx_multicast += rxmulticast; | 847 | accum.rx_multicast += rxmulticast; |
849 | /* rx_errors, rx_dropped are ulong, not protected by syncp */ | 848 | /* rx_errors is ulong, not protected by syncp */ |
850 | accum.rx_errors += p->rx_errors; | 849 | accum.rx_errors += p->rx_errors; |
851 | accum.rx_dropped += p->rx_dropped; | ||
852 | } | 850 | } |
853 | stats->rx_packets = accum.rx_packets; | 851 | stats->rx_packets = accum.rx_packets; |
854 | stats->rx_bytes = accum.rx_bytes; | 852 | stats->rx_bytes = accum.rx_bytes; |
855 | stats->rx_errors = accum.rx_errors; | 853 | stats->rx_errors = accum.rx_errors; |
856 | stats->multicast = accum.rx_multicast; | 854 | stats->multicast = accum.rx_multicast; |
857 | stats->rx_dropped = accum.rx_dropped; | ||
858 | } | 855 | } |
859 | return stats; | 856 | return stats; |
860 | } | 857 | } |