net: dev: add skb drop reasons to net/core/dev.c
Subsystems (4)
cover net: dev: add skb drop reasons to net/core/dev.c
From: Menglong Dong <[email protected]>
In the commit c504e5c2f964 ("net: skb: introduce kfree_skb_reason()"), we added the support of reporting the reasons of skb drops to kfree_skb tracepoint. And in this series patches, reasons for skb drops are added to the link layer, which means that 'net/core/dev.c' is our target.
Following functions are processed:
sch_handle_egress()__dev_xmit_skb()enqueue_to_backlog()do_xdp_generic()sch_handle_ingress()__netif_receive_skb_core()
and following new drop reasons are added (what they mean can be see in the document of them):
SKB_DROP_REASON_QDISC_EGRESSSKB_DROP_REASON_QDISC_DROPSKB_DROP_REASON_CPU_BACKLOGSKB_DROP_REASON_XDPSKB_DROP_REASON_QDISC_INGRESSSKB_DROP_REASON_PTYPE_ABSENT
In order to add skb drop reasons to kfree_skb_list(), the function kfree_skb_list_reason() is introduced in the 2th patch, which will be used in __dev_xmit_skb() in the 3th patch.
Menglong Dong (7):
net: dev: use kfree_skb_reason() for sch_handle_egress()
net: skb: introduce the function kfree_skb_list_reason()
net: dev: add skb drop reasons to __dev_xmit_skb()
net: dev: use kfree_skb_reason() for enqueue_to_backlog()
net: dev: use kfree_skb_reason() for do_xdp_generic()
net: dev: use kfree_skb_reason() for sch_handle_ingress()
net: dev: use kfree_skb_reason() for __netif_receive_skb_core()
include/linux/skbuff.h | 32 +++++++++++++++++++++++++++++++- include/trace/events/skb.h | 5 +++++ net/core/dev.c | 25 ++++++++++++++++--------- net/core/skbuff.c | 7 ++++--- 4 files changed, 56 insertions(+), 13 deletions(-)
Signature · 1 line
2.35.1
PATCH 1/7 net: dev: use kfree_skb_reason() for sch_handle_egress()
From: Menglong Dong <[email protected]>
Replace kfree_skb() used in sch_handle_egress() with kfree_skb_reason(). The drop reason SKB_DROP_REASON_QDISC_EGRESS is introduced. Considering the code path of qdisc egerss, we make it distinct with the drop reason of SKB_DROP_REASON_QDISC_DROP in the next commit.
--- include/linux/skbuff.h | 4 ++++ include/trace/events/skb.h | 1 + net/core/dev.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-)
include/linux/skbuff.h +4 -0
@@ -394,6 +394,10 @@ enum skb_drop_reason {* entry is full */ SKB_DROP_REASON_NEIGH_DEAD ,/* neigh entry is dead */ +SKB_DROP_REASON_QDISC_EGRESS ,/* qdisc of type egress check +* failed (mapbe an eBPF program +* is tricking?) +*/ SKB_DROP_REASON_MAX, };
include/trace/events/skb.h +1 -0
@@ -45,6 +45,7 @@ EM(SKB_DROP_REASON_NEIGH_FAILED, NEIGH_FAILED) \ EM(SKB_DROP_REASON_NEIGH_QUEUEFULL, NEIGH_QUEUEFULL) \ EM(SKB_DROP_REASON_NEIGH_DEAD, NEIGH_DEAD) \ + EM(SKB_DROP_REASON_QDISC_EGRESS, QDISC_EGRESS) \ EMe(SKB_DROP_REASON_MAX, MAX)#undef EM
net/core/dev.c +1 -1
@@ -3860,7 +3860,7 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)case TC_ACT_SHOT :mini_qdisc_qstats_cpu_drop (miniq); *ret =NET_XMIT_DROP ; -kfree_skb (skb); +kfree_skb_reason (skb,SKB_DROP_REASON_QDISC_EGRESS );return NULL ;case TC_ACT_STOLEN :case TC_ACT_QUEUED :
Signature · 1 line
2.35.1
Jakub Kicinski
maintainerRe: [PATCH net-next 1/7] net: dev: use kfree_skb_reason() for sch_handle_egress()
Quoted 4 lines · On Fri, 4 Mar 2022 01:47:01 +0800 [email protected] wrote:
Replace
kfree_skb()used insch_handle_egress()withkfree_skb_reason(). The drop reasonSKB_DROP_REASON_QDISC_EGRESSis introduced. Considering the code path of qdisc egerss, we make it distinct with the drop reason ofSKB_DROP_REASON_QDISC_DROPin the next commit.
I don't think this has much to do with Qdiscs, this is the TC egress hook, it's more for filtering. Classful Qdisc like HTB will run its own classification. I think.
Maybe TC_EGRESS?
Re: [PATCH net-next 1/7] net: dev: use kfree_skb_reason() for sch_handle_egress()
Quoted 7 lines · Jakub Kicinski
Quoted 4 lines · On Fri, 4 Mar 2022 01:47:01 +0800 [email protected] wrote:
Replace
kfree_skb()used insch_handle_egress()withkfree_skb_reason(). The drop reasonSKB_DROP_REASON_QDISC_EGRESSis introduced. Considering the code path of qdisc egerss, we make it distinct with the drop reason ofSKB_DROP_REASON_QDISC_DROPin the next commit.
Quoted 5 lines
I don't think this has much to do with Qdiscs, this is the TC egress hook, it's more for filtering. Classful Qdisc like HTB will run its own classification. I think.
Maybe
TC_EGRESS?
You are right, I think I misunderstanded the concept of qdisc and tc before. and seems all 'QDISC' here should be 'TC'? which means:
QDISC_EGRESS -> TC_EGRESSQDISC_DROP -> TC_DROPQDISC_INGRESS -> TC_INGRESS
Jakub Kicinski
maintainerRe: [PATCH net-next 1/7] net: dev: use kfree_skb_reason() for sch_handle_egress()
Quoted 5 lines · On Fri, 4 Mar 2022 12:56:40 +0800 Menglong Dong wrote:
You are right, I think I misunderstanded the concept of qdisc and tc before. and seems all 'QDISC' here should be 'TC'? which means:
QDISC_EGRESS->TC_EGRESSQDISC_DROP->TC_DROP
For this one QDISC is good, I think, it will mostly catch packets which went thru qdisc_drop(), right?
Quoted 1 line
QDISC_INGRESS->TC_INGRESS
Re: [PATCH net-next 1/7] net: dev: use kfree_skb_reason() for sch_handle_egress()
Quoted 11 lines · Jakub Kicinski
Quoted 5 lines · On Fri, 4 Mar 2022 12:56:40 +0800 Menglong Dong wrote:
You are right, I think I misunderstanded the concept of qdisc and tc before. and seems all 'QDISC' here should be 'TC'? which means:
QDISC_EGRESS->TC_EGRESSQDISC_DROP->TC_DROPFor this one QDISC is good, I think, it will mostly catch packets which went thru
qdisc_drop(), right?
Yeah, you are right.
Quoted 1 line
Quoted 1 line
QDISC_INGRESS->TC_INGRESS
PATCH 2/7 net: skb: introduce the function kfree_skb_list_reason()
In reply to [email protected]From: Menglong Dong <[email protected]>
To report reasons of skb drops, introduce the function kfree_skb_list_reason() and make kfree_skb_list() an inline call to it. This function will be used in the next commit in __dev_xmit_skb().
--- include/linux/skbuff.h | 8 +++++++- net/core/skbuff.c | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-)
include/linux/skbuff.h +7 -1
@@ -1194,10 +1194,16 @@ static inline void kfree_skb(struct sk_buff *skb) }void skb_release_head_state (struct sk_buff *skb); -void kfree_skb_list (struct sk_buff *segs); +void kfree_skb_list_reason (struct sk_buff *segs, +enum skb_drop_reason reason);void skb_dump (const char *level,const struct sk_buff *skb,bool full_pkt);void skb_tx_error (struct sk_buff *skb); +static inline void kfree_skb_list (struct sk_buff *segs) +{ +kfree_skb_list_reason (segs,SKB_DROP_REASON_NOT_SPECIFIED ); +} +#ifdef CONFIG_TRACEPOINTS void consume_skb (struct sk_buff *skb);#else
net/core/skbuff.c +4 -3
@@ -777,16 +777,17 @@ void kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) }EXPORT_SYMBOL (kfree_skb_reason); -void kfree_skb_list (struct sk_buff *segs) +void kfree_skb_list_reason (struct sk_buff *segs, +enum skb_drop_reason reason) {while (segs) {struct sk_buff *next = segs->next; -kfree_skb (segs); +kfree_skb_reason (segs, reason); segs = next; } } -EXPORT_SYMBOL (kfree_skb_list); +EXPORT_SYMBOL (kfree_skb_list_reason);/* Dump skb information and contents. *
Signature · 1 line
2.35.1
Re: [PATCH net-next 2/7] net: skb: introduce the function kfree_skb_list_reason()
Hi Menglong,
I am going to send another v5 soon which introduces kfree_skb_list_reason() as well.
https://lore.kernel.org/all/[email protected]/
I will need to make it inline as suggested by Jakub.
Not sure how to handle such scenario :)
Thank you very much!
Dongli Zhang
Quoted 61 lines · On 3/3/22 9:47 AM, [email protected] wrote:
From: Menglong Dong <[email protected]>
To report reasons of skb drops, introduce the function
kfree_skb_list_reason()and makekfree_skb_list()an inline call to it. This function will be used in the next commit in__dev_xmit_skb().Signed-off-by Menglong Dong <[email protected]>--- include/linux/skbuff.h | 8 +++++++- net/core/skbuff.c | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-)include/linux/skbuff.h +7
-1@@ -1194,10 +1194,16 @@ static inline void kfree_skb(struct sk_buff *skb) }void skb_release_head_state (struct sk_buff *skb); -void kfree_skb_list (struct sk_buff *segs); +void kfree_skb_list_reason (struct sk_buff *segs, +enum skb_drop_reason reason);void skb_dump (const char *level,const struct sk_buff *skb,bool full_pkt);void skb_tx_error (struct sk_buff *skb); +static inline void kfree_skb_list (struct sk_buff *segs) +{ +kfree_skb_list_reason (segs,SKB_DROP_REASON_NOT_SPECIFIED ); +} +#ifdef CONFIG_TRACEPOINTS void consume_skb (struct sk_buff *skb);#else net/core/skbuff.c +4
-3@@ -777,16 +777,17 @@ void kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) }EXPORT_SYMBOL (kfree_skb_reason); -void kfree_skb_list (struct sk_buff *segs) +void kfree_skb_list_reason (struct sk_buff *segs, +enum skb_drop_reason reason) {while (segs) {struct sk_buff *next = segs->next; -kfree_skb (segs); +kfree_skb_reason (segs, reason); segs = next; } } -EXPORT_SYMBOL (kfree_skb_list); +EXPORT_SYMBOL (kfree_skb_list_reason);/* Dump skb information and contents. *
Jakub Kicinski
maintainerRe: [PATCH net-next 2/7] net: skb: introduce the function kfree_skb_list_reason()
Quoted 7 lines · On Thu, 3 Mar 2022 16:12:05 -0800 Dongli Zhang wrote:
I am going to send another v5 soon which introduces
kfree_skb_list_reason()as well.https://lore.kernel.org/all/[email protected]/
I will need to make it inline as suggested by Jakub.
Not sure how to handle such scenario :)
Probably nothing we can do about that :( I'd say proceed as if the other series didn't exist, and after one series is merged the author of the other one will have to rebase.
PATCH 3/7 net: dev: add skb drop reasons to __dev_xmit_skb()
In reply to [email protected]From: Menglong Dong <[email protected]>
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.
--- include/linux/skbuff.h | 4 ++++ include/trace/events/skb.h | 1 + net/core/dev.c | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-)
include/linux/skbuff.h +4 -0
@@ -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, };
include/trace/events/skb.h +1 -0
@@ -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
net/core/dev.c +3 -2
@@ -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;
Signature · 1 line
2.35.1
PATCH 4/7 net: dev: use kfree_skb_reason() for enqueue_to_backlog()
In reply to [email protected]From: Menglong Dong <[email protected]>
Replace kfree_skb() used in enqueue_to_backlog() with kfree_skb_reason(). The skb rop reason SKB_DROP_REASON_CPU_BACKLOG is introduced for the case of failing to enqueue the skb to the per CPU backlog queue. The further reason can be backlog queue full or RPS flow limition, and I think we meedn't to make further distinctions.
--- include/linux/skbuff.h | 6 ++++++ include/trace/events/skb.h | 1 + net/core/dev.c | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-)
include/linux/skbuff.h +6 -0
@@ -402,6 +402,12 @@ enum skb_drop_reason {* outputting (failed to enqueue to * current qdisc) */ +SKB_DROP_REASON_CPU_BACKLOG ,/* failed to enqueue the skb to +* the per CPU backlog queue. This +* can be caused by backlog queue +* full (see netdev_max_backlog in +* net.rst) or RPS flow limit +*/ SKB_DROP_REASON_MAX, };
include/trace/events/skb.h +1 -0
@@ -47,6 +47,7 @@ EM(SKB_DROP_REASON_NEIGH_DEAD, NEIGH_DEAD) \ EM(SKB_DROP_REASON_QDISC_EGRESS, QDISC_EGRESS) \ EM(SKB_DROP_REASON_QDISC_DROP, QDISC_DROP) \ + EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG) \ EMe(SKB_DROP_REASON_MAX, MAX)#undef EM
net/core/dev.c +5 -1
@@ -4541,10 +4541,12 @@ static bool skb_flow_limit(struct sk_buff *skb, unsigned int qlen)static int enqueue_to_backlog (struct sk_buff *skb,int cpu,unsigned int *qtail) { +enum skb_drop_reason reason;struct softnet_data *sd;unsigned long flags;unsigned int qlen; + reason =SKB_DROP_REASON_NOT_SPECIFIED ; sd = &per_cpu (softnet_data, cpu);rps_lock_irqsave (sd, &flags);
@@ -4566,6 +4568,8 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu,if (!__test_and_set_bit (NAPI_STATE_SCHED , &sd->backlog.state))napi_schedule_rps (sd); goto enqueue; + }else { + reason =SKB_DROP_REASON_CPU_BACKLOG ; } drop:
@@ -4573,7 +4577,7 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu,rps_unlock_irq_restore (sd, &flags);atomic_long_inc (&skb->dev->rx_dropped); -kfree_skb (skb); +kfree_skb_reason (skb, reason);return NET_RX_DROP ; }
Signature · 1 line
2.35.1
Re: [PATCH net-next 4/7] net: dev: use kfree_skb_reason() for enqueue_to_backlog()
Quoted 63 lines · On Thu, Mar 3, 2022 at 9:48 AM <[email protected]> wrote:
From: Menglong Dong <[email protected]>
Replace
kfree_skb()used inenqueue_to_backlog()withkfree_skb_reason(). The skb rop reasonSKB_DROP_REASON_CPU_BACKLOGis introduced for the case of failing to enqueue the skb to the per CPU backlog queue. The further reason can be backlog queue full or RPS flow limition, and I think we meedn't to make further distinctions.Signed-off-by Menglong Dong <[email protected]>--- include/linux/skbuff.h | 6 ++++++ include/trace/events/skb.h | 1 + net/core/dev.c | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-)include/linux/skbuff.h +6
-0@@ -402,6 +402,12 @@ enum skb_drop_reason {* outputting (failed to enqueue to * current qdisc) */ +SKB_DROP_REASON_CPU_BACKLOG ,/* failed to enqueue the skb to +* the per CPU backlog queue. This +* can be caused by backlog queue +* full (see netdev_max_backlog in +* net.rst) or RPS flow limit +*/ SKB_DROP_REASON_MAX, };include/trace/events/skb.h +1
-0@@ -47,6 +47,7 @@ EM(SKB_DROP_REASON_NEIGH_DEAD, NEIGH_DEAD) \ EM(SKB_DROP_REASON_QDISC_EGRESS, QDISC_EGRESS) \ EM(SKB_DROP_REASON_QDISC_DROP, QDISC_DROP) \ + EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG) \ EMe(SKB_DROP_REASON_MAX, MAX)#undef EMnet/core/dev.c +2
-0@@ -4541,10 +4541,12 @@ static bool skb_flow_limit(struct sk_buff *skb, unsigned int qlen)static int enqueue_to_backlog (struct sk_buff *skb,int cpu,unsigned int *qtail) { +enum skb_drop_reason reason;struct softnet_data *sd;unsigned long flags;unsigned int qlen; + reason =SKB_DROP_REASON_NOT_SPECIFIED ; sd = &per_cpu (softnet_data, cpu);rps_lock_irqsave (sd, &flags);
net/core/dev.c static int enqueue_to_backlog(struct sk_buff *skb, int cpu, · line 4571
Quoted 4 lines
net/core/dev.c +1
-0@@ -4566,6 +4568,8 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu,if (!__test_and_set_bit (NAPI_STATE_SCHED , &sd->backlog.state))napi_schedule_rps (sd); goto enqueue; + }else {
No need for an else {} after a goto xxx;
Quoted 16 lines
net/core/dev.c +2
-2+ reason =SKB_DROP_REASON_CPU_BACKLOG ; } drop:@@ -4573,7 +4577,7 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu,rps_unlock_irq_restore (sd, &flags);atomic_long_inc (&skb->dev->rx_dropped); -kfree_skb (skb); +kfree_skb_reason (skb, reason);return NET_RX_DROP ; } --2.35.1
Re: [PATCH net-next 4/7] net: dev: use kfree_skb_reason() for enqueue_to_backlog()
Quoted 63 lines · Eric Dumazet
Quoted 61 lines · On Thu, Mar 3, 2022 at 9:48 AM <[email protected]> wrote:
From: Menglong Dong <[email protected]>
Replace
kfree_skb()used inenqueue_to_backlog()withkfree_skb_reason(). The skb rop reasonSKB_DROP_REASON_CPU_BACKLOGis introduced for the case of failing to enqueue the skb to the per CPU backlog queue. The further reason can be backlog queue full or RPS flow limition, and I think we meedn't to make further distinctions.Signed-off-by Menglong Dong <[email protected]>--- include/linux/skbuff.h | 6 ++++++ include/trace/events/skb.h | 1 + net/core/dev.c | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-)include/linux/skbuff.h +6
-0@@ -402,6 +402,12 @@ enum skb_drop_reason {* outputting (failed to enqueue to * current qdisc) */ +SKB_DROP_REASON_CPU_BACKLOG ,/* failed to enqueue the skb to +* the per CPU backlog queue. This +* can be caused by backlog queue +* full (see netdev_max_backlog in +* net.rst) or RPS flow limit +*/ SKB_DROP_REASON_MAX, };include/trace/events/skb.h +1
-0@@ -47,6 +47,7 @@ EM(SKB_DROP_REASON_NEIGH_DEAD, NEIGH_DEAD) \ EM(SKB_DROP_REASON_QDISC_EGRESS, QDISC_EGRESS) \ EM(SKB_DROP_REASON_QDISC_DROP, QDISC_DROP) \ + EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG) \ EMe(SKB_DROP_REASON_MAX, MAX)#undef EMnet/core/dev.c +2
-0@@ -4541,10 +4541,12 @@ static bool skb_flow_limit(struct sk_buff *skb, unsigned int qlen)static int enqueue_to_backlog (struct sk_buff *skb,int cpu,unsigned int *qtail) { +enum skb_drop_reason reason;struct softnet_data *sd;unsigned long flags;unsigned int qlen; + reason =SKB_DROP_REASON_NOT_SPECIFIED ; sd = &per_cpu (softnet_data, cpu);
Quoted 9 lines
net/core/dev.c static int enqueue_to_backlog(struct sk_buff *skb, int cpu, · line 4571
Quoted 6 lines
net/core/dev.c +1
-0rps_lock_irqsave (sd, &flags);@@ -4566,6 +4568,8 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu,if (!__test_and_set_bit (NAPI_STATE_SCHED , &sd->backlog.state))napi_schedule_rps (sd); goto enqueue; + }else {No need for an else {} after a goto xxx;
Yeah, this 'else' can be omitted :) Thanks!
Quoted 17 lines
Quoted 17 lines
net/core/dev.c +2
-2+ reason =SKB_DROP_REASON_CPU_BACKLOG ; } drop:@@ -4573,7 +4577,7 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu,rps_unlock_irq_restore (sd, &flags);atomic_long_inc (&skb->dev->rx_dropped); -kfree_skb (skb); +kfree_skb_reason (skb, reason);return NET_RX_DROP ; } --2.35.1
PATCH 5/7 net: dev: use kfree_skb_reason() for do_xdp_generic()
In reply to [email protected]From: Menglong Dong <[email protected]>
Replace kfree_skb() used in do_xdp_generic() with kfree_skb_reason(). The drop reason SKB_DROP_REASON_XDP is introduced for this case.
--- include/linux/skbuff.h | 1 + include/trace/events/skb.h | 1 + net/core/dev.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-)
include/linux/skbuff.h +1 -0
@@ -408,6 +408,7 @@ enum skb_drop_reason {* full (see netdev_max_backlog in * net.rst) or RPS flow limit */ +SKB_DROP_REASON_XDP ,/* dropped by XDP in input path */ SKB_DROP_REASON_MAX, };
include/trace/events/skb.h +1 -0
@@ -48,6 +48,7 @@ EM(SKB_DROP_REASON_QDISC_EGRESS, QDISC_EGRESS) \ EM(SKB_DROP_REASON_QDISC_DROP, QDISC_DROP) \ EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG) \ + EM(SKB_DROP_REASON_XDP, XDP) \ EMe(SKB_DROP_REASON_MAX, MAX)#undef EM
net/core/dev.c +1 -1
@@ -4797,7 +4797,7 @@ int do_xdp_generic(struct bpf_prog *xdp_prog, struct sk_buff *skb) }return XDP_PASS ; out_redir: -kfree_skb (skb); +kfree_skb_reason (skb,SKB_DROP_REASON_XDP );return XDP_DROP ; }EXPORT_SYMBOL_GPL (do_xdp_generic);
Signature · 1 line
2.35.1
PATCH 6/7 net: dev: use kfree_skb_reason() for sch_handle_ingress()
In reply to [email protected]From: Menglong Dong <[email protected]>
Replace kfree_skb() used in sch_handle_ingress() with kfree_skb_reason(). Following drop reasons are introduced:
SKB_DROP_REASON_QDISC_INGRESS
--- include/linux/skbuff.h | 4 ++++ include/trace/events/skb.h | 1 + net/core/dev.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-)
include/linux/skbuff.h +4 -0
@@ -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, };
include/trace/events/skb.h +1 -0
@@ -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
net/core/dev.c +1 -1
@@ -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 :
Signature · 1 line
2.35.1
PATCH 7/7 net: dev: use kfree_skb_reason() for __netif_receive_skb_core()
In reply to [email protected]From: Menglong Dong <[email protected]>
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.
--- include/linux/skbuff.h | 5 +++++ net/core/dev.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-)
include/linux/skbuff.h +5 -0
@@ -413,6 +413,11 @@ enum skb_drop_reason {* failed (maybe an eBPF program * is tricking?) */ +SKB_DROP_REASON_PTYPE_ABSENT ,/* not packet_type found to handle +* the skb. For an etner packet, +* this means that L3 protocol is +* not supported +*/ SKB_DROP_REASON_MAX, };
net/core/dev.c +5 -3
@@ -5330,11 +5330,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. :-) */
Signature · 1 line
2.35.1