net/smc: convert getsockopt to getsockopt_iter
Get series with b4
b4 am [email protected] change-id 20260604-getsockopt_smc-e2ad719486ebVersions newest first
- v1 Latest2 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | smc: convert to getsockopt_iternet/ net/ net/ | +32 | 1 reply | |
| 2/2 | selftests: net: add SMC getsockopt_iter conversion testtools/ tools/ | +176 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH net-next 0/2] net/smc: convert getsockopt to getsockopt_iter
SMC is the last protocol to be converted to getsockopt_iter(). As soon as this series lands, and all the other outstanding conversion patches land, getsockopt_iter() will be renamed back to getsockopt() and the first part of the conversion will be complete.
This series converts SMC's getsockopt() to the new getsockopt_iter() callback, which hands protocols a sockopt_t that abstracts the optval buffer as an iov_iter and the option length as a plain int instead of raw (char __user *optval, int __user *optlen) pointers. This is part of the broader effort to move getsockopt() off __user pointers so that kernel-backed callers (e.g. io_uring) can issue socket options.
SMC is a proxy socket: only the SOL_SMC level is handled locally, while every other level is forwarded to the underlying CLC (TCP) socket. That sub-socket's getsockopt() still operates on __user buffers, so the pass-through cannot simply forward the sockopt_t. Instead it reconstructs optval from a user-backed iter_out, forwards the preserved user optlen pointer (kept in sockopt_t by the base patch), and mirrors the length reported by the clcsock back into opt->optlen.
Because of that, the SOL_SMC level is fully converted and works with any iov_iter type, but the CLC pass-through is intentionally limited to user-backed iters (ubuf) and returns -EOPNOTSUPP otherwise. This is a deliberate, temporary restriction: SMC will continue to operate on ubuf only until the underlying protocols (TCP/IP) grow their own getsockopt_iter() callbacks. Once that generic callback path is enabled, the pass-through can forward the sockopt_t directly and drop the ubuf restriction, supporting all iov_iter types.
The series contains:
1) smc: convert getsockopt to getsockopt_iter / sockopt_t.
2) selftests: net: I've vibe coded a kselftest exercising both the SOL_SMC path and the CLC pass-through, including the oversized-buffer writeback.
---
Breno Leitao (2):
smc: convert to getsockopt_iter
selftests: net: add SMC getsockopt_iter conversion test
net/smc/af_smc.c | 41 +++++-- net/smc/smc.h | 2 +- net/smc/smc_inet.c | 4 +- tools/testing/selftests/net/Makefile | 1 + tools/testing/selftests/net/getsockopt_smc.c | 175 +++++++++++++++++++++++++++ 5 files changed, 208 insertions(+), 15 deletions(-)
---
base-commit: 0a8b288e2248cb62a62f748bc095c2136acf22b2
change-id: 20260604-getsockopt_smc-e2ad719486eb
Best regards,
Signature · 1 line
Breno Leitao <[email protected]>