Messages in this thread Patch in this message | | | From | menglong8.dong@gmail ... | Subject | [PATCH net-next v4 1/8] net: skb: use SKB_NOT_DROPPED in kfree_skb_reason() as consume_skb() | Date | Fri, 17 Jun 2022 18:05:07 +0800 |
| |
From: Menglong Dong <imagedong@tencent.com>
Inorder to simply the code, allow SKB_NOT_DROPPED to be passed to kfree_skb_reason(), suggested by Eric. Therefore, consume_skb(skb) can be replaced with kfree_skb_reason(skb, SKB_NOT_DROPPED).
Not sure if it is suitable to make consume_skb() a simple call to kfree_skb_reason(skb, SKB_NOT_DROPPED), as this can increase the function call chain.
Signed-off-by: Menglong Dong <imagedong@tencent.com> --- net/core/skbuff.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index b661040c100e..92f01b59ae40 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -769,15 +769,22 @@ EXPORT_SYMBOL(__kfree_skb); * Drop a reference to the buffer and free it if the usage count has * hit zero. Meanwhile, pass the drop reason to 'kfree_skb' * tracepoint. + * + * When the reason is SKB_NOT_DROPPED, it means that the packet is + * freed normally, and the event 'consume_skb' will be triggered. */ void kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) { if (!skb_unref(skb)) return; - DEBUG_NET_WARN_ON_ONCE(reason <= 0 || reason >= SKB_DROP_REASON_MAX); + DEBUG_NET_WARN_ON_ONCE(reason < 0 || reason >= SKB_DROP_REASON_MAX); + + if (reason) + trace_kfree_skb(skb, __builtin_return_address(0), reason); + else + trace_consume_skb(skb); - trace_kfree_skb(skb, __builtin_return_address(0), reason); __kfree_skb(skb); } EXPORT_SYMBOL(kfree_skb_reason); -- 2.36.1
| |