[PATCH net-next 3/7] net: dev: add skb drop reasons to __dev_xmit_skb()
From: menglong8 . dong
Date: Thu Mar 03 2022 - 12:48:49 EST
From: Menglong Dong <imagedong@xxxxxxxxxxx>
Add reasons for skb drops to __dev_xmit_skb() by replacing
kfree_skb_list() with kfree_skb_list_reason(). The drop reason of
SKB_DROP_REASON_QDISC_DROP is introduced for qdisc enqueue fails.
Signed-off-by: Menglong Dong <imagedong@xxxxxxxxxxx>
---
include/linux/skbuff.h | 4 ++++
include/trace/events/skb.h | 1 +
net/core/dev.c | 5 +++--
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index e344603aecc4..62f9d15ec6ec 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -398,6 +398,10 @@ enum skb_drop_reason {
* failed (mapbe an eBPF program
* is tricking?)
*/
+ SKB_DROP_REASON_QDISC_DROP, /* dropped by qdisc when packet
+ * outputting (failed to enqueue to
+ * current qdisc)
+ */
SKB_DROP_REASON_MAX,
};
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 3cadf13448c6..80fe15d175e3 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -46,6 +46,7 @@
EM(SKB_DROP_REASON_NEIGH_QUEUEFULL, NEIGH_QUEUEFULL) \
EM(SKB_DROP_REASON_NEIGH_DEAD, NEIGH_DEAD) \
EM(SKB_DROP_REASON_QDISC_EGRESS, QDISC_EGRESS) \
+ EM(SKB_DROP_REASON_QDISC_DROP, QDISC_DROP) \
EMe(SKB_DROP_REASON_MAX, MAX)
#undef EM
diff --git a/net/core/dev.c b/net/core/dev.c
index 828946d74a19..3280ba2502cd 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3730,7 +3730,8 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
no_lock_out:
if (unlikely(to_free))
- kfree_skb_list(to_free);
+ kfree_skb_list_reason(to_free,
+ SKB_DROP_REASON_QDISC_DROP);
return rc;
}
@@ -3785,7 +3786,7 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
}
spin_unlock(root_lock);
if (unlikely(to_free))
- kfree_skb_list(to_free);
+ kfree_skb_list_reason(to_free, SKB_DROP_REASON_QDISC_DROP);
if (unlikely(contended))
spin_unlock(&q->busylock);
return rc;
--
2.35.1