[Devel] [PATCH RHEL9 COMMIT] net: udp: use kfree_skb_reason() in __udp_queue_rcv_skb()

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

    net: udp: use kfree_skb_reason() in __udp_queue_rcv_skb()
    
    Replace kfree_skb() with kfree_skb_reason() in __udp_queue_rcv_skb().
    Following new drop reasons are introduced:
    
    SKB_DROP_REASON_SOCKET_RCVBUFF
    SKB_DROP_REASON_PROTO_MEM
    
    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     |  7 +++++++
 include/trace/events/skb.h |  2 ++
 net/ipv4/udp.c             | 10 +++++++---
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 10505942655f..f81a4bc09585 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -339,6 +339,13 @@ enum skb_drop_reason {
 						  */
 	SKB_DROP_REASON_XFRM_POLICY,    /* xfrm policy check failed */
 	SKB_DROP_REASON_IP_NOPROTO,     /* no support for IP protocol */
+	SKB_DROP_REASON_SOCKET_RCVBUFF, /* socket receive buff is full */
+	SKB_DROP_REASON_PROTO_MEM,      /* proto memory limition, such as
+					 * udp packet drop out of
+					 * udp_memory_allocated.
+					 */
+
+
 
 
 	SKB_DROP_REASON_MAX,
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 381840c1c7c1..2d11e23e402e 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -25,6 +25,8 @@
 	   UNICAST_IN_L2_MULTICAST)                             \
 	EM(SKB_DROP_REASON_XFRM_POLICY, XFRM_POLICY)            \
 	EM(SKB_DROP_REASON_IP_NOPROTO, IP_NOPROTO)              \
+	EM(SKB_DROP_REASON_SOCKET_RCVBUFF, SOCKET_RCVBUFF)      \
+	EM(SKB_DROP_REASON_PROTO_MEM, PROTO_MEM)                \
 	EMe(SKB_DROP_REASON_MAX, MAX)
 
 #undef EM
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index cf60596d2338..8db1dd9486ca 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2093,16 +2093,20 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 	rc = __udp_enqueue_schedule_skb(sk, skb);
 	if (rc < 0) {
 		int is_udplite = IS_UDPLITE(sk);
+		int drop_reason;
 
 		/* Note that an ENOMEM error is charged twice */
-		if (rc == -ENOMEM)
+		if (rc == -ENOMEM) {
 			UDP_INC_STATS(sock_net(sk), UDP_MIB_RCVBUFERRORS,
 					is_udplite);
-		else
+			drop_reason = SKB_DROP_REASON_SOCKET_RCVBUFF;
+		} else {
 			UDP_INC_STATS(sock_net(sk), UDP_MIB_MEMERRORS,
 				      is_udplite);
+			drop_reason = SKB_DROP_REASON_PROTO_MEM;
+		}
 		UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
-		kfree_skb(skb);
+		kfree_skb_reason(skb, drop_reason);
 		trace_udp_fail_queue_rcv_skb(rc, sk);
 		return -1;
 	}


More information about the Devel mailing list