| #
c8c2bd2b |
| 07-May-2026 |
Breno Leitao <leitao@debian.org> |
selftests: net: getsockopt_iter: cleanup
Apply two cleanups suggested by Stanislav and bobby on the original selftest series:
- Reorder local variable declarations into reverse christmas-tree ord
selftests: net: getsockopt_iter: cleanup
Apply two cleanups suggested by Stanislav and bobby on the original selftest series:
- Reorder local variable declarations into reverse christmas-tree order (longest line first). Because that ordering puts socklen_t optlen before the variable whose size it stores, the "optlen = sizeof(...)" initializer is moved out of the declaration to a plain assignment in the test body, as Stanislav suggested.
- Add ASSERT_EQ(optlen, ...) on every error path so the value the kernel writes back to the userspace optlen is pinned down even when the syscall returns -1. With do_sock_getsockopt() now writing opt->optlen back to userspace unconditionally, asserting that the netlink/vsock error paths leave the original input length untouched guards against future regressions.
Bobby Eshleman pointed out that SO_VM_SOCKETS_CONNECT_TIMEOUT_NEW/OLD return a sock_timeval-shaped payload (16 bytes on 64-bit), which is wider than the u64 case already covered. Add four tests that exercise this path:
- connect_timeout_new_exact exact-size buffer - connect_timeout_new_oversize_clamped oversize buffer, clamped - connect_timeout_new_undersize undersize -> -EINVAL, optlen untouched - connect_timeout_old_exact exact-size buffer for OLD optname
Suggested-by: Stanislav Fomichev <sdf@fomichev.me> Suggested-by: Bobby Eshleman <bobbyeshleman@meta.com> Signed-off-by: Breno Leitao <leitao@debian.org> Link: https://patch.msgid.link/20260507-getsock_two-v2-5-5873111d9c12@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
| #
d39887f5 |
| 01-May-2026 |
Breno Leitao <leitao@debian.org> |
net: selftests: add getsockopt_iter regression tests
Add a single kselftest covering the proto_ops getsockopt_iter conversions for AF_NETLINK and AF_VSOCK, using one fixture per protocol:
netlink:
net: selftests: add getsockopt_iter regression tests
Add a single kselftest covering the proto_ops getsockopt_iter conversions for AF_NETLINK and AF_VSOCK, using one fixture per protocol:
netlink:
NETLINK_PKTINFO covers the flag-style int path (exact size, oversize clamp, undersize -EINVAL); NETLINK_LIST_MEMBERSHIPS covers the size-discovery path that always reports the required buffer length back via optlen, even when the user buffer is too small to receive any group bits.
vsock: SO_VM_SOCKETS_BUFFER_SIZE covers the u64 path (exact size, oversize clamp, undersize -EINVAL).
Each fixture also exercises an unknown optname and a bogus level so the returned-length / errno semantics preserved by the sockopt_t conversion are pinned down.
Signed-off-by: Breno Leitao <leitao@debian.org> Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20260501-getsock_one-v1-3-810ce23ea70e@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|