[Devel] [PATCH RHEL9 COMMIT] net: neigh: use kfree_skb_reason() for __neigh_event_send()

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

    net: neigh: use kfree_skb_reason() for __neigh_event_send()
    
    Replace kfree_skb() used in __neigh_event_send() with
    kfree_skb_reason(). Following drop reasons are added:
    
    SKB_DROP_REASON_NEIGH_FAILED
    SKB_DROP_REASON_NEIGH_QUEUEFULL
    SKB_DROP_REASON_NEIGH_DEAD
    
    The first two reasons above should be the hot path that skb drops
    in neighbour subsystem.
    
    Reviewed-by: Mengen Sun <mengensun at tencent.com>
    Reviewed-by: Hao Peng <flyingpeng at tencent.com>
    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     | 9 +++++----
 include/trace/events/skb.h | 3 +++
 net/core/neighbour.c       | 6 +++---
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 4cfc9f359d7d..df1c8c5110ed 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -387,10 +387,11 @@ enum skb_drop_reason {
 	SKB_DROP_REASON_NEIGH_CREATEFAIL,       /* failed to create neigh
 						 * entry
 						 */
-
-
-
-
+	SKB_DROP_REASON_NEIGH_FAILED,   /* neigh entry in failed state */
+	SKB_DROP_REASON_NEIGH_QUEUEFULL,        /* arp_queue for neigh
+						 * entry is full
+						 */
+	SKB_DROP_REASON_NEIGH_DEAD,     /* neigh entry is dead */
 	SKB_DROP_REASON_MAX,
 };
 
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index c28194e29b95..005ad4a645e1 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -42,6 +42,9 @@
 	   BPF_CGROUP_EGRESS)                                   \
 	EM(SKB_DROP_REASON_IPV6DISABLED, IPV6DISABLED)          \
 	EM(SKB_DROP_REASON_NEIGH_CREATEFAIL, NEIGH_CREATEFAIL)  \
+	EM(SKB_DROP_REASON_NEIGH_FAILED, NEIGH_FAILED)          \
+	EM(SKB_DROP_REASON_NEIGH_QUEUEFULL, NEIGH_QUEUEFULL)    \
+	EM(SKB_DROP_REASON_NEIGH_DEAD, NEIGH_DEAD)              \
 	EMe(SKB_DROP_REASON_MAX, MAX)
 
 #undef EM
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 04c17587dff2..e41708335ba2 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1192,7 +1192,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
 			neigh->updated = jiffies;
 			write_unlock_bh(&neigh->lock);
 
-			kfree_skb(skb);
+			kfree_skb_reason(skb, SKB_DROP_REASON_NEIGH_FAILED);
 			return 1;
 		}
 	} else if (neigh->nud_state & NUD_STALE) {
@@ -1214,7 +1214,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
 				if (!buff)
 					break;
 				neigh->arp_queue_len_bytes -= buff->truesize;
-				kfree_skb(buff);
+				kfree_skb_reason(buff, SKB_DROP_REASON_NEIGH_QUEUEFULL);
 				NEIGH_CACHE_STAT_INC(neigh->tbl, unres_discards);
 			}
 			skb_dst_force(skb);
@@ -1236,7 +1236,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
 	if (neigh->nud_state & NUD_STALE)
 		goto out_unlock_bh;
 	write_unlock_bh(&neigh->lock);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, SKB_DROP_REASON_NEIGH_DEAD);
 	trace_neigh_event_send_dead(neigh, 1);
 	return 1;
 }


More information about the Devel mailing list