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>,
	Matthieu Baerts <matttbe@kernel.org>,
	 Mat Martineau <martineau@kernel.org>,
	Geliang Tang <geliang@kernel.org>
Subject: [PATCH v2 net-next 5/9] mptcp: snmp: do not use SNMP_MIB_SENTINEL anymore
Date: Fri,  5 Sep 2025 16:58:09 +0000	[thread overview]
Message-ID: <20250905165813.1470708-6-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: Matthieu Baerts <matttbe@kernel.org>
Cc: Mat Martineau <martineau@kernel.org>
Cc: Geliang Tang <geliang@kernel.org>
---
 net/mptcp/mib.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/mptcp/mib.c b/net/mptcp/mib.c
index cf879c188ca2..6003e47c770a 100644
--- a/net/mptcp/mib.c
+++ b/net/mptcp/mib.c
@@ -85,7 +85,6 @@ static const struct snmp_mib mptcp_snmp_list[] = {
 	SNMP_MIB_ITEM("DssFallback", MPTCP_MIB_DSSFALLBACK),
 	SNMP_MIB_ITEM("SimultConnectFallback", MPTCP_MIB_SIMULTCONNFALLBACK),
 	SNMP_MIB_ITEM("FallbackFailed", MPTCP_MIB_FALLBACKFAILED),
-	SNMP_MIB_SENTINEL
 };
 
 /* mptcp_mib_alloc - allocate percpu mib counters
@@ -108,22 +107,23 @@ bool mptcp_mib_alloc(struct net *net)
 
 void mptcp_seq_show(struct seq_file *seq)
 {
-	unsigned long sum[ARRAY_SIZE(mptcp_snmp_list) - 1];
+	unsigned long sum[ARRAY_SIZE(mptcp_snmp_list)];
+	const int cnt = ARRAY_SIZE(mptcp_snmp_list);
 	struct net *net = seq->private;
 	int i;
 
 	seq_puts(seq, "MPTcpExt:");
-	for (i = 0; mptcp_snmp_list[i].name; i++)
+	for (i = 0; i < cnt; i++)
 		seq_printf(seq, " %s", mptcp_snmp_list[i].name);
 
 	seq_puts(seq, "\nMPTcpExt:");
 
 	memset(sum, 0, sizeof(sum));
 	if (net->mib.mptcp_statistics)
-		snmp_get_cpu_field_batch(sum, mptcp_snmp_list,
-					 net->mib.mptcp_statistics);
+		snmp_get_cpu_field_batch_cnt(sum, mptcp_snmp_list, cnt,
+					     net->mib.mptcp_statistics);
 
-	for (i = 0; mptcp_snmp_list[i].name; i++)
+	for (i = 0; i < cnt; i++)
 		seq_printf(seq, " %lu", sum[i]);
 
 	seq_putc(seq, '\n');
-- 
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 ` Eric Dumazet [this message]
2025-09-06 12:59   ` [PATCH v2 net-next 5/9] mptcp: " 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 ` [PATCH v2 net-next 8/9] xfrm: " Eric Dumazet
2025-09-08 14:12   ` 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-6-edumazet@google.com \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=eric.dumazet@gmail.com \
    --cc=geliang@kernel.org \
    --cc=horms@kernel.org \
    --cc=jamie.bainbridge@gmail.com \
    --cc=kuba@kernel.org \
    --cc=martineau@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rawal.abhishek92@gmail.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).