[Devel] [PATCH RHEL9 COMMIT] skb: add some helpers for skb drop reasons

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jan 16 20:56:50 MSK 2023


The commit is pushed to "branch-rh9-5.14.0-162.6.1.vz9.18.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-162.6.1.vz9.18.2
------>
commit ced811694fe67c4a61c688f736eeb66686a26ec8
Author: Menglong Dong <imagedong at tencent.com>
Date:   Tue Jan 3 17:39:30 2023 +0200

    skb: add some helpers for skb drop reasons
    
    In order to simply the definition and assignment for
    'enum skb_drop_reason', introduce some helpers.
    
    SKB_DR() is used to define a variable of type 'enum skb_drop_reason'
    with the 'SKB_DROP_REASON_NOT_SPECIFIED' initial value.
    
    SKB_DR_SET() is used to set the value of the variable. Seems it is
    a little useless? But it makes the code shorter.
    
    SKB_DR_OR() is used to set the value of the variable if it is not set
    yet, which means its value is SKB_DROP_REASON_NOT_SPECIFIED.
    
    Signed-off-by: Menglong Dong <imagedong at tencent.com>
    Reviewed-by: Jiang Biao <benbjiang at tencent.com>
    Reviewed-by: Hao Peng <flyingpeng at tencent.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>
    Acked-by: Nikolay Borisov <nborisov at suse.com>
    Signed-off-by: Nikolay Borisov <nikolay.borisov at virtuozzo.com>
    
    ======
    Patchset description:
    ms/net: Annotate skb free sites with reason
    
    This series backports most of the patches that add a reason to skb free sites.
    
    https://jira.sw.ru/browse/PSBM-143302
    
    Feature: net: improve verbosity of dropped packets reporting
---
 include/linux/skbuff.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 4a79a2d8cb83..47047dc588aa 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -448,6 +448,18 @@ enum skb_drop_reason {
 	SKB_DROP_REASON_MAX,
 };
 
+#define SKB_DR_INIT(name, reason)				\
+	enum skb_drop_reason name = SKB_DROP_REASON_##reason
+#define SKB_DR(name)						\
+	SKB_DR_INIT(name, NOT_SPECIFIED)
+#define SKB_DR_SET(name, reason)				\
+	(name = SKB_DROP_REASON_##reason)
+#define SKB_DR_OR(name, reason)					\
+	do {							\
+		if (name == SKB_DROP_REASON_NOT_SPECIFIED)	\
+			SKB_DR_SET(name, reason);		\
+	} while (0)
+
 /* To allow 64K frame to be packed as single skb without frag_list we
  * require 64K/PAGE_SIZE pages plus 1 additional page to allow for
  * buffers which do not start on a page boundary.


More information about the Devel mailing list