net: enable SO_REUSEPORT for AF_TIPC sockets
Subsystems (3)
RFC PATCH 1/1 net: enable SO_REUSEPORT for AF_TIPC sockets
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.
--- include/net/sock.h | 5 +++++ net/core/sock.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
include/net/sock.h +5 -0
@@ -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
net/core/sock.c +1 -1
@@ -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;
Signature · 1 line
2.45.2
From: Nicolas Morey <[email protected]>
Date: Wed, 12 Mar 2025 14:48:01 +0100
Quoted 4 lines
Commit
5b0af621c3f6("net: restrictSO_REUSEPORTto inet sockets") disabledSO_REUSEPORTfor all non inet sockets, includingAF_TIPCsockets which broke one of our customer applications.
Re-enableSO_REUSEPORTforAF_TIPCto 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
Quoted 39 lines
Fixes 5b0af621c3f6 ("net: restrict SO_REUSEPORT to inet sockets")Signed-off-by Nicolas Morey <[email protected]>--- include/net/sock.h | 5 +++++ net/core/sock.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)include/net/sock.h +5
-0@@ -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 net/core/sock.c +1
-1@@ -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;Signature · 1 line
2.45.2
Quoted 10 lines · Kuniyuki Iwashima
From: Nicolas Morey <[email protected]>
Date: Wed, 12 Mar 2025 14:48:01 +0100Quoted 4 lines
Commit
5b0af621c3f6("net: restrictSO_REUSEPORTto inet sockets") disabledSO_REUSEPORTfor all non inet sockets, includingAF_TIPCsockets which broke one of our customer applications.
Re-enableSO_REUSEPORTforAF_TIPCto restore the original behaviour.AFAIU,
AF_TIPCdoes not actually implementSO_REUSEPORTlogic, no ? If so, please tell your customer not to set it onAF_TIPCsockets.
Quoted 8 lines
There were similar reports about
AF_VSOCKandAF_UNIX, and we told that the userspace should not setSO_REUSEPORTfor 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
From: Nicolas Morey <[email protected]>
Date: Wed, 12 Mar 2025 18:44:10 +0100
Quoted 15 lines · Kuniyuki Iwashima
Quoted 14 lines
From: Nicolas Morey <[email protected]>
Date: Wed, 12 Mar 2025 14:48:01 +0100Quoted 4 lines
Commit
5b0af621c3f6("net: restrictSO_REUSEPORTto inet sockets") disabledSO_REUSEPORTfor all non inet sockets, includingAF_TIPCsockets which broke one of our customer applications.
Re-enableSO_REUSEPORTforAF_TIPCto restore the original behaviour.AFAIU,
AF_TIPCdoes not actually implementSO_REUSEPORTlogic, no ? If so, please tell your customer not to set it onAF_TIPCsockets.There were similar reports about
AF_VSOCKandAF_UNIX, and we told that the userspace should not setSO_REUSEPORTfor such sockets that do not support the option.
Quoted 5 lines
Quoted 4 lines
https://lore.kernel.org/stable/CAGxU2F57EgVGbPifRuCvrUVjx06mrOXNdLcPdqhV9bdM0VqGvg@mail.gmail.com/
https://github.com/amazonlinux/amazon-linux-2023/issues/901Isn't the
sk_reuseportinherited/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.
Quoted 17 lines · Kuniyuki Iwashima
From: Nicolas Morey <[email protected]>
Date: Wed, 12 Mar 2025 18:44:10 +0100Quoted 15 lines · Kuniyuki Iwashima
Quoted 14 lines
From: Nicolas Morey <[email protected]>
Date: Wed, 12 Mar 2025 14:48:01 +0100Quoted 4 lines
Commit
5b0af621c3f6("net: restrictSO_REUSEPORTto inet sockets") disabledSO_REUSEPORTfor all non inet sockets, includingAF_TIPCsockets which broke one of our customer applications.
Re-enableSO_REUSEPORTforAF_TIPCto restore the original behaviour.AFAIU,
AF_TIPCdoes not actually implementSO_REUSEPORTlogic, no ? If so, please tell your customer not to set it onAF_TIPCsockets.There were similar reports about
AF_VSOCKandAF_UNIX, and we told that the userspace should not setSO_REUSEPORTfor such sockets that do not support the option.
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
https://lore.kernel.org/stable/CAGxU2F57EgVGbPifRuCvrUVjx06mrOXNdLcPdqhV9bdM0VqGvg@mail.gmail.com/
https://github.com/amazonlinux/amazon-linux-2023/issues/901Isn't the
sk_reuseportinherited/used by the underlying UDP socket ?
tipc_udp_enable()callsudp_sock_create()and udp_sock_create[46]() creates a new UDP socket and bind()s without settingSO_REUSEPORT.
Thanks for the feedback. We'll advise to fix the userland code then.
Nicolas