🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19239

[PATCH v8 4/4] net: drop_monitor: use drop_reason_lookup()

#19239
From: Johannes Berg
Date: Thu, 19 Nov 2026 15:48
104 lines
12290 bytes
From: Johannes Berg <johannes.berg@intel.com>

Now that we have drop_reason_lookup(), we can just use it for
drop_monitor as well, rather than exporting the list itself.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
v7: don't hide drop_reason_show() prototype (sashiko,
    but it got it the wrong way around)
---
 include/net/dropreason.h |  5 +----
 net/core/drop_monitor.c  | 20 +++++---------------
 net/core/skbuff.c        |  6 +++---
 3 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/include/net/dropreason.h b/include/net/dropreason.h
index dc4a60130c09..537428c72642 100644
--- a/include/net/dropreason.h
+++ b/include/net/dropreason.h
@@ -38,12 +38,9 @@ struct drop_reason_list {
 	size_t n_reasons;
 };
 
-/* Note: due to dynamic registrations, access must be under RCU */
-extern const struct drop_reason_list __rcu *
-drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM];
+const char *drop_reason_lookup(unsigned long long value);
 
 #ifdef CONFIG_TRACEPOINTS
-const char *drop_reason_lookup(unsigned long long value);
 void drop_reason_show(struct seq_file *m);
 #endif
 
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index edc660778408..5aa7692c5df2 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -611,9 +611,8 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,
 				     size_t payload_len)
 {
 	struct net_dm_skb_cb *cb = NET_DM_SKB_CB(skb);
-	const struct drop_reason_list *list = NULL;
-	unsigned int subsys, subsys_reason;
 	char buf[NET_DM_MAX_SYMBOL_LEN];
+	const char *reason_str;
 	struct nlattr *attr;
 	void *hdr;
 	int rc;
@@ -631,19 +630,10 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,
 		goto nla_put_failure;
 
 	rcu_read_lock();
-	subsys = u32_get_bits(cb->reason, SKB_DROP_REASON_SUBSYS_MASK);
-	if (subsys < SKB_DROP_REASON_SUBSYS_NUM)
-		list = rcu_dereference(drop_reasons_by_subsys[subsys]);
-	subsys_reason = cb->reason & ~SKB_DROP_REASON_SUBSYS_MASK;
-	if (!list ||
-	    subsys_reason >= list->n_reasons ||
-	    !list->reasons[subsys_reason] ||
-	    strlen(list->reasons[subsys_reason]) > NET_DM_MAX_REASON_LEN) {
-		list = rcu_dereference(drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_CORE]);
-		subsys_reason = SKB_DROP_REASON_NOT_SPECIFIED;
-	}
-	if (nla_put_string(msg, NET_DM_ATTR_REASON,
-			   list->reasons[subsys_reason])) {
+	reason_str = drop_reason_lookup(cb->reason);
+	if (unlikely(!reason_str))
+		reason_str = drop_reason_lookup(SKB_DROP_REASON_NOT_SPECIFIED);
+	if (nla_put_string(msg, NET_DM_ATTR_REASON, reason_str)) {
 		rcu_read_unlock();
 		goto nla_put_failure;
 	}
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index d83d89e310de..5ce442a283d4 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -149,13 +149,11 @@ static const struct drop_reason_list drop_reasons_core = {
 	.n_reasons = ARRAY_SIZE(drop_reasons),
 };
 
-const struct drop_reason_list __rcu *
+static const struct drop_reason_list __rcu *
 drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM] = {
 	[SKB_DROP_REASON_SUBSYS_CORE] = RCU_INITIALIZER(&drop_reasons_core),
 };
-EXPORT_SYMBOL(drop_reasons_by_subsys);
 
-#ifdef CONFIG_TRACEPOINTS
 const char *drop_reason_lookup(unsigned long long value)
 {
 	unsigned long long subsys_id = value >> SKB_DROP_REASON_SUBSYS_SHIFT;
@@ -172,7 +170,9 @@ const char *drop_reason_lookup(unsigned long long value)
 		return NULL;
 	return subsys->reasons[reason];
 }
+EXPORT_SYMBOL(drop_reason_lookup);
 
+#ifdef CONFIG_TRACEPOINTS
 void drop_reason_show(struct seq_file *m)
 {
 	u32 subsys_id;
-- 
2.56.1
Technical Details
Message-ID: <20261119155133.355849-10-johannes@sipsolutions.net>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367135-linux-kernel-netdev=dewy.ru
References: <20261119155133.355849-6-johannes@sipsolutions.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367135-linux-kernel-netdev=dewy.ru
From: johannes@sipsolutions.net (Johannes Berg)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v8 4/4] net: drop_monitor: use drop_reason_lookup()
Date: Thu, 19 Nov 2026 16:48:44 +0100
Organization: Usenet Network
Message-ID: <20261119155133.355849-10-johannes@sipsolutions.net>
References: <20261119155133.355849-6-johannes@sipsolutions.net>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2916748"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Yztw7iMwEJ+Zln8OZ84HzOdjtwY= sha256:TvqMpB0cBXMin6lTeWJFufhr0L7M1oxrNbcZ4rI+gqg=
	sha1:NGgOZNwZed6ZU8GeNUrbfEIujjQ= sha256:T+m/Pk5FCoSV1bxsh6MXmeL5JBarESgktxWoWgy8NaY=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 98FC41156D0; Thu, 19 Nov 2026 18:52:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.15
X-Spam-Status: No, score=-3.15 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=sipsolutions.net
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Ic6ww0Si9ESa;
	Thu, 19 Nov 2026 18:52:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-367135-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=permerror header.from=sipsolutions.net
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id B892D1156CF; Thu, 19 Nov 2026 18:52:18 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 2E1C86C069D; Thu, 19 Nov 2026 15:52:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795103506;
	b=RWV62cIbxTdNCU6u6aFX50dWSi0czVhaGVEAtiASFOXdXBsViPbXkaaQ6D1oV8xk+4VS
	 YIVFR+skmQRtkbC7DodQHSfqsnflXHft877SOwDU7BxzMZdLHMcBvJb9pS1MexQP9zKpr
	 ob5941BVQWJ2qKWyGAi2bYvyhhDhP0FaNyGro+HZ/mfjqpoZ93P3SGtpvEXKeF3BTw6Pf
	 JaApX5+kDlsqiOJsET0r1jB3BL9KZAfpVoFGnG/tM/Z0s8SQ5DbjKk5akVASuXsAMg5dy
	 7fx8KSl/l8dpccMvhVGqT6bAWUxcyjZd9GUmFxm6BQ6LvDAv2jt0h6VLy+/4X0Zl28w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795103506;
	h=X-Original-To:Received:DKIM-Signature:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=SxDUG3/xM066tA6uiM6W3v/WIO1jwIP5o8aTwpX/ISo=;
	b=BBAXaXI7sjysa5dp5svAuJMdBczYom0Wt6cEgLGGbsR9hKNwWvaLSSbEZD0pHYGrkgV2
	 MMfYJruwWAJDfwIX7pZ0fu2l9NG0/QqOdkjAq51xKkb1mUt/4uoq1ah9DRkJLumwm+Aru
	 kbK8JXF59ha7VVKESBczPSHR0B5FQQejZb1T+mOaUd/9lTlXJOjgzCyo06E9WtnJ6k0i2
	 7BIszGYyL99Pc3/+6gJdl65fqGsqLctPyu6nNVUatBzZaJWQacbKsPwo2XADgIlQcZ/dr
	 Y94wIVc8HPz9k1jtKws+tJo9vZuBvaqzHt722J67fVImVL3PbrEMhS+OLYWME6plYTg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=w9B7X6bN;
	dmarc=permerror header.from=sipsolutions.net;
	spf=pass smtp.mailfrom=sipsolutions.net;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id F0F3C60A383F;
	Thu, 19 Nov 2026 15:51:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=w9B7X6bN
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=168.119.38.16
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795103505;
	b=Tt3A2EUlBWGthC9CjHpN5Iy2QPrAdL2LZw9deOdjLTq2eZxXv6aET7Az22/+2zm0Ynsz
	 t7t/edY4H/BOlpg+7gKK2towOhWSZ3C4FDsEdXjOLlS7BoX92aXwDws5A0H+1MAKPdEUU
	 g0GREqUIJJhe2EMc/lrCQrC8VwoULoWeq2WjHR6SS3Om7xN6F4cIeLS2cT29SeAaTLEuh
	 Jg+mRx3GFvuIelLeIfSwAMjW5820K0hpb39zHwTIYZ3RvpYaByC6D1mlsgk4l7GZLGI1Z
	 9B5jVmgNVG9Pvz/MGVj8O5DIcagSqPVE4VLkzNpiRtRRZEGB/IjNbtXQ9TPpe5AvKYg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795103505;
	h=DKIM-Signature:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=SxDUG3/xM066tA6uiM6W3v/WIO1jwIP5o8aTwpX/ISo=;
	b=yaReGO1hhODABUbNCFfyZN7ej+fjOfoMbTfAa6fvp1o0flX93KEc/fWU5+dtGl5zUhi+
	 l0U03rptidA+LVuvtlubuq3Y5hLAkJm5bfbqjiH0EwtkZR1tnVo/zSOT62XLSW5F4bc1V
	 PCOQgVMFWJIqRBsyLR0pNJYEd9O17h9/ab4XJK7g7ORn10+XVPkai5RVjj89FAU3ZTUDE
	 Wz7W0J9ZXERIztjM8ocBIZUYHwHkRbdIheVd/zdnSuab8fBX9jui0MgGZRv/sCupEyc2m
	 mr6IrObXN4klIpmaSQ6EE4Bw4mn+EAay9gYmsCDsgsh7foPLF4T3Kt3g+pXmY1cZ6PQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=permerror header.from=sipsolutions.net;
	spf=pass smtp.mailfrom=sipsolutions.net;
	dkim=pass header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=w9B7X6bN;
	arc=none smtp.remote-ip=168.119.38.16
X-Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5C7060A2615;
	Thu, 19 Nov 2026 15:51:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=permerror header.from=sipsolutions.net
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
	d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version:
	References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender
	:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To:
	Resent-Cc:Resent-Message-ID; bh=SxDUG3/xM066tA6uiM6W3v/WIO1jwIP5o8aTwpX/ISo=;
	t=1795103504; x=1796313104; b=w9B7X6bNp5bY2m6AiZiN6BLBqP1kSBf24dF+wJwgomjPOu9
	k8/uZ83S9XDis22Auhx/AoNH6+uPj/ITKRhNZoH69pA0PxFFuPrx8fxhsNbT3+ajTK3OAi7oLUPr7
	OPHSGNRml7JmddPTkHKoMX0G4SB3KIvdjJq0PV20kjxr8jj+uU+q9HDGilBBBH50LCmQt9zEs3u9d
	xV7KMTkToAmjJpM+jYwjvQ95LZRQSMt2WnBcpBFERTfmkCWxNPk4VUAJpsKPu1xHzzCvrxjclLK0q
	iivme1YZW33wkEtxnQc4UC57LRXsZG5OvNU/V/gez2Ex0QhSZGNP7qwHrOOb3G/g==;
X-Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__ECDSA_SECP256R1_SHA256__AES_256_GCM:256)
	(Exim 4.98.2)
	(envelope-from <johannes@sipsolutions.net>)
	id 1xU4QG-00000004ZOV-2bVG;
	Thu, 19 Nov 2026 16:51:40 +0100
X-Cc: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Ilya Maximets <i.maximets@ovn.org>,
	Matthieu Baerts <matttbe@kernel.org>,
	Aaron Conole <aconole@redhat.com>,
	Eelco Chaudron <echaudro@redhat.com>,
	dev@openvswitch.org,
	Adrian Moreno <amorenoz@redhat.com>,
	Antoine Tenart <atenart@kernel.org>,
	Johannes Berg <johannes.berg@intel.com>
X-Mailer: git-send-email 2.56.1
X-In-Reply-To: <20261119155133.355849-6-johannes@sipsolutions.net>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list