[PATCH net-next 6/7] net: dev: use kfree_skb_reason() for sch_handle_ingress()
From: menglong8 . dong
Date: Thu Mar 03 2022 - 12:49:13 EST
From: Menglong Dong <imagedong@xxxxxxxxxxx>
Replace kfree_skb() used in sch_handle_ingress() with
kfree_skb_reason(). Following drop reasons are introduced:
SKB_DROP_REASON_QDISC_INGRESS
Signed-off-by: Menglong Dong <imagedong@xxxxxxxxxxx>
---
include/linux/skbuff.h | 4 ++++
include/trace/events/skb.h | 1 +
net/core/dev.c | 2 +-
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 23bbfcd6668b..04508d15152e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -409,6 +409,10 @@ enum skb_drop_reason {
* net.rst) or RPS flow limit
*/
SKB_DROP_REASON_XDP, /* dropped by XDP in input path */
+ SKB_DROP_REASON_QDISC_INGRESS, /* qdisc of type ingress check
+ * failed (maybe an eBPF program
+ * is tricking?)
+ */
SKB_DROP_REASON_MAX,
};
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index c117430375c0..d635951c9db8 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -49,6 +49,7 @@
EM(SKB_DROP_REASON_QDISC_DROP, QDISC_DROP) \
EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG) \
EM(SKB_DROP_REASON_XDP, XDP) \
+ EM(SKB_DROP_REASON_QDISC_INGRESS, QDISC_INGRESS) \
EMe(SKB_DROP_REASON_MAX, MAX)
#undef EM
diff --git a/net/core/dev.c b/net/core/dev.c
index ae85e024c7b7..429ad8265e8c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5013,7 +5013,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
break;
case TC_ACT_SHOT:
mini_qdisc_qstats_cpu_drop(miniq);
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_QDISC_INGRESS);
return NULL;
case TC_ACT_STOLEN:
case TC_ACT_QUEUED:
--
2.35.1