Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v1 0/2] ipv6: make IPV6_FREEBIND and IPV6_TRANSPARENT lockless
@ 2026-09-11 10:24 Xuanqiang Luo
  2026-09-11 10:24 ` [PATCH net-next v1 1/2] ipv6: make IPV6_FREEBIND setsockopt lockless Xuanqiang Luo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Xuanqiang Luo @ 2026-09-11 10:24 UTC (permalink / raw)
  To: netdev
  Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, horms,
	linux-kernel, Xuanqiang Luo

From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>

Move both IPv6 setters to the lockless setsockopt path.

Patch 1 handles IPV6_FREEBIND.

Patch 2 handles IPV6_TRANSPARENT.

Xuanqiang Luo (2):
  ipv6: make IPV6_FREEBIND setsockopt lockless
  ipv6: make IPV6_TRANSPARENT setsockopt lockless

 net/ipv6/ipv6_sockglue.c | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)


base-commit: 348ea4642f56ab3dc93621c8e3ab0ccd0e5f1782
-- 
2.43.0


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

* [PATCH net-next v1 1/2] ipv6: make IPV6_FREEBIND setsockopt lockless
  2026-09-11 10:24 [PATCH net-next v1 0/2] ipv6: make IPV6_FREEBIND and IPV6_TRANSPARENT lockless Xuanqiang Luo
@ 2026-09-11 10:24 ` Xuanqiang Luo
  2026-09-11 10:24 ` [PATCH net-next v1 2/2] ipv6: make IPV6_TRANSPARENT " Xuanqiang Luo
  2026-09-11 11:36 ` [PATCH net-next v1 0/2] ipv6: make IPV6_FREEBIND and IPV6_TRANSPARENT lockless Eric Dumazet
  2 siblings, 0 replies; 4+ messages in thread
From: Xuanqiang Luo @ 2026-09-11 10:24 UTC (permalink / raw)
  To: netdev
  Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, horms,
	linux-kernel, Xuanqiang Luo

From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>

IPV6_FREEBIND still takes the socket lock despite using
inet_assign_bit() to update the flag shared with IP_FREEBIND.
IPv6 TCP and UDP sockets can already update this flag without the
lock through SOL_IP/IP_FREEBIND.

Move IPV6_FREEBIND to the lockless setsockopt path.

Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
---
 net/ipv6/ipv6_sockglue.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 1f68fb64a43ef..4124084c3cd79 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -398,6 +398,12 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 
 	/* Handle options that can be set without locking the socket. */
 	switch (optname) {
+	case IPV6_FREEBIND:
+		if (optlen < sizeof(int))
+			return -EINVAL;
+		/* Shared with IP_FREEBIND. */
+		inet_assign_bit(FREEBIND, sk, valbool);
+		return 0;
 	case IPV6_UNICAST_HOPS:
 		if (optlen < sizeof(int))
 			return -EINVAL;
@@ -679,14 +685,6 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 		retv = 0;
 		break;
 
-	case IPV6_FREEBIND:
-		if (optlen < sizeof(int))
-			goto e_inval;
-		/* we also don't have a separate freebind bit for IPV6 */
-		inet_assign_bit(FREEBIND, sk, valbool);
-		retv = 0;
-		break;
-
 	case IPV6_RECVORIGDSTADDR:
 		if (optlen < sizeof(int))
 			goto e_inval;
-- 
2.43.0


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

* [PATCH net-next v1 2/2] ipv6: make IPV6_TRANSPARENT setsockopt lockless
  2026-09-11 10:24 [PATCH net-next v1 0/2] ipv6: make IPV6_FREEBIND and IPV6_TRANSPARENT lockless Xuanqiang Luo
  2026-09-11 10:24 ` [PATCH net-next v1 1/2] ipv6: make IPV6_FREEBIND setsockopt lockless Xuanqiang Luo
@ 2026-09-11 10:24 ` Xuanqiang Luo
  2026-09-11 11:36 ` [PATCH net-next v1 0/2] ipv6: make IPV6_FREEBIND and IPV6_TRANSPARENT lockless Eric Dumazet
  2 siblings, 0 replies; 4+ messages in thread
From: Xuanqiang Luo @ 2026-09-11 10:24 UTC (permalink / raw)
  To: netdev
  Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, horms,
	linux-kernel, Xuanqiang Luo

From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>

IPV6_TRANSPARENT still takes the socket lock despite using
inet_assign_bit() to update the flag shared with IP_TRANSPARENT.
IPv6 TCP and UDP sockets can already update this flag without the
lock through SOL_IP/IP_TRANSPARENT.

Move IPV6_TRANSPARENT to the lockless setsockopt path.

Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
---
 net/ipv6/ipv6_sockglue.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 4124084c3cd79..4b3536571c980 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -404,6 +404,15 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 		/* Shared with IP_FREEBIND. */
 		inet_assign_bit(FREEBIND, sk, valbool);
 		return 0;
+	case IPV6_TRANSPARENT:
+		if (valbool && !sockopt_ns_capable(net->user_ns, CAP_NET_RAW) &&
+		    !sockopt_ns_capable(net->user_ns, CAP_NET_ADMIN))
+			return -EPERM;
+		if (optlen < sizeof(int))
+			return -EINVAL;
+		/* Shared with IP_TRANSPARENT. */
+		inet_assign_bit(TRANSPARENT, sk, valbool);
+		return 0;
 	case IPV6_UNICAST_HOPS:
 		if (optlen < sizeof(int))
 			return -EINVAL;
@@ -672,19 +681,6 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 		retv = 0;
 		break;
 
-	case IPV6_TRANSPARENT:
-		if (valbool && !sockopt_ns_capable(net->user_ns, CAP_NET_RAW) &&
-		    !sockopt_ns_capable(net->user_ns, CAP_NET_ADMIN)) {
-			retv = -EPERM;
-			break;
-		}
-		if (optlen < sizeof(int))
-			goto e_inval;
-		/* we don't have a separate transparent bit for IPV6 we use the one in the IPv4 socket */
-		inet_assign_bit(TRANSPARENT, sk, valbool);
-		retv = 0;
-		break;
-
 	case IPV6_RECVORIGDSTADDR:
 		if (optlen < sizeof(int))
 			goto e_inval;
-- 
2.43.0


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

* Re: [PATCH net-next v1 0/2] ipv6: make IPV6_FREEBIND and IPV6_TRANSPARENT lockless
  2026-09-11 10:24 [PATCH net-next v1 0/2] ipv6: make IPV6_FREEBIND and IPV6_TRANSPARENT lockless Xuanqiang Luo
  2026-09-11 10:24 ` [PATCH net-next v1 1/2] ipv6: make IPV6_FREEBIND setsockopt lockless Xuanqiang Luo
  2026-09-11 10:24 ` [PATCH net-next v1 2/2] ipv6: make IPV6_TRANSPARENT " Xuanqiang Luo
@ 2026-09-11 11:36 ` Eric Dumazet
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-09-11 11:36 UTC (permalink / raw)
  To: Xuanqiang Luo
  Cc: netdev, dsahern, idosch, davem, kuba, pabeni, horms, linux-kernel,
	Xuanqiang Luo

On Fri, Sep 11, 2026 at 3:24 AM Xuanqiang Luo <xuanqiang.luo@linux.dev> wrote:
>
> From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
>
> Move both IPv6 setters to the lockless setsockopt path.
>
> Patch 1 handles IPV6_FREEBIND.
>
> Patch 2 handles IPV6_TRANSPARENT.
>

The changes are fine, they simply align IPv6 with what IP_FREEBIND and
IP_TRANSPARENT have been doing in ip_sockglue.c already.

However, both patches touch the same switch() in the same function and
do exactly the same thing. Please squash them into a single patch in
v2, no cover letter needed then.

Thanks!

pw-bot: cr

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

end of thread, other threads:[~2026-09-11 11:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-11 10:24 [PATCH net-next v1 0/2] ipv6: make IPV6_FREEBIND and IPV6_TRANSPARENT lockless Xuanqiang Luo
2026-09-11 10:24 ` [PATCH net-next v1 1/2] ipv6: make IPV6_FREEBIND setsockopt lockless Xuanqiang Luo
2026-09-11 10:24 ` [PATCH net-next v1 2/2] ipv6: make IPV6_TRANSPARENT " Xuanqiang Luo
2026-09-11 11:36 ` [PATCH net-next v1 0/2] ipv6: make IPV6_FREEBIND and IPV6_TRANSPARENT lockless Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox