[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <68224974de7ed_e985e294b5@willemb.c.googlers.com.notmuch>
Date: Mon, 12 May 2025 15:18:12 -0400
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: Kuniyuki Iwashima <kuniyu@...zon.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Willem de Bruijn <willemb@...gle.com>
Cc: Simon Horman <horms@...nel.org>,
Christian Brauner <brauner@...nel.org>,
Kuniyuki Iwashima <kuniyu@...zon.com>,
Kuniyuki Iwashima <kuni1840@...il.com>,
netdev@...r.kernel.org
Subject: Re: [PATCH v2 net-next 4/9] tcp: Restrict SO_TXREHASH to TCP socket.
Kuniyuki Iwashima wrote:
> sk->sk_txrehash is only used for TCP.
>
> Let's restrict SO_TXREHASH to TCP to reflect this.
>
> Later, we will make sk_txrehash a part of the union for other
> protocol families, so we set 0 explicitly in getsockopt().
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@...zon.com>
> ---
> net/core/sock.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/sock.c b/net/core/sock.c
> index b64df2463300..5c84a608ddd7 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -1276,6 +1276,8 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
> return 0;
> }
> case SO_TXREHASH:
> + if (!sk_is_tcp(sk))
> + return -EOPNOTSUPP;
> if (val < -1 || val > 1)
> return -EINVAL;
> if ((u8)val == SOCK_TXREHASH_DEFAULT)
> @@ -2102,8 +2104,11 @@ int sk_getsockopt(struct sock *sk, int level, int optname,
> break;
>
> case SO_TXREHASH:
> - /* Paired with WRITE_ONCE() in sk_setsockopt() */
> - v.val = READ_ONCE(sk->sk_txrehash);
> + if (sk_is_tcp(sk))
> + /* Paired with WRITE_ONCE() in sk_setsockopt() */
> + v.val = READ_ONCE(sk->sk_txrehash);
> + else
> + v.val = 0;
Here and in the following getsockopt calls: should the call fail with
EOPNOTSUPP rather than return a value that is legal where the option
is supported (in TCP).
Powered by blists - more mailing lists