[Devel] [PATCH RHEL9 COMMIT] ipv6: Add reasons for skb drops to __udp6_lib_rcv

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 1538919588597349baa64aabc384a60e02e6a56b
Author: David Ahern <dsahern at kernel.org>
Date:   Tue Jan 3 17:39:04 2023 +0200

    ipv6: Add reasons for skb drops to __udp6_lib_rcv
    
    Add reasons to __udp6_lib_rcv for skb drops. The only twist is that the
    NO_SOCKET takes precedence over the CSUM or other counters for that
    path (motivation behind this patch - csum counter was misleading).
    
    Signed-off-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
---
 net/ipv6/udp.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 8cde9efd7919..297cfc069248 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -910,6 +910,7 @@ static int udp6_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb,
 int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 		   int proto)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	const struct in6_addr *saddr, *daddr;
 	struct net *net = dev_net(skb->dev);
 	struct udphdr *uh;
@@ -986,6 +987,8 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 		return udp6_unicast_rcv_skb(sk, skb, uh);
 	}
 
+	reason = SKB_DROP_REASON_NO_SOCKET;
+
 	if (!uh->check)
 		goto report_csum_error;
 
@@ -998,10 +1001,12 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	__UDP6_INC_STATS(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
 	icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
 
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return 0;
 
 short_packet:
+	if (reason == SKB_DROP_REASON_NOT_SPECIFIED)
+		reason = SKB_DROP_REASON_PKT_TOO_SMALL;
 	net_dbg_ratelimited("UDP%sv6: short packet: From [%pI6c]:%u %d/%d to [%pI6c]:%u\n",
 			    proto == IPPROTO_UDPLITE ? "-Lite" : "",
 			    saddr, ntohs(uh->source),
@@ -1012,10 +1017,12 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 report_csum_error:
 	udp6_csum_zero_error(skb);
 csum_error:
+	if (reason == SKB_DROP_REASON_NOT_SPECIFIED)
+		reason = SKB_DROP_REASON_UDP_CSUM;
 	__UDP6_INC_STATS(net, UDP_MIB_CSUMERRORS, proto == IPPROTO_UDPLITE);
 discard:
 	__UDP6_INC_STATS(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return 0;
 }
 


More information about the Devel mailing list