netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] net: enable SO_REUSEPORT for AF_TIPC sockets
@ 2025-03-12 13:48 Nicolas Morey
  2025-03-12 16:35 ` Kuniyuki Iwashima
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Morey @ 2025-03-12 13:48 UTC (permalink / raw)
  To: netdev, Eric Dumazet

Commit 5b0af621c3f6 ("net: restrict SO_REUSEPORT to inet sockets") disabled
SO_REUSEPORT for all non inet sockets, including AF_TIPC sockets which broke
one of our customer applications.
Re-enable SO_REUSEPORT for AF_TIPC to restore the original behaviour.

Fixes: 5b0af621c3f6 ("net: restrict SO_REUSEPORT to inet sockets")
Signed-off-by: Nicolas Morey <nmorey@suse.com>
---
 include/net/sock.h | 5 +++++
 net/core/sock.c    | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index 7ef728324e4e..d14f6ffedcd5 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2755,6 +2755,11 @@ static inline bool sk_is_vsock(const struct sock *sk)
 	return sk->sk_family == AF_VSOCK;
 }
 
+static inline bool sk_is_tipc(const struct sock *sk)
+{
+	return sk->sk_family == AF_TIPC;
+}
+
 /**
  * sk_eat_skb - Release a skb if it is no longer needed
  * @sk: socket to eat this skb from
diff --git a/net/core/sock.c b/net/core/sock.c
index 6c0e87f97fa4..d4ad4cdff997 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1300,7 +1300,7 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
 		sk->sk_reuse = (valbool ? SK_CAN_REUSE : SK_NO_REUSE);
 		break;
 	case SO_REUSEPORT:
-		if (valbool && !sk_is_inet(sk))
+		if (valbool && !sk_is_inet(sk) && !sk_is_tipc(sk))
 			ret = -EOPNOTSUPP;
 		else
 			sk->sk_reuseport = valbool;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] net: enable SO_REUSEPORT for AF_TIPC sockets
  2025-03-12 13:48 [RFC PATCH] net: enable SO_REUSEPORT for AF_TIPC sockets Nicolas Morey
@ 2025-03-12 16:35 ` Kuniyuki Iwashima
  2025-03-12 17:44   ` Nicolas Morey
  0 siblings, 1 reply; 5+ messages in thread
From: Kuniyuki Iwashima @ 2025-03-12 16:35 UTC (permalink / raw)
  To: nicolas.morey; +Cc: edumazet, netdev, kuniyu

From: Nicolas Morey <nicolas.morey@suse.com>
Date: Wed, 12 Mar 2025 14:48:01 +0100
> Commit 5b0af621c3f6 ("net: restrict SO_REUSEPORT to inet sockets") disabled
> SO_REUSEPORT for all non inet sockets, including AF_TIPC sockets which broke
> one of our customer applications.
> Re-enable SO_REUSEPORT for AF_TIPC to restore the original behaviour.

AFAIU, AF_TIPC does not actually implement SO_REUSEPORT logic, no ?
If so, please tell your customer not to set it on AF_TIPC sockets.

There were similar reports about AF_VSOCK and AF_UNIX, and we told
that the userspace should not set SO_REUSEPORT for such sockets
that do not support the option.

https://lore.kernel.org/stable/CAGxU2F57EgVGbPifRuCvrUVjx06mrOXNdLcPdqhV9bdM0VqGvg@mail.gmail.com/
https://github.com/amazonlinux/amazon-linux-2023/issues/901


> 
> Fixes: 5b0af621c3f6 ("net: restrict SO_REUSEPORT to inet sockets")
> Signed-off-by: Nicolas Morey <nmorey@suse.com>
> ---
>  include/net/sock.h | 5 +++++
>  net/core/sock.c    | 2 +-
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/sock.h b/include/net/sock.h
> index 7ef728324e4e..d14f6ffedcd5 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2755,6 +2755,11 @@ static inline bool sk_is_vsock(const struct sock *sk)
>  	return sk->sk_family == AF_VSOCK;
>  }
>  
> +static inline bool sk_is_tipc(const struct sock *sk)
> +{
> +	return sk->sk_family == AF_TIPC;
> +}
> +
>  /**
>   * sk_eat_skb - Release a skb if it is no longer needed
>   * @sk: socket to eat this skb from
> diff --git a/net/core/sock.c b/net/core/sock.c
> index 6c0e87f97fa4..d4ad4cdff997 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -1300,7 +1300,7 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
>  		sk->sk_reuse = (valbool ? SK_CAN_REUSE : SK_NO_REUSE);
>  		break;
>  	case SO_REUSEPORT:
> -		if (valbool && !sk_is_inet(sk))
> +		if (valbool && !sk_is_inet(sk) && !sk_is_tipc(sk))
>  			ret = -EOPNOTSUPP;
>  		else
>  			sk->sk_reuseport = valbool;
> -- 
> 2.45.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] net: enable SO_REUSEPORT for AF_TIPC sockets
  2025-03-12 16:35 ` Kuniyuki Iwashima
@ 2025-03-12 17:44   ` Nicolas Morey
  2025-03-12 18:20     ` Kuniyuki Iwashima
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Morey @ 2025-03-12 17:44 UTC (permalink / raw)
  To: Kuniyuki Iwashima; +Cc: edumazet, netdev

On 2025-03-12 17:35, Kuniyuki Iwashima wrote:
> From: Nicolas Morey <nicolas.morey@suse.com>
> Date: Wed, 12 Mar 2025 14:48:01 +0100
>> Commit 5b0af621c3f6 ("net: restrict SO_REUSEPORT to inet sockets") disabled
>> SO_REUSEPORT for all non inet sockets, including AF_TIPC sockets which broke
>> one of our customer applications.
>> Re-enable SO_REUSEPORT for AF_TIPC to restore the original behaviour.
> 
> AFAIU, AF_TIPC does not actually implement SO_REUSEPORT logic, no ?
> If so, please tell your customer not to set it on AF_TIPC sockets.
> 
> There were similar reports about AF_VSOCK and AF_UNIX, and we told
> that the userspace should not set SO_REUSEPORT for such sockets
> that do not support the option.
> 
> https://lore.kernel.org/stable/CAGxU2F57EgVGbPifRuCvrUVjx06mrOXNdLcPdqhV9bdM0VqGvg@mail.gmail.com/
> https://github.com/amazonlinux/amazon-linux-2023/issues/901
> 
> 
Isn't the sk_reuseport inherited/used by the underlying UDP socket ?

Nicolas

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] net: enable SO_REUSEPORT for AF_TIPC sockets
  2025-03-12 17:44   ` Nicolas Morey
@ 2025-03-12 18:20     ` Kuniyuki Iwashima
  2025-03-12 19:45       ` Nicolas Morey
  0 siblings, 1 reply; 5+ messages in thread
From: Kuniyuki Iwashima @ 2025-03-12 18:20 UTC (permalink / raw)
  To: nicolas.morey; +Cc: edumazet, kuniyu, netdev

From: Nicolas Morey <nicolas.morey@suse.com>
Date: Wed, 12 Mar 2025 18:44:10 +0100
> On 2025-03-12 17:35, Kuniyuki Iwashima wrote:
> > From: Nicolas Morey <nicolas.morey@suse.com>
> > Date: Wed, 12 Mar 2025 14:48:01 +0100
> >> Commit 5b0af621c3f6 ("net: restrict SO_REUSEPORT to inet sockets") disabled
> >> SO_REUSEPORT for all non inet sockets, including AF_TIPC sockets which broke
> >> one of our customer applications.
> >> Re-enable SO_REUSEPORT for AF_TIPC to restore the original behaviour.
> > 
> > AFAIU, AF_TIPC does not actually implement SO_REUSEPORT logic, no ?
> > If so, please tell your customer not to set it on AF_TIPC sockets.
> > 
> > There were similar reports about AF_VSOCK and AF_UNIX, and we told
> > that the userspace should not set SO_REUSEPORT for such sockets
> > that do not support the option.
> > 
> > https://lore.kernel.org/stable/CAGxU2F57EgVGbPifRuCvrUVjx06mrOXNdLcPdqhV9bdM0VqGvg@mail.gmail.com/
> > https://github.com/amazonlinux/amazon-linux-2023/issues/901
> > 
> > 
> Isn't the sk_reuseport inherited/used by the underlying UDP socket ?

tipc_udp_enable() calls udp_sock_create() and udp_sock_create[46]()
creates a new UDP socket and bind()s without setting SO_REUSEPORT.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH] net: enable SO_REUSEPORT for AF_TIPC sockets
  2025-03-12 18:20     ` Kuniyuki Iwashima
@ 2025-03-12 19:45       ` Nicolas Morey
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Morey @ 2025-03-12 19:45 UTC (permalink / raw)
  To: Kuniyuki Iwashima; +Cc: edumazet, netdev

On 2025-03-12 19:20, Kuniyuki Iwashima wrote:
> From: Nicolas Morey <nicolas.morey@suse.com>
> Date: Wed, 12 Mar 2025 18:44:10 +0100
>> On 2025-03-12 17:35, Kuniyuki Iwashima wrote:
>>> From: Nicolas Morey <nicolas.morey@suse.com>
>>> Date: Wed, 12 Mar 2025 14:48:01 +0100
>>>> Commit 5b0af621c3f6 ("net: restrict SO_REUSEPORT to inet sockets") disabled
>>>> SO_REUSEPORT for all non inet sockets, including AF_TIPC sockets which broke
>>>> one of our customer applications.
>>>> Re-enable SO_REUSEPORT for AF_TIPC to restore the original behaviour.
>>>
>>> AFAIU, AF_TIPC does not actually implement SO_REUSEPORT logic, no ?
>>> If so, please tell your customer not to set it on AF_TIPC sockets.
>>>
>>> There were similar reports about AF_VSOCK and AF_UNIX, and we told
>>> that the userspace should not set SO_REUSEPORT for such sockets
>>> that do not support the option.
>>>
>>> https://lore.kernel.org/stable/CAGxU2F57EgVGbPifRuCvrUVjx06mrOXNdLcPdqhV9bdM0VqGvg@mail.gmail.com/
>>> https://github.com/amazonlinux/amazon-linux-2023/issues/901
>>>
>>>
>> Isn't the sk_reuseport inherited/used by the underlying UDP socket ?
> 
> tipc_udp_enable() calls udp_sock_create() and udp_sock_create[46]()
> creates a new UDP socket and bind()s without setting SO_REUSEPORT.

Thanks for the feedback. We'll advise to fix the userland code then.

Nicolas

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-03-12 19:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-12 13:48 [RFC PATCH] net: enable SO_REUSEPORT for AF_TIPC sockets Nicolas Morey
2025-03-12 16:35 ` Kuniyuki Iwashima
2025-03-12 17:44   ` Nicolas Morey
2025-03-12 18:20     ` Kuniyuki Iwashima
2025-03-12 19:45       ` Nicolas Morey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).