netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>,
	 Jamie Bainbridge <jamie.bainbridge@gmail.com>,
	Abhishek Rawal <rawal.abhishek92@gmail.com>,
	 netdev@vger.kernel.org, eric.dumazet@gmail.com,
	 Eric Dumazet <edumazet@google.com>,
	Steffen Klassert <steffen.klassert@secunet.com>
Subject: [PATCH v2 net-next 8/9] xfrm: snmp: do not use SNMP_MIB_SENTINEL anymore
Date: Fri,  5 Sep 2025 16:58:12 +0000	[thread overview]
Message-ID: <20250905165813.1470708-9-edumazet@google.com> (raw)
In-Reply-To: <20250905165813.1470708-1-edumazet@google.com>

Use ARRAY_SIZE(), so that we know the limit at compile time.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/xfrm/xfrm_proc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/xfrm/xfrm_proc.c b/net/xfrm/xfrm_proc.c
index 8e07dd614b0b..5e1fd6b1d503 100644
--- a/net/xfrm/xfrm_proc.c
+++ b/net/xfrm/xfrm_proc.c
@@ -45,21 +45,21 @@ static const struct snmp_mib xfrm_mib_list[] = {
 	SNMP_MIB_ITEM("XfrmInStateDirError", LINUX_MIB_XFRMINSTATEDIRERROR),
 	SNMP_MIB_ITEM("XfrmInIptfsError", LINUX_MIB_XFRMINIPTFSERROR),
 	SNMP_MIB_ITEM("XfrmOutNoQueueSpace", LINUX_MIB_XFRMOUTNOQSPACE),
-	SNMP_MIB_SENTINEL
 };
 
 static int xfrm_statistics_seq_show(struct seq_file *seq, void *v)
 {
-	unsigned long buff[LINUX_MIB_XFRMMAX];
+	unsigned long buff[ARRAY_SIZE(xfrm_mib_list)];
+	const int cnt = ARRAY_SIZE(xfrm_mib_list);
 	struct net *net = seq->private;
 	int i;
 
-	memset(buff, 0, sizeof(unsigned long) * LINUX_MIB_XFRMMAX);
+	memset(buff, 0, sizeof(buff));
 
 	xfrm_state_update_stats(net);
-	snmp_get_cpu_field_batch(buff, xfrm_mib_list,
-				 net->mib.xfrm_statistics);
-	for (i = 0; xfrm_mib_list[i].name; i++)
+	snmp_get_cpu_field_batch_cnt(buff, xfrm_mib_list, cnt,
+				     net->mib.xfrm_statistics);
+	for (i = 0; i < cnt; i++)
 		seq_printf(seq, "%-24s\t%lu\n", xfrm_mib_list[i].name,
 						buff[i]);
 
-- 
2.51.0.355.g5224444f11-goog


  parent reply	other threads:[~2025-09-05 16:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05 16:58 [PATCH v2 net-next 0/9] ipv6: snmp: avoid performance issue with RATELIMITHOST Eric Dumazet
2025-09-05 16:58 ` [PATCH v2 net-next 1/9] ipv6: snmp: remove icmp6type2name[] Eric Dumazet
2025-09-08 13:49   ` Sabrina Dubroca
2025-09-05 16:58 ` [PATCH v2 net-next 2/9] ipv6: snmp: do not use SNMP_MIB_SENTINEL anymore Eric Dumazet
2025-09-08 13:49   ` Sabrina Dubroca
2025-09-05 16:58 ` [PATCH v2 net-next 3/9] ipv6: snmp: do not track per idev ICMP6_MIB_RATELIMITHOST Eric Dumazet
2025-09-05 16:58 ` [PATCH v2 net-next 4/9] ipv4: snmp: do not use SNMP_MIB_SENTINEL anymore Eric Dumazet
2025-09-08 13:54   ` Sabrina Dubroca
2025-09-05 16:58 ` [PATCH v2 net-next 5/9] mptcp: " Eric Dumazet
2025-09-06 12:59   ` Matthieu Baerts
2025-09-05 16:58 ` [PATCH v2 net-next 6/9] sctp: " Eric Dumazet
2025-09-08 13:56   ` Sabrina Dubroca
2025-09-08 15:29   ` Xin Long
2025-09-05 16:58 ` [PATCH v2 net-next 7/9] tls: " Eric Dumazet
2025-09-08 13:58   ` Sabrina Dubroca
2025-09-05 16:58 ` Eric Dumazet [this message]
2025-09-08 14:12   ` [PATCH v2 net-next 8/9] xfrm: " Sabrina Dubroca
2025-09-05 16:58 ` [PATCH v2 net-next 9/9] net: snmp: remove SNMP_MIB_SENTINEL Eric Dumazet
2025-09-08 14:18   ` Sabrina Dubroca
2025-09-09  1:30 ` [PATCH v2 net-next 0/9] ipv6: snmp: avoid performance issue with RATELIMITHOST patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250905165813.1470708-9-edumazet@google.com \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=eric.dumazet@gmail.com \
    --cc=horms@kernel.org \
    --cc=jamie.bainbridge@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rawal.abhishek92@gmail.com \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).