summaryrefslogtreecommitdiff
path: root/net/core/sock.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2023-09-21 23:28:16 +0300
committerDavid S. Miller <davem@davemloft.net>2023-10-01 21:09:54 +0300
commit5eef0b8de1be40c5d05873b7e3d63824300c9f39 (patch)
tree1dc4786807f52ef44c11381914fa570ef297a2ed /net/core/sock.c
parent28b24f90020fed8e8e3e8e20575f08c1cd06e54f (diff)
downloadlinux-5eef0b8de1be40c5d05873b7e3d63824300c9f39.tar.xz
net: lockless implementation of SO_TXREHASH
sk->sk_txrehash readers are already safe against concurrent change of this field. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/sock.c')
-rw-r--r--net/core/sock.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index 4254ed0e4817..f0930f858714 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1181,6 +1181,16 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
WRITE_ONCE(sk->sk_pacing_rate, ulval);
return 0;
}
+ case SO_TXREHASH:
+ if (val < -1 || val > 1)
+ return -EINVAL;
+ if ((u8)val == SOCK_TXREHASH_DEFAULT)
+ val = READ_ONCE(sock_net(sk)->core.sysctl_txrehash);
+ /* Paired with READ_ONCE() in tcp_rtx_synack()
+ * and sk_getsockopt().
+ */
+ WRITE_ONCE(sk->sk_txrehash, (u8)val);
+ return 0;
}
sockopt_lock_sock(sk);
@@ -1528,19 +1538,6 @@ set_sndbuf:
break;
}
- case SO_TXREHASH:
- if (val < -1 || val > 1) {
- ret = -EINVAL;
- break;
- }
- if ((u8)val == SOCK_TXREHASH_DEFAULT)
- val = READ_ONCE(sock_net(sk)->core.sysctl_txrehash);
- /* Paired with READ_ONCE() in tcp_rtx_synack()
- * and sk_getsockopt().
- */
- WRITE_ONCE(sk->sk_txrehash, (u8)val);
- break;
-
default:
ret = -ENOPROTOOPT;
break;