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

sctp: 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: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://patch.msgid.link/20250905165813.1470708-7-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
52a33cae 35cb2da0

+6 -6
+6 -6
net/sctp/proc.c
··· 52 52 SNMP_MIB_ITEM("SctpInPktBacklog", SCTP_MIB_IN_PKT_BACKLOG), 53 53 SNMP_MIB_ITEM("SctpInPktDiscards", SCTP_MIB_IN_PKT_DISCARDS), 54 54 SNMP_MIB_ITEM("SctpInDataChunkDiscards", SCTP_MIB_IN_DATA_CHUNK_DISCARDS), 55 - SNMP_MIB_SENTINEL 56 55 }; 57 56 58 57 /* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */ 59 58 static int sctp_snmp_seq_show(struct seq_file *seq, void *v) 60 59 { 61 - unsigned long buff[SCTP_MIB_MAX]; 60 + unsigned long buff[ARRAY_SIZE(sctp_snmp_list)]; 61 + const int cnt = ARRAY_SIZE(sctp_snmp_list); 62 62 struct net *net = seq->private; 63 63 int i; 64 64 65 - memset(buff, 0, sizeof(unsigned long) * SCTP_MIB_MAX); 65 + memset(buff, 0, sizeof(buff)); 66 66 67 - snmp_get_cpu_field_batch(buff, sctp_snmp_list, 68 - net->sctp.sctp_statistics); 69 - for (i = 0; sctp_snmp_list[i].name; i++) 67 + snmp_get_cpu_field_batch_cnt(buff, sctp_snmp_list, cnt, 68 + net->sctp.sctp_statistics); 69 + for (i = 0; i < cnt; i++) 70 70 seq_printf(seq, "%-32s\t%ld\n", sctp_snmp_list[i].name, 71 71 buff[i]); 72 72