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

mptcp: 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: Mat Martineau <martineau@kernel.org>
Cc: Geliang Tang <geliang@kernel.org>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20250905165813.1470708-6-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
35cb2da0 b7b74953

+6 -6
+6 -6
net/mptcp/mib.c
··· 85 85 SNMP_MIB_ITEM("DssFallback", MPTCP_MIB_DSSFALLBACK), 86 86 SNMP_MIB_ITEM("SimultConnectFallback", MPTCP_MIB_SIMULTCONNFALLBACK), 87 87 SNMP_MIB_ITEM("FallbackFailed", MPTCP_MIB_FALLBACKFAILED), 88 - SNMP_MIB_SENTINEL 89 88 }; 90 89 91 90 /* mptcp_mib_alloc - allocate percpu mib counters ··· 107 108 108 109 void mptcp_seq_show(struct seq_file *seq) 109 110 { 110 - unsigned long sum[ARRAY_SIZE(mptcp_snmp_list) - 1]; 111 + unsigned long sum[ARRAY_SIZE(mptcp_snmp_list)]; 112 + const int cnt = ARRAY_SIZE(mptcp_snmp_list); 111 113 struct net *net = seq->private; 112 114 int i; 113 115 114 116 seq_puts(seq, "MPTcpExt:"); 115 - for (i = 0; mptcp_snmp_list[i].name; i++) 117 + for (i = 0; i < cnt; i++) 116 118 seq_printf(seq, " %s", mptcp_snmp_list[i].name); 117 119 118 120 seq_puts(seq, "\nMPTcpExt:"); 119 121 120 122 memset(sum, 0, sizeof(sum)); 121 123 if (net->mib.mptcp_statistics) 122 - snmp_get_cpu_field_batch(sum, mptcp_snmp_list, 123 - net->mib.mptcp_statistics); 124 + snmp_get_cpu_field_batch_cnt(sum, mptcp_snmp_list, cnt, 125 + net->mib.mptcp_statistics); 124 126 125 - for (i = 0; mptcp_snmp_list[i].name; i++) 127 + for (i = 0; i < cnt; i++) 126 128 seq_printf(seq, " %lu", sum[i]); 127 129 128 130 seq_putc(seq, '\n');