Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tls: snmp: do not use SNMP_MIB_SENTINEL anymore

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>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Link: https://patch.msgid.link/20250905165813.1470708-8-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
3a951f95 52a33cae

+6 -4
+6 -4
net/tls/tls_proc.c
··· 27 27 SNMP_MIB_ITEM("TlsTxRekeyOk", LINUX_MIB_TLSTXREKEYOK), 28 28 SNMP_MIB_ITEM("TlsTxRekeyError", LINUX_MIB_TLSTXREKEYERROR), 29 29 SNMP_MIB_ITEM("TlsRxRekeyReceived", LINUX_MIB_TLSRXREKEYRECEIVED), 30 - SNMP_MIB_SENTINEL 31 30 }; 32 31 33 32 static int tls_statistics_seq_show(struct seq_file *seq, void *v) 34 33 { 35 - unsigned long buf[LINUX_MIB_TLSMAX] = {}; 34 + unsigned long buf[ARRAY_SIZE(tls_mib_list)]; 35 + const int cnt = ARRAY_SIZE(tls_mib_list); 36 36 struct net *net = seq->private; 37 37 int i; 38 38 39 - snmp_get_cpu_field_batch(buf, tls_mib_list, net->mib.tls_statistics); 40 - for (i = 0; tls_mib_list[i].name; i++) 39 + memset(buf, 0, sizeof(buf)); 40 + snmp_get_cpu_field_batch_cnt(buf, tls_mib_list, cnt, 41 + net->mib.tls_statistics); 42 + for (i = 0; i < cnt; i++) 41 43 seq_printf(seq, "%-32s\t%lu\n", tls_mib_list[i].name, buf[i]); 42 44 43 45 return 0;