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

Configure Feed

Select the types of activity you want to include in your feed.

ipv6: snmp: remove icmp6type2name[]

This 2KB array can be replaced by a switch() to save space.

Before:
$ size net/ipv6/proc.o
text data bss dec hex filename
6410 624 0 7034 1b7a net/ipv6/proc.o

After:
$ size net/ipv6/proc.o
text data bss dec hex filename
5516 592 0 6108 17dc net/ipv6/proc.o

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Link: https://patch.msgid.link/20250905165813.1470708-2-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
b7fe8c1b abcf9f66

+22 -22
+22 -22
net/ipv6/proc.c
··· 99 99 SNMP_MIB_SENTINEL 100 100 }; 101 101 102 - /* RFC 4293 v6 ICMPMsgStatsTable; named items for RFC 2466 compatibility */ 103 - static const char *const icmp6type2name[256] = { 104 - [ICMPV6_DEST_UNREACH] = "DestUnreachs", 105 - [ICMPV6_PKT_TOOBIG] = "PktTooBigs", 106 - [ICMPV6_TIME_EXCEED] = "TimeExcds", 107 - [ICMPV6_PARAMPROB] = "ParmProblems", 108 - [ICMPV6_ECHO_REQUEST] = "Echos", 109 - [ICMPV6_ECHO_REPLY] = "EchoReplies", 110 - [ICMPV6_MGM_QUERY] = "GroupMembQueries", 111 - [ICMPV6_MGM_REPORT] = "GroupMembResponses", 112 - [ICMPV6_MGM_REDUCTION] = "GroupMembReductions", 113 - [ICMPV6_MLD2_REPORT] = "MLDv2Reports", 114 - [NDISC_ROUTER_ADVERTISEMENT] = "RouterAdvertisements", 115 - [NDISC_ROUTER_SOLICITATION] = "RouterSolicits", 116 - [NDISC_NEIGHBOUR_ADVERTISEMENT] = "NeighborAdvertisements", 117 - [NDISC_NEIGHBOUR_SOLICITATION] = "NeighborSolicits", 118 - [NDISC_REDIRECT] = "Redirects", 119 - }; 120 - 121 - 122 102 static const struct snmp_mib snmp6_udp6_list[] = { 123 103 SNMP_MIB_ITEM("Udp6InDatagrams", UDP_MIB_INDATAGRAMS), 124 104 SNMP_MIB_ITEM("Udp6NoPorts", UDP_MIB_NOPORTS), ··· 131 151 132 152 /* print by name -- deprecated items */ 133 153 for (i = 0; i < ICMP6MSG_MIB_MAX; i++) { 154 + const char *p = NULL; 134 155 int icmptype; 135 - const char *p; 156 + 157 + #define CASE(TYP, STR) case TYP: p = STR; break; 136 158 137 159 icmptype = i & 0xff; 138 - p = icmp6type2name[icmptype]; 160 + switch (icmptype) { 161 + /* RFC 4293 v6 ICMPMsgStatsTable; named items for RFC 2466 compatibility */ 162 + CASE(ICMPV6_DEST_UNREACH, "DestUnreachs") 163 + CASE(ICMPV6_PKT_TOOBIG, "PktTooBigs") 164 + CASE(ICMPV6_TIME_EXCEED, "TimeExcds") 165 + CASE(ICMPV6_PARAMPROB, "ParmProblems") 166 + CASE(ICMPV6_ECHO_REQUEST, "Echos") 167 + CASE(ICMPV6_ECHO_REPLY, "EchoReplies") 168 + CASE(ICMPV6_MGM_QUERY, "GroupMembQueries") 169 + CASE(ICMPV6_MGM_REPORT, "GroupMembResponses") 170 + CASE(ICMPV6_MGM_REDUCTION, "GroupMembReductions") 171 + CASE(ICMPV6_MLD2_REPORT, "MLDv2Reports") 172 + CASE(NDISC_ROUTER_ADVERTISEMENT, "RouterAdvertisements") 173 + CASE(NDISC_ROUTER_SOLICITATION, "RouterSolicits") 174 + CASE(NDISC_NEIGHBOUR_ADVERTISEMENT, "NeighborAdvertisements") 175 + CASE(NDISC_NEIGHBOUR_SOLICITATION, "NeighborSolicits") 176 + CASE(NDISC_REDIRECT, "Redirects") 177 + } 178 + #undef CASE 139 179 if (!p) /* don't print un-named types here */ 140 180 continue; 141 181 snprintf(name, sizeof(name), "Icmp6%s%s",