Skip to content

Commit 8990f46

Browse files
Eric Dumazetdavem330
authored andcommitted
net: rx_dropped accounting
Under load, netif_rx() can drop incoming packets but administrators dont have a chance to spot which device needs some tuning (RPS activation for example) This patch adds rx_dropped accounting in vlans and tunnels. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 462fb2a commit 8990f46

File tree

7 files changed

+28
-8
lines changed

7 files changed

+28
-8
lines changed

net/8021q/vlan.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ struct vlan_priority_tci_mapping {
2525
* @rx_multicast: number of received multicast packets
2626
* @syncp: synchronization point for 64bit counters
2727
* @rx_errors: number of errors
28+
* @rx_dropped: number of dropped packets
2829
*/
2930
struct vlan_rx_stats {
3031
u64 rx_packets;
3132
u64 rx_bytes;
3233
u64 rx_multicast;
3334
struct u64_stats_sync syncp;
3435
unsigned long rx_errors;
36+
unsigned long rx_dropped;
3537
};
3638

3739
/**

net/8021q/vlan_dev.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
225225
}
226226
}
227227

228-
netif_rx(skb);
228+
if (unlikely(netif_rx(skb) == NET_RX_DROP)) {
229+
if (rx_stats)
230+
rx_stats->rx_dropped++;
231+
}
229232
rcu_read_unlock();
230233
return NET_RX_SUCCESS;
231234

@@ -843,13 +846,15 @@ static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, st
843846
accum.rx_packets += rxpackets;
844847
accum.rx_bytes += rxbytes;
845848
accum.rx_multicast += rxmulticast;
846-
/* rx_errors is an ulong, not protected by syncp */
849+
/* rx_errors, rx_dropped are ulong, not protected by syncp */
847850
accum.rx_errors += p->rx_errors;
851+
accum.rx_dropped += p->rx_dropped;
848852
}
849853
stats->rx_packets = accum.rx_packets;
850854
stats->rx_bytes = accum.rx_bytes;
851855
stats->rx_errors = accum.rx_errors;
852856
stats->multicast = accum.rx_multicast;
857+
stats->rx_dropped = accum.rx_dropped;
853858
}
854859
return stats;
855860
}

net/ipv4/ip_gre.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,11 @@ static int ipgre_rcv(struct sk_buff *skb)
647647
skb_reset_network_header(skb);
648648
ipgre_ecn_decapsulate(iph, skb);
649649

650-
netif_rx(skb);
650+
if (netif_rx(skb) == NET_RX_DROP)
651+
stats->rx_dropped++;
652+
651653
rcu_read_unlock();
652-
return(0);
654+
return 0;
653655
}
654656
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
655657

net/ipv4/ipip.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,10 @@ static int ipip_rcv(struct sk_buff *skb)
377377
skb_tunnel_rx(skb, tunnel->dev);
378378

379379
ipip_ecn_decapsulate(iph, skb);
380-
netif_rx(skb);
380+
381+
if (netif_rx(skb) == NET_RX_DROP)
382+
tunnel->dev->stats.rx_dropped++;
383+
381384
rcu_read_unlock();
382385
return 0;
383386
}

net/ipv6/ip6_tunnel.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,10 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,
725725
skb_tunnel_rx(skb, t->dev);
726726

727727
dscp_ecn_decapsulate(t, ipv6h, skb);
728-
netif_rx(skb);
728+
729+
if (netif_rx(skb) == NET_RX_DROP)
730+
t->dev->stats.rx_dropped++;
731+
729732
rcu_read_unlock();
730733
return 0;
731734
}

net/ipv6/ip6mr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,9 @@ static int pim6_rcv(struct sk_buff *skb)
666666

667667
skb_tunnel_rx(skb, reg_dev);
668668

669-
netif_rx(skb);
669+
if (netif_rx(skb) == NET_RX_DROP)
670+
reg_dev->stats.rx_dropped++;
671+
670672
dev_put(reg_dev);
671673
return 0;
672674
drop:

net/ipv6/sit.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,10 @@ static int ipip6_rcv(struct sk_buff *skb)
564564
skb_tunnel_rx(skb, tunnel->dev);
565565

566566
ipip6_ecn_decapsulate(iph, skb);
567-
netif_rx(skb);
567+
568+
if (netif_rx(skb) == NET_RX_DROP)
569+
tunnel->dev->stats.rx_dropped++;
570+
568571
rcu_read_unlock();
569572
return 0;
570573
}

0 commit comments

Comments
 (0)