[Devel] [PATCH RHEL9 COMMIT] net: ipv4: use kfree_skb_reason() in ip_protocol_deliver_rcu()

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jan 16 20:56:40 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 0f6ad87b565800d5ead7053fed8b476d0e388353
Author: Menglong Dong <imagedong at tencent.com>
Date:   Tue Jan 3 17:39:00 2023 +0200

    net: ipv4: use kfree_skb_reason() in ip_protocol_deliver_rcu()
    
    Replace kfree_skb() with kfree_skb_reason() in ip_protocol_deliver_rcu().
    Following new drop reasons are introduced:
    
    SKB_DROP_REASON_XFRM_POLICY
    SKB_DROP_REASON_IP_NOPROTO
    
    Signed-off-by: Menglong Dong <imagedong at tencent.com>
    Reviewed-by: David Ahern <dsahern at kernel.org>
    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     | 2 ++
 include/trace/events/skb.h | 2 ++
 net/ipv4/ip_input.c        | 5 +++--
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index bc067688b1e4..aa7bed26bb0d 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -337,6 +337,8 @@ enum skb_drop_reason {
 						  * is multicast, but L3 is
 						  * unicast.
 						  */
+	SKB_DROP_REASON_XFRM_POLICY,    /* xfrm policy check failed */
+	SKB_DROP_REASON_IP_NOPROTO,     /* no support for IP protocol */
 
 
 	SKB_DROP_REASON_MAX,
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index f4aa403da950..92ee7d674725 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -23,6 +23,8 @@
 	EM(SKB_DROP_REASON_IP_RPFILTER, IP_RPFILTER)            \
 	EM(SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST,             \
 	   UNICAST_IN_L2_MULTICAST)                             \
+	EM(SKB_DROP_REASON_XFRM_POLICY, XFRM_POLICY)            \
+	EM(SKB_DROP_REASON_IP_NOPROTO, IP_NOPROTO)              \
 	EMe(SKB_DROP_REASON_MAX, MAX)
 
 #undef EM
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index d5222c0fa87c..d94f9f7e60c3 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -196,7 +196,8 @@ void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int protocol)
 	if (ipprot) {
 		if (!ipprot->no_policy) {
 			if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
-				kfree_skb(skb);
+				kfree_skb_reason(skb,
+						 SKB_DROP_REASON_XFRM_POLICY);
 				return;
 			}
 			nf_reset_ct(skb);
@@ -215,7 +216,7 @@ void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int protocol)
 				icmp_send(skb, ICMP_DEST_UNREACH,
 					  ICMP_PROT_UNREACH, 0);
 			}
-			kfree_skb(skb);
+			kfree_skb_reason(skb, SKB_DROP_REASON_IP_NOPROTO);
 		} else {
 			__IP_INC_STATS(net, IPSTATS_MIB_INDELIVERS);
 			consume_skb(skb);


More information about the Devel mailing list