From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Stefano Brivio <sbrivio@redhat.com>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Eric Dumazet <edumazet@google.com>
Cc: netdev@vger.kernel.org,
Mike Manning <mmanning@vyatta.att-mail.com>,
David Gibson <david@gibson.dropbear.id.au>,
Ed Santiago <santiago@redhat.com>,
Paul Holzinger <pholzing@redhat.com>
Subject: Re: [PATCH RFC net 1/2] datagram: Rehash sockets only if local address changed for their family
Date: Fri, 15 Nov 2024 12:48:29 -0500 [thread overview]
Message-ID: <6737896d3b97b_3d5f2c29459@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <20241114215414.3357873-2-sbrivio@redhat.com>
Stefano Brivio wrote:
> It makes no sense to rehash an IPv4 socket when we change
> sk_v6_rcv_saddr, or to rehash an IPv6 socket as inet_rcv_saddr is set:
> the secondary hash (including the local address) won't change, because
> ipv4_portaddr_hash() and ipv6_portaddr_hash() only take the address
> matching the socket family.
Even if this is correct, it sounds like an optimization.
If so, it belongs in net-next.
Avoid making a fix (to net and eventually stable kernels) conditional
on optimizations that are not suitable for stable cherry-picks.
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> ---
> net/ipv4/datagram.c | 2 +-
> net/ipv6/datagram.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
> index cc6d0bd7b0a9..d52333e921f3 100644
> --- a/net/ipv4/datagram.c
> +++ b/net/ipv4/datagram.c
> @@ -65,7 +65,7 @@ int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
> inet->inet_saddr = fl4->saddr; /* Update source address */
> if (!inet->inet_rcv_saddr) {
> inet->inet_rcv_saddr = fl4->saddr;
> - if (sk->sk_prot->rehash)
> + if (sk->sk_prot->rehash && sk->sk_family == AF_INET)
> sk->sk_prot->rehash(sk);
When is sk_family != AF_INET in __ip4_datagram_connect?
> }
> inet->inet_daddr = fl4->daddr;
> diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
> index fff78496803d..5c28a11128c7 100644
> --- a/net/ipv6/datagram.c
> +++ b/net/ipv6/datagram.c
> @@ -211,7 +211,7 @@ int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr,
> ipv6_mapped_addr_any(&sk->sk_v6_rcv_saddr)) {
> ipv6_addr_set_v4mapped(inet->inet_rcv_saddr,
> &sk->sk_v6_rcv_saddr);
> - if (sk->sk_prot->rehash)
> + if (sk->sk_prot->rehash && sk->sk_family == AF_INET6)
> sk->sk_prot->rehash(sk);
Even if this is a v4mappedv6 address, sk_family will be AF_INET6.
next prev parent reply other threads:[~2024-11-15 17:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-14 21:54 [PATCH RFC net 0/2] Fix race between datagram socket address change and rehash Stefano Brivio
2024-11-14 21:54 ` [PATCH RFC net 1/2] datagram: Rehash sockets only if local address changed for their family Stefano Brivio
2024-11-15 17:48 ` Willem de Bruijn [this message]
2024-11-15 18:10 ` Stefano Brivio
2024-11-15 18:23 ` Stefano Brivio
2024-11-19 12:33 ` Stefano Brivio
2024-11-19 14:54 ` Willem de Bruijn
2024-11-14 21:54 ` [PATCH RFC net 2/2] datagram, udp: Set local address and rehash socket atomically against lookup Stefano Brivio
2024-11-15 17:50 ` Willem de Bruijn
2024-11-15 18:10 ` Stefano Brivio
2024-11-15 19:55 ` Kuniyuki Iwashima
2024-11-19 12:33 ` Stefano Brivio
2024-11-15 3:01 ` [PATCH RFC net 0/2] Fix race between datagram socket address change and rehash David Gibson
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=6737896d3b97b_3d5f2c29459@willemb.c.googlers.com.notmuch \
--to=willemdebruijn.kernel@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=edumazet@google.com \
--cc=mmanning@vyatta.att-mail.com \
--cc=netdev@vger.kernel.org \
--cc=pholzing@redhat.com \
--cc=santiago@redhat.com \
--cc=sbrivio@redhat.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