Commit ca79d80b authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski
Browse files

tcp: optimize inet_use_bhash2_on_bind()



There is no reason to call ipv6_addr_type().

Instead, use highly optimized ipv6_addr_any() and ipv6_addr_v4mapped().

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarJason Xing <kerneljasonxing@gmail.com>
Reviewed-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250302124237.3913746-3-edumazet@google.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent ae9d5b19
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -157,12 +157,10 @@ static bool inet_use_bhash2_on_bind(const struct sock *sk)
{
#if IS_ENABLED(CONFIG_IPV6)
	if (sk->sk_family == AF_INET6) {
		int addr_type = ipv6_addr_type(&sk->sk_v6_rcv_saddr);

		if (addr_type == IPV6_ADDR_ANY)
		if (ipv6_addr_any(&sk->sk_v6_rcv_saddr))
			return false;

		if (addr_type != IPV6_ADDR_MAPPED)
		if (!ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr))
			return true;
	}
#endif