Skip to content

Commit dd759bb

Browse files
Wen GuSasha Levin
authored andcommitted
net/smc: avoid overwriting when adjusting sock bufsizes
[ Upstream commit fb0aa07 ] When copying smc settings to clcsock, avoid setting clcsock's sk_sndbuf to sysctl_tcp_wmem[1], since this may overwrite the value set by tcp_sndbuf_expand() in TCP connection establishment. And the other setting sk_{snd|rcv}buf to sysctl value in smc_adjust_sock_bufsizes() can also be omitted since the initialization of smc sock and clcsock has set sk_{snd|rcv}buf to smc.sysctl_{w|r}mem or ipv4_sysctl_tcp_{w|r}mem[1]. Fixes: 30c3c4a ("net/smc: Use correct buffer sizes when switching between TCP and SMC") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wen Gu <[email protected]> Reviewed-by: Wenjia Zhang <[email protected]> Reviewed-by: Gerd Bayer <[email protected]>, too. Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent df42c7c commit dd759bb

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

net/smc/af_smc.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -462,29 +462,11 @@ static int smc_bind(struct socket *sock, struct sockaddr *uaddr,
462462
static void smc_adjust_sock_bufsizes(struct sock *nsk, struct sock *osk,
463463
unsigned long mask)
464464
{
465-
struct net *nnet = sock_net(nsk);
466-
467465
nsk->sk_userlocks = osk->sk_userlocks;
468-
if (osk->sk_userlocks & SOCK_SNDBUF_LOCK) {
466+
if (osk->sk_userlocks & SOCK_SNDBUF_LOCK)
469467
nsk->sk_sndbuf = osk->sk_sndbuf;
470-
} else {
471-
if (mask == SK_FLAGS_SMC_TO_CLC)
472-
WRITE_ONCE(nsk->sk_sndbuf,
473-
READ_ONCE(nnet->ipv4.sysctl_tcp_wmem[1]));
474-
else
475-
WRITE_ONCE(nsk->sk_sndbuf,
476-
2 * READ_ONCE(nnet->smc.sysctl_wmem));
477-
}
478-
if (osk->sk_userlocks & SOCK_RCVBUF_LOCK) {
468+
if (osk->sk_userlocks & SOCK_RCVBUF_LOCK)
479469
nsk->sk_rcvbuf = osk->sk_rcvbuf;
480-
} else {
481-
if (mask == SK_FLAGS_SMC_TO_CLC)
482-
WRITE_ONCE(nsk->sk_rcvbuf,
483-
READ_ONCE(nnet->ipv4.sysctl_tcp_rmem[1]));
484-
else
485-
WRITE_ONCE(nsk->sk_rcvbuf,
486-
2 * READ_ONCE(nnet->smc.sysctl_rmem));
487-
}
488470
}
489471

490472
static void smc_copy_sock_settings(struct sock *nsk, struct sock *osk,

0 commit comments

Comments
 (0)