Skip to content

Commit 6e7333d

Browse files
jarodwilsondavem330
authored andcommitted
net: add rx_nohandler stat counter
This adds an rx_nohandler stat counter, along with a sysfs statistics node, and copies the counter out via netlink as well. CC: "David S. Miller" <[email protected]> CC: Eric Dumazet <[email protected]> CC: Jiri Pirko <[email protected]> CC: Daniel Borkmann <[email protected]> CC: Tom Herbert <[email protected]> CC: Jay Vosburgh <[email protected]> CC: Veaceslav Falico <[email protected]> CC: Andy Gospodarek <[email protected]> CC: [email protected] Signed-off-by: Jarod Wilson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9256645 commit 6e7333d

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

include/linux/netdevice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,8 @@ enum netdev_priv_flags {
13971397
* do not use this in drivers
13981398
* @tx_dropped: Dropped packets by core network,
13991399
* do not use this in drivers
1400+
* @rx_nohandler: nohandler dropped packets by core network on
1401+
* inactive devices, do not use this in drivers
14001402
*
14011403
* @wireless_handlers: List of functions to handle Wireless Extensions,
14021404
* instead of ioctl,
@@ -1611,6 +1613,7 @@ struct net_device {
16111613

16121614
atomic_long_t rx_dropped;
16131615
atomic_long_t tx_dropped;
1616+
atomic_long_t rx_nohandler;
16141617

16151618
#ifdef CONFIG_WIRELESS_EXT
16161619
const struct iw_handler_def * wireless_handlers;

include/uapi/linux/if_link.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ struct rtnl_link_stats {
3535
/* for cslip etc */
3636
__u32 rx_compressed;
3737
__u32 tx_compressed;
38+
39+
__u32 rx_nohandler; /* dropped, no handler found */
3840
};
3941

4042
/* The main device statistics structure */
@@ -68,6 +70,8 @@ struct rtnl_link_stats64 {
6870
/* for cslip etc */
6971
__u64 rx_compressed;
7072
__u64 tx_compressed;
73+
74+
__u64 rx_nohandler; /* dropped, no handler found */
7175
};
7276

7377
/* The struct should be in sync with struct ifmap */

net/core/dev.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4154,7 +4154,10 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
41544154
ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
41554155
} else {
41564156
drop:
4157-
atomic_long_inc(&skb->dev->rx_dropped);
4157+
if (!deliver_exact)
4158+
atomic_long_inc(&skb->dev->rx_dropped);
4159+
else
4160+
atomic_long_inc(&skb->dev->rx_nohandler);
41584161
kfree_skb(skb);
41594162
/* Jamal, now you will not able to escape explaining
41604163
* me how you were going to use this. :-)
@@ -7307,6 +7310,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
73077310
}
73087311
storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
73097312
storage->tx_dropped += atomic_long_read(&dev->tx_dropped);
7313+
storage->rx_nohandler += atomic_long_read(&dev->rx_nohandler);
73107314
return storage;
73117315
}
73127316
EXPORT_SYMBOL(dev_get_stats);

net/core/net-sysfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ NETSTAT_ENTRY(tx_heartbeat_errors);
574574
NETSTAT_ENTRY(tx_window_errors);
575575
NETSTAT_ENTRY(rx_compressed);
576576
NETSTAT_ENTRY(tx_compressed);
577+
NETSTAT_ENTRY(rx_nohandler);
577578

578579
static struct attribute *netstat_attrs[] = {
579580
&dev_attr_rx_packets.attr,
@@ -599,6 +600,7 @@ static struct attribute *netstat_attrs[] = {
599600
&dev_attr_tx_window_errors.attr,
600601
&dev_attr_rx_compressed.attr,
601602
&dev_attr_tx_compressed.attr,
603+
&dev_attr_rx_nohandler.attr,
602604
NULL
603605
};
604606

net/core/rtnetlink.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,8 @@ static void copy_rtnl_link_stats(struct rtnl_link_stats *a,
804804

805805
a->rx_compressed = b->rx_compressed;
806806
a->tx_compressed = b->tx_compressed;
807+
808+
a->rx_nohandler = b->rx_nohandler;
807809
}
808810

809811
static void copy_rtnl_link_stats64(void *v, const struct rtnl_link_stats64 *b)

0 commit comments

Comments
 (0)