Skip to content

Commit 0201eed

Browse files
edumazetkuba-moo
authored andcommitted
ipv6: icmp: remove obsolete code in icmpv6_xrlim_allow()
Following part was needed before the blamed commit, because inet_getpeer_v6() second argument was the prefix. /* Give more bandwidth to wider prefixes. */ if (rt->rt6i_dst.plen < 128) tmo >>= ((128 - rt->rt6i_dst.plen)>>5); Now inet_getpeer_v6() retrieves hosts, we need to remove @tmo adjustement or wider prefixes likes /24 allow 8x more ICMP to be sent for a given ratelimit. As we had this issue for a while, this patch changes net.ipv6.icmp.ratelimit default value from 1000ms to 100ms to avoid potential regressions. Also add a READ_ONCE() when reading net->ipv6.sysctl.icmpv6_time. Fixes: fd0273d ("ipv6: Remove external dependency on rt6i_dst and rt6i_src") Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Cc: Martin KaFai Lau <martin.lau@kernel.org> Link: https://patch.msgid.link/20260216142832.3834174-4-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 87b0891 commit 0201eed

3 files changed

Lines changed: 6 additions & 10 deletions

File tree

Documentation/networking/ip-sysctl.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3234,12 +3234,13 @@ enhanced_dad - BOOLEAN
32343234
===========
32353235

32363236
ratelimit - INTEGER
3237-
Limit the maximal rates for sending ICMPv6 messages.
3237+
Limit the maximal rates for sending ICMPv6 messages to a particular
3238+
peer.
32383239

32393240
0 to disable any limiting,
3240-
otherwise the minimal space between responses in milliseconds.
3241+
otherwise the space between responses in milliseconds.
32413242

3242-
Default: 1000
3243+
Default: 100
32433244

32443245
ratemask - list of comma separated ranges
32453246
For ICMPv6 message types matching the ranges in the ratemask, limit

net/ipv6/af_inet6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ static int __net_init inet6_net_init(struct net *net)
952952
int err = 0;
953953

954954
net->ipv6.sysctl.bindv6only = 0;
955-
net->ipv6.sysctl.icmpv6_time = 1*HZ;
955+
net->ipv6.sysctl.icmpv6_time = HZ / 10;
956956
net->ipv6.sysctl.icmpv6_echo_ignore_all = 0;
957957
net->ipv6.sysctl.icmpv6_echo_ignore_multicast = 0;
958958
net->ipv6.sysctl.icmpv6_echo_ignore_anycast = 0;

net/ipv6/icmp.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,9 @@ static bool icmpv6_xrlim_allow(struct sock *sk, u8 type,
217217
} else if (dev && (dev->flags & IFF_LOOPBACK)) {
218218
res = true;
219219
} else {
220-
struct rt6_info *rt = dst_rt6_info(dst);
221-
int tmo = net->ipv6.sysctl.icmpv6_time;
220+
int tmo = READ_ONCE(net->ipv6.sysctl.icmpv6_time);
222221
struct inet_peer *peer;
223222

224-
/* Give more bandwidth to wider prefixes. */
225-
if (rt->rt6i_dst.plen < 128)
226-
tmo >>= ((128 - rt->rt6i_dst.plen)>>5);
227-
228223
peer = inet_getpeer_v6(net->ipv6.peers, &fl6->daddr);
229224
res = inet_peer_xrlim_allow(peer, tmo);
230225
}

0 commit comments

Comments
 (0)