Skip to content

Commit 9395b1b

Browse files
edumazetkuba-moo
authored andcommitted
ipv6: icmp: icmpv6_xrlim_allow() optimization if net.ipv6.icmp.ratelimit is zero
If net.ipv6.icmp.ratelimit is zero we do not have to call inet_getpeer_v6() and inet_peer_xrlim_allow(). Both can be very expensive under DDOS. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260216142832.3834174-6-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d8d9ef2 commit 9395b1b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

net/ipv6/icmp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,12 @@ static bool icmpv6_xrlim_allow(struct sock *sk, u8 type,
220220
int tmo = READ_ONCE(net->ipv6.sysctl.icmpv6_time);
221221
struct inet_peer *peer;
222222

223-
peer = inet_getpeer_v6(net->ipv6.peers, &fl6->daddr);
224-
res = inet_peer_xrlim_allow(peer, tmo);
223+
if (!tmo) {
224+
res = true;
225+
} else {
226+
peer = inet_getpeer_v6(net->ipv6.peers, &fl6->daddr);
227+
res = inet_peer_xrlim_allow(peer, tmo);
228+
}
225229
}
226230
rcu_read_unlock();
227231
if (!res)

0 commit comments

Comments
 (0)