Skip to contentSkip to conversation

net: Use rx_nohandler for unhandled packets

PATCH In review Patrick Talbert 3 participants 5 messages Dec 11, 2019 – Dec 16, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: Use rx_nohandler for unhandled packets

Since caf586e5f23c ("net: add a core netdev->rx_dropped counter") incoming packets which do not have a handler cause a counter named rx_dropped to be incremented. This can lead to confusion as some see a non-zero "drop" counter as cause for concern.

To avoid any confusion, instead use the existing rx_nohandler counter. Its name more closely aligns with the activity being tracked here.

---
 include/linux/netdevice.h |  5 +++--
 net/core/dev.c            | 15 +++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)
include/linux/netdevice.h +3 -2
index 9ef20389622d..3d194cea9859 100644
@@ -1618,8 +1618,9 @@ enum netdev_priv_flags {
  *			do not use this in drivers
  *	@tx_dropped:	Dropped packets by core network,
  *			do not use this in drivers
- *	@rx_nohandler:	nohandler dropped packets by core network on
- *			inactive devices, do not use this in drivers
+ *	@rx_nohandler:	Dropped packets by core network when they were not handled
+ *			by any protocol/socket or the device was inactive,
+ *			do not use this in drivers.
  *	@carrier_up_count:	Number of times the carrier has been up
  *	@carrier_down_count:	Number of times the carrier has been down
  *
net/core/dev.c +7 -8
index 2c277b8aba38..11e500f8ffa3 100644
@@ -5123,20 +5123,19 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc,
 			goto drop;
 		*ppt_prev = pt_prev;
 	} else {
-drop:
-		if (!deliver_exact)
-			atomic_long_inc(&skb->dev->rx_dropped);
-		else
-			atomic_long_inc(&skb->dev->rx_nohandler);
+		/* We have not delivered the skb anywhere */
+		atomic_long_inc(&skb->dev->rx_nohandler);
 		kfree_skb(skb);
-		/* Jamal, now you will not able to escape explaining
-		 * me how you were going to use this. :-)
-		 */
 		ret = NET_RX_DROP;
 	}
 
 out:
 	return ret;
+drop:
+	atomic_long_inc(&skb->dev->rx_dropped);
+	kfree_skb(skb);
+	ret = NET_RX_DROP;
+	goto out;
 }
 
 static int __netif_receive_skb_one_core(struct sk_buff *skb, bool pfmemalloc)
Signature · 1 line
2.18.1
#1 lore raw
Quoted 9 lines · Patrick Talbert

Since caf586e5f23c ("net: add a core netdev->rx_dropped counter") incoming packets which do not have a handler cause a counter named rx_dropped to be incremented. This can lead to confusion as some see a non-zero "drop" counter as cause for concern.

To avoid any confusion, instead use the existing rx_nohandler counter. Its name more closely aligns with the activity being tracked here.

Looks like commit 6e7333d315a7 ("net: add rx_nohandler stat counter") is far more relevant here, it added rx_nohandler but kept using rx_dropped for non-exact delivery.

Jarod, could you take a look?

Quoted 48 lines
include/linux/netdevice.h +3 -2
index 9ef20389622d..3d194cea9859 100644
@@ -1618,8 +1618,9 @@ enum netdev_priv_flags {
  *			do not use this in drivers
  *	@tx_dropped:	Dropped packets by core network,
  *			do not use this in drivers
- *	@rx_nohandler:	nohandler dropped packets by core network on
- *			inactive devices, do not use this in drivers
+ *	@rx_nohandler:	Dropped packets by core network when they were not handled
+ *			by any protocol/socket or the device was inactive,
+ *			do not use this in drivers.
  *	@carrier_up_count:	Number of times the carrier has been up
  *	@carrier_down_count:	Number of times the carrier has been down
  *
net/core/dev.c +7 -8
index 2c277b8aba38..11e500f8ffa3 100644
@@ -5123,20 +5123,19 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc,
 			goto drop;
 		*ppt_prev = pt_prev;
 	} else {
-drop:
-		if (!deliver_exact)
-			atomic_long_inc(&skb->dev->rx_dropped);
-		else
-			atomic_long_inc(&skb->dev->rx_nohandler);
+		/* We have not delivered the skb anywhere */
+		atomic_long_inc(&skb->dev->rx_nohandler);
 		kfree_skb(skb);
-		/* Jamal, now you will not able to escape explaining
-		 * me how you were going to use this. :-)
-		 */
 		ret = NET_RX_DROP;
 	}
 
 out:
 	return ret;
+drop:
+	atomic_long_inc(&skb->dev->rx_dropped);
+	kfree_skb(skb);
+	ret = NET_RX_DROP;
+	goto out;
 }
 
 static int __netif_receive_skb_one_core(struct sk_buff *skb, bool pfmemalloc)
maintainer
#2 lore raw
In reply to Patrick Talbert

From: Patrick Talbert <[email protected]>
Date: Wed, 11 Dec 2019 17:21:07 +0100

Quoted 9 lines

Since caf586e5f23c ("net: add a core netdev->rx_dropped counter") incoming packets which do not have a handler cause a counter named rx_dropped to be incremented. This can lead to confusion as some see a non-zero "drop" counter as cause for concern.

To avoid any confusion, instead use the existing rx_nohandler counter. Its name more closely aligns with the activity being tracked here.

I disagree with this change.

When deliver_exact is false we try to deliver the packet to an appropriate ptype handler. And we end up in the counter bump if no ptype handler exists.

Therefore, the two counters allow to distinguish two very different situations and providing that distinction is quite valuable.

I think this distinction was very much intentional. Having people understand that rx_dropped can have this meaning is merely a matter of education.

I'm not applying this patch, sorry.

#3 lore raw
Quoted 9 lines · David Miller

From: Patrick Talbert <[email protected]>
Date: Wed, 11 Dec 2019 17:21:07 +0100

Quoted 5 lines

Since caf586e5f23c ("net: add a core netdev->rx_dropped counter") incoming packets which do not have a handler cause a counter named rx_dropped to be incremented. This can lead to confusion as some see a non-zero "drop" counter as cause for concern.

Quoted 6 lines
Quoted 4 lines

To avoid any confusion, instead use the existing rx_nohandler counter. Its name more closely aligns with the activity being tracked here.

I disagree with this change.

Thank you for the review and consideration.

Quoted 4 lines

When deliver_exact is false we try to deliver the packet to an appropriate ptype handler. And we end up in the counter bump if no ptype handler exists.

If we get to this point in __netif_receive_skb_core() it means the packet was not passed on to any handler or socket but it is not because anything went wrong. It simply means no one cared about it. I suppose a counter named rx_nothandled or rx_ignored would fit better but for now, the existing rx_nohandler counter much more closely describes what has happened. Lumping these discards into rx_dropped along with buffer errors and that ilk is misleading at best.

Quoted 3 lines

Therefore, the two counters allow to distinguish two very different situations and providing that distinction is quite valuable.

As is, we have packets which are not handled due to no fault and packets which were discarded due to some fault lumped into rx_dropped. I think it is much more useful to clarify that distinction by utilizing separate counters versus worrying that someone might miss the distinction between an inactive slave drop and any other drop.

Quoted 4 lines

I think this distinction was very much intentional. Having people understand that rx_dropped can have this meaning is merely a matter of education.

From what I recall, the patch to add rx_nohandler was a reaction to caf586e5f23c ("net: add a core netdev->rx_dropped counter") being backported to RHEL7 and customers suddenly seeing rx_dopped piling up on inactive bond slaves. I wish it had been more broad to trap all the unhandled traffic, not just inactive slave traffic, but it wasn't.

I appreciate netdev rx_dropped by itself should not be considered a count of errors but I argue that is not at all common knowledge. At Red Hat it is a weekly, if not daily, occurrence that a customer opens a case to ask about a non-zero rx_dropped counter. Whether they noticed it themselves or some 3rd party monitoring software highlighted it. Sometimes it reflects a real problem but more often than not it turns out there is some benign LLC traffic (or the like) arriving on the interface. That's a seemingly simple and nice answer but it often takes a good bit of time to convince people they can ignore a non-zero rx_dropped (if not ignore, at least appreciate it is not a fault of the NIC/OS). For example, with pcaps and by monitoring the counter you can show a 1:1 correlation between specific types of traffic which do not match /proc/net/ptype and increases in rx_dropped. Its neat but it takes time and often distracts from whatever the real problem is.

Quoted 3 lines

I'm not applying this patch, sorry.

If you do not agree with adjusting the purpose of rx_nohandler to track these events then would you agree to a new counter?

maintainer
#4 lore raw

From: Patrick Talbert <[email protected]>
Date: Mon, 16 Dec 2019 15:07:14 +0100

Quoted 5 lines · David Miller
Quoted 1 line

I'm not applying this patch, sorry.

If you do not agree with adjusting the purpose of rx_nohandler to track these events then would you agree to a new counter?

I guess the people relying on the current rx_dropped behavior don't matter and we can just change things from underneath them? No, actually, we cannot do that.

Educating people to solve this problem has the benefit of not screwing over the users who understand what the counter means in this situation already.