diff mbox series

[net-next,19/19] net: dev: use kfree_skb_reason() for __netif_receive_skb_core()

Message ID 20220215112812.2093852-20-imagedong@tencent.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series net: add skb drop reasons for TCP, IP, dev and neigh | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/apply fail Patch does not apply to net-next

Commit Message

Menglong Dong Feb. 15, 2022, 11:28 a.m. UTC
From: Menglong Dong <imagedong@tencent.com>

Add reason for skb drops to __netif_receive_skb_core() when packet_type
not found to handle the skb. For this purpose, the drop reason
SKB_DROP_REASON_PTYPE_ABSENT is introduced. Take ether packets for
example, this case mainly happens when L3 protocol is not supported.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
---
 include/linux/skbuff.h     | 5 +++++
 include/trace/events/skb.h | 1 +
 net/core/dev.c             | 8 +++++---
 3 files changed, 11 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index e36e27943104..b467a5adfeaf 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -415,6 +415,11 @@  enum skb_drop_reason {
 					 * failed (maybe an eBPF program
 					 * is tricking?)
 					 */
+	SKB_DROP_REASON_PTYPE_ABSENT,	/* no packet_type found to handle
+					 * the skb. For an etner packet,
+					 * this means that L3 protocol is
+					 * not supported
+					 */
 	SKB_DROP_REASON_MAX,
 };
 
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 96a550570dfe..f649c0a18d29 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -48,6 +48,7 @@ 
 	EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG)		\
 	EM(SKB_DROP_REASON_XDP, XDP)				\
 	EM(SKB_DROP_REASON_QDISC_INGRESS, QDISC_INGRESS)	\
+	EM(SKB_DROP_REASON_PTYPE_ABSENT, PTYPE_ABSENT)		\
 	EMe(SKB_DROP_REASON_MAX, MAX)
 
 #undef EM
diff --git a/net/core/dev.c b/net/core/dev.c
index c67e3491c004..90488d05f83b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5323,11 +5323,13 @@  static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,
 		*ppt_prev = pt_prev;
 	} else {
 drop:
-		if (!deliver_exact)
+		if (!deliver_exact) {
 			atomic_long_inc(&skb->dev->rx_dropped);
-		else
+			kfree_skb_reason(skb, SKB_DROP_REASON_PTYPE_ABSENT);
+		} else {
 			atomic_long_inc(&skb->dev->rx_nohandler);
-		kfree_skb(skb);
+			kfree_skb(skb);
+		}
 		/* Jamal, now you will not able to escape explaining
 		 * me how you were going to use this. :-)
 		 */