Skip to content

Commit 63b530d

Browse files
edumazetopsiff
authored andcommitted
tcp: optimize inet_use_bhash2_on_bind()
mainline inclusion from mainline-v6.15-rc1 category: performance There is no reason to call ipv6_addr_type(). Instead, use highly optimized ipv6_addr_any() and ipv6_addr_v4mapped(). Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Jason Xing <kerneljasonxing@gmail.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/20250302124237.3913746-3-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit ca79d80) Signed-off-by: Wentao Guan <guanwentao@uniontech.com> Change-Id: Ic23033aad4ec462fbb470cf859952ae341a21b81
1 parent b508429 commit 63b530d

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

net/ipv4/inet_connection_sock.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,10 @@ static bool inet_use_bhash2_on_bind(const struct sock *sk)
155155
{
156156
#if IS_ENABLED(CONFIG_IPV6)
157157
if (sk->sk_family == AF_INET6) {
158-
int addr_type = ipv6_addr_type(&sk->sk_v6_rcv_saddr);
159-
160-
if (addr_type == IPV6_ADDR_ANY)
158+
if (ipv6_addr_any(&sk->sk_v6_rcv_saddr))
161159
return false;
162160

163-
if (addr_type != IPV6_ADDR_MAPPED)
161+
if (!ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr))
164162
return true;
165163
}
166164
#endif

0 commit comments

Comments
 (0)