Commit 5eef0b8d authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: lockless implementation of SO_TXREHASH

sk->sk_txrehash readers are already safe against
concurrent change of this field.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 28b24f90
...@@ -1181,6 +1181,16 @@ int sk_setsockopt(struct sock *sk, int level, int optname, ...@@ -1181,6 +1181,16 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
WRITE_ONCE(sk->sk_pacing_rate, ulval); WRITE_ONCE(sk->sk_pacing_rate, ulval);
return 0; 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); sockopt_lock_sock(sk);
...@@ -1528,19 +1538,6 @@ int sk_setsockopt(struct sock *sk, int level, int optname, ...@@ -1528,19 +1538,6 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
break; 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: default:
ret = -ENOPROTOOPT; ret = -ENOPROTOOPT;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment