Commit d14cdbd5 authored by Litao Jiao's avatar Litao Jiao
Browse files

net/smc: Use correct buffer sizes when switching between TCP and SMC

mainline inclusion
from mainline-v6.5-rc6
commit 30c3c4a4
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I76JHC
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/net/smc?id=30c3c4a4497c3765bf6b298f5072c8165aeaf7cc



--------------------------------

Tuning of the effective buffer size through setsockopts was working for
SMC traffic only but not for TCP fall-back connections even before
commit 0227f058 ("net/smc: Unbind r/w buffer size from clcsock and
make them tunable"). That change made it apparent that TCP fall-back
connections would use net.smc.[rw]mem as buffer size instead of
net.ipv4_tcp_[rw]mem.

Amend the code that copies attributes between the (TCP) clcsock and the
SMC socket and adjust buffer sizes appropriately:
- Copy over sk_userlocks so that both sockets agree on whether tuning
  via setsockopt is active.
- When falling back to TCP use sk_sndbuf or sk_rcvbuf as specified with
  setsockopt. Otherwise, use the sysctl value for TCP/IPv4.
- Likewise, use either values from setsockopt or from sysctl for SMC
  (duplicated) on successful SMC connect.

In smc_tcp_listen_work() drop the explicit copy of buffer sizes as that
is taken care of by the attribute copy.

Fixes: 0227f058 ("net/smc: Unbind r/w buffer size from clcsock and make them tunable")
Reviewed-by: default avatarWenjia Zhang <wenjia@linux.ibm.com>
Reviewed-by: default avatarTony Lu <tonylu@linux.alibaba.com>
Signed-off-by: default avatarGerd Bayer <gbayer@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarjiaolitao48147 <48147@sangfor.com>
Signed-off-by: default avatarjiaolitao48147 <48147@sangfor.com>
Signed-off-by: default avatarLitao Jiao <jiaolitao@sangfor.com.cn>
parent a307b2b1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment