Skip to content

Commit 4e9ce29

Browse files
edumazetgregkh
authored andcommitted
ipv6: snmp: do not track per idev ICMP6_MIB_RATELIMITHOST
[ Upstream commit 2fab94b ] Blamed commit added a critical false sharing on a single atomic_long_t under DOS, like receiving UDP packets to closed ports. Per netns ICMP6_MIB_RATELIMITHOST tracking uses per-cpu storage and is enough, we do not need per-device and slow tracking. Fixes: d094113 ("icmp: Add counters for rate limits") Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Jamie Bainbridge <jamie.bainbridge@gmail.com> Cc: Abhishek Rawal <rawal.abhishek92@gmail.com> Link: https://patch.msgid.link/20250905165813.1470708-4-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b629547 commit 4e9ce29

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

net/ipv6/icmp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ static bool icmpv6_xrlim_allow(struct sock *sk, u8 type,
230230
}
231231
rcu_read_unlock();
232232
if (!res)
233-
__ICMP6_INC_STATS(net, ip6_dst_idev(dst),
234-
ICMP6_MIB_RATELIMITHOST);
233+
__ICMP6_INC_STATS(net, NULL, ICMP6_MIB_RATELIMITHOST);
235234
else
236235
icmp_global_consume(net);
237236
dst_release(dst);

net/ipv6/proc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static const struct snmp_mib snmp6_icmp6_list[] = {
9494
SNMP_MIB_ITEM("Icmp6OutMsgs", ICMP6_MIB_OUTMSGS),
9595
SNMP_MIB_ITEM("Icmp6OutErrors", ICMP6_MIB_OUTERRORS),
9696
SNMP_MIB_ITEM("Icmp6InCsumErrors", ICMP6_MIB_CSUMERRORS),
97+
/* ICMP6_MIB_RATELIMITHOST needs to be last, see snmp6_dev_seq_show(). */
9798
SNMP_MIB_ITEM("Icmp6OutRateLimitHost", ICMP6_MIB_RATELIMITHOST),
9899
};
99100

@@ -242,8 +243,11 @@ static int snmp6_dev_seq_show(struct seq_file *seq, void *v)
242243
snmp6_ipstats_list,
243244
ARRAY_SIZE(snmp6_ipstats_list),
244245
offsetof(struct ipstats_mib, syncp));
246+
247+
/* Per idev icmp stats do not have ICMP6_MIB_RATELIMITHOST */
245248
snmp6_seq_show_item(seq, NULL, idev->stats.icmpv6dev->mibs,
246-
snmp6_icmp6_list, ARRAY_SIZE(snmp6_icmp6_list));
249+
snmp6_icmp6_list, ARRAY_SIZE(snmp6_icmp6_list) - 1);
250+
247251
snmp6_seq_show_icmpv6msg(seq, idev->stats.icmpv6msgdev->mibs);
248252
return 0;
249253
}

0 commit comments

Comments
 (0)