net: convert UDP getsockopt to sockopt_t
Status from this message: This series was applied to netdev/net-next.git (main)
Get series with b4
b4 am [email protected] change-id 20260611-getsockopt_phase2-cd495a0115caVersions newest first
- v2 Latest4 patches 8 repliesApplied 4/4
- v12 patches 6 repliesSuperseded
Changes in v2 from the cover letter
- Check for invalid len at call site (Stanlislav)
- Do not rewrite optlen on error path (Sashiko)
- Converted ipv4 raw
- Expanded the selftest to test this new helper.
- Link to v1: https://lore.kernel.org/r/[email protected]
Patches in v2 All 4 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | net: add sockopt_init_user() for getsockopt conversioninclude/ | +23 | 2 replies | Applied |
| 2/4 | udp: convert udp_lib_getsockopt to sockopt_tinclude/ net/ net/ | +46 | 2 replies | Applied |
| 3/4 | ipv4: raw: convert do_raw_getsockopt to sockopt_tnet/ | +25 | 2 replies | Applied |
| 4/4 | selftests: net: getsockopt_iter: add raw ICMP_FILTER coveragetools/ | +97 | 2 replies | Applied |
Reviews trailers per patch
All 4 patches have a Reviewed-by or Acked-by.
| Patch | Stanislav Fomichev | Willem de Bruijn |
|---|---|---|
| 1/4 | A-b | A-b |
| 2/4 | A-b | A-b |
| 3/4 | A-b | A-b |
| 4/4 | A-b | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH net-next v2 0/4] net: convert UDP getsockopt to sockopt_t
The leaf proto_ops getsockopt callbacks have been moving to the new getsockopt_iter()/sockopt_t interface.
I was trying to get SMC into getsockop and retire .getsockopt, but, I found the best approach is to keep converting other protocols.
This series starts the same conversion one layer down, at the struct proto getsockopt path, beginning with UDP.
Example of the current code.
static int udp_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *optlen)
{
if (level == SOL_UDP)
return udp_lib_getsockopt(sk, level, optname, optval, optlen);
return ip_getsockopt(sk, level, optname, optval, optlen);
}We want udp_getsockopt to go to .getsockopt_iter, and there are two approaches in this case:
1) Create a patchset that moves both of them to getsockopt_iter, which is will be a huge change (ip_getsockopt() is used in many places)
2) Break this down, and transform from bottoms up. First udp_lib_getsockopt() up to the point we can easily convert others, such as ip_getsockopt().
I am taking the approach 2), so, the intermediate code will be something like:
static int udp_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *optlen)
{
sockopt_t opt;
int err;
if (level != SOL_UDP)
return ip_getsockopt(sk, level, optname, optval, optlen);
// Convert optlen/optval in sockopt // (first patch)
err = udp_lib_getsockopt(sk, level, optname, &opt);
}The work is bottom-up and mergeable in small steps: a protocol's inner getsockopt helper is switched to sockopt_t behind its existing thin __user wrapper, one patch at a time.
Once every inner helper speaks sockopt_t, a later series flips the shared struct proto.getsockopt and inet_connection_sock_af_ops.getsockopt signatures and drops the transitional wrappers.
---
Changes in v2:
- Check for invalid len at call site (Stanlislav)
- Do not rewrite optlen on error path (Sashiko)
- Converted ipv4 raw
- Expanded the selftest to test this new helper.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Breno Leitao (4):
net: add sockopt_init_user() for getsockopt conversion
udp: convert udp_lib_getsockopt to sockopt_t
ipv4: raw: convert do_raw_getsockopt to sockopt_t
selftests: net: getsockopt_iter: add raw ICMP_FILTER coverage
include/linux/net.h | 23 +++++++ include/net/udp.h | 2 +- net/ipv4/raw.c | 41 ++++++----- net/ipv4/udp.c | 39 ++++++++--- net/ipv6/udp.c | 19 +++++- tools/testing/selftests/net/getsockopt_iter.c | 97 +++++++++++++++++++++++++++ 6 files changed, 191 insertions(+), 30 deletions(-)
---
base-commit: c8459ee2fef502d6ef6c063751c33d9ac7943eab
change-id: 20260611-getsockopt_phase2-cd495a0115ca
Best regards,
Signature · 1 line
Breno Leitao <[email protected]>