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>,
	John Fastabend <john.fastabend@gmail.com>,
	 Sabrina Dubroca <sd@queasysnail.net>
Subject: [PATCH v2 net-next 7/9] tls: snmp: do not use SNMP_MIB_SENTINEL anymore
Date: Fri,  5 Sep 2025 16:58:11 +0000	[thread overview]
Message-ID: <20250905165813.1470708-8-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: John Fastabend <john.fastabend@gmail.com>
Cc: Sabrina Dubroca <sd@queasysnail.net>
---
 net/tls/tls_proc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/tls/tls_proc.c b/net/tls/tls_proc.c
index 367666aa07b8..4012c4372d4c 100644
--- a/net/tls/tls_proc.c
+++ b/net/tls/tls_proc.c
@@ -27,17 +27,19 @@ static const struct snmp_mib tls_mib_list[] = {
 	SNMP_MIB_ITEM("TlsTxRekeyOk", LINUX_MIB_TLSTXREKEYOK),
 	SNMP_MIB_ITEM("TlsTxRekeyError", LINUX_MIB_TLSTXREKEYERROR),
 	SNMP_MIB_ITEM("TlsRxRekeyReceived", LINUX_MIB_TLSRXREKEYRECEIVED),
-	SNMP_MIB_SENTINEL
 };
 
 static int tls_statistics_seq_show(struct seq_file *seq, void *v)
 {
-	unsigned long buf[LINUX_MIB_TLSMAX] = {};
+	unsigned long buf[ARRAY_SIZE(tls_mib_list)];
+	const int cnt = ARRAY_SIZE(tls_mib_list);
 	struct net *net = seq->private;
 	int i;
 
-	snmp_get_cpu_field_batch(buf, tls_mib_list, net->mib.tls_statistics);
-	for (i = 0; tls_mib_list[i].name; i++)
+	memset(buf, 0, sizeof(buf));
+	snmp_get_cpu_field_batch_cnt(buf, tls_mib_list, cnt,
+				     net->mib.tls_statistics);
+	for (i = 0; i < cnt; i++)
 		seq_printf(seq, "%-32s\t%lu\n", tls_mib_list[i].name, buf[i]);
 
 	return 0;
-- 
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 ` Eric Dumazet [this message]
2025-09-08 13:58   ` [PATCH v2 net-next 7/9] tls: " 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-8-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=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rawal.abhishek92@gmail.com \
    --cc=sd@queasysnail.net \
    /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).