public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
	Willem de Bruijn <willemb@google.com>,
	 Kuniyuki Iwashima <kuniyu@google.com>,
	David Ahern <dsahern@kernel.org>,
	 Martin KaFai Lau <martin.lau@kernel.org>,
	netdev@vger.kernel.org, eric.dumazet@gmail.com,
	 Eric Dumazet <edumazet@google.com>
Subject: [PATCH net 5/5] ipv6: icmp: icmpv6_xrlim_allow() optimization if net.ipv4.icmp_ratelimit is zero
Date: Sun, 15 Feb 2026 14:38:21 +0000	[thread overview]
Message-ID: <20260215143821.2330791-6-edumazet@google.com> (raw)
In-Reply-To: <20260215143821.2330791-1-edumazet@google.com>

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>
---
 net/ipv6/icmp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 0f41ca6f3d83e86ce97ce5a30613f58f4dc22dad..813d2e9edb8bed7c1649e279cea9229806af4132 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -220,8 +220,12 @@ static bool icmpv6_xrlim_allow(struct sock *sk, u8 type,
 		int tmo = READ_ONCE(net->ipv6.sysctl.icmpv6_time);
 		struct inet_peer *peer;
 
-		peer = inet_getpeer_v6(net->ipv6.peers, &fl6->daddr);
-		res = inet_peer_xrlim_allow(peer, tmo);
+		if (!tmo) {
+			res = true;
+		} else {
+			peer = inet_getpeer_v6(net->ipv6.peers, &fl6->daddr);
+			res = inet_peer_xrlim_allow(peer, tmo);
+		}
 	}
 	rcu_read_unlock();
 	if (!res)
-- 
2.53.0.310.g728cabbaf7-goog


  parent reply	other threads:[~2026-02-15 14:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-15 14:38 [PATCH net 0/5] icmp: better deal with DDOS Eric Dumazet
2026-02-15 14:38 ` [PATCH net 1/5] icmp: prevent possible overflow in icmp_global_allow() Eric Dumazet
2026-02-16  0:42   ` Kuniyuki Iwashima
2026-02-15 14:38 ` [PATCH net 2/5] inet: move icmp_global_{credit,stamp} to a separate cache line Eric Dumazet
2026-02-16  0:42   ` Kuniyuki Iwashima
2026-02-15 14:38 ` [PATCH net 3/5] ipv6: icmp: remove obsolete code in icmpv6_xrlim_allow() Eric Dumazet
2026-02-16  0:58   ` Kuniyuki Iwashima
2026-02-15 14:38 ` [PATCH net 4/5] ipv4: icmp: icmpv4_xrlim_allow() optimization if net.ipv4.icmp_ratelimit is zero Eric Dumazet
2026-02-16  1:00   ` Kuniyuki Iwashima
2026-02-15 14:38 ` Eric Dumazet [this message]
2026-02-16  1:01   ` [PATCH net 5/5] ipv6: icmp: icmpv6_xrlim_allow() " Kuniyuki Iwashima
2026-02-16  5:01     ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260215143821.2330791-6-edumazet@google.com \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=eric.dumazet@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=martin.lau@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox