[PATCH net-next v2 0/4] net: uapi: Provide an UAPI definition of 'struct sockaddr'

Thomas Weißschuh posted 4 patches 5 days, 8 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20260120-uapi-sockaddr-v2-0-63c319111cf6@linutronix.de
include/linux/socket.h                             | 10 ----------
include/uapi/linux/if.h                            |  4 ----
include/uapi/linux/libc-compat.h                   | 12 ++++++++++++
include/uapi/linux/socket.h                        | 14 ++++++++++++++
samples/bpf/xdp_adjust_tail_user.c                 |  6 ++++--
samples/bpf/xdp_fwd_user.c                         |  7 ++++---
samples/bpf/xdp_router_ipv4_user.c                 |  6 +++---
samples/bpf/xdp_sample_user.c                      | 15 ++++++++-------
samples/bpf/xdp_tx_iptunnel_user.c                 |  4 ++--
tools/testing/selftests/landlock/audit.h           |  7 ++++---
tools/testing/selftests/net/af_unix/diag_uid.c     |  9 +++++----
tools/testing/selftests/net/busy_poller.c          |  3 ++-
tools/testing/selftests/net/mptcp/mptcp_diag.c     | 11 ++++++-----
tools/testing/selftests/net/nettest.c              |  4 ++--
tools/testing/selftests/net/tcp_ao/icmps-discard.c |  6 +++---
tools/testing/selftests/net/tcp_ao/lib/netlink.c   |  9 +++++----
tools/testing/selftests/net/tun.c                  |  5 +++--
17 files changed, 77 insertions(+), 55 deletions(-)
[PATCH net-next v2 0/4] net: uapi: Provide an UAPI definition of 'struct sockaddr'
Posted by Thomas Weißschuh 5 days, 8 hours ago
Various UAPI headers reference 'struct sockaddr'. Currently the
definition of this struct is pulled in from the libc header
sys/socket.h. This is problematic as it introduces a dependency
on a full userspace toolchain.

Add a definition of 'struct sockaddr' to the UAPI headers.
Before that, reorder some problematic header inclusions in the selftests.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Changes in v2:
- Fix compilation failures in BPF samples and selftests
- Link to v1: https://lore.kernel.org/r/20260105-uapi-sockaddr-v1-1-b7653aba12a5@linutronix.de

---
Thomas Weißschuh (4):
      selftests: net: Move some UAPI header inclusions after libc ones
      selftests/landlock: Move some UAPI header inclusions after libc ones
      samples/bpf: Move some UAPI header inclusions after libc ones
      net: uapi: Provide an UAPI definition of 'struct sockaddr'

 include/linux/socket.h                             | 10 ----------
 include/uapi/linux/if.h                            |  4 ----
 include/uapi/linux/libc-compat.h                   | 12 ++++++++++++
 include/uapi/linux/socket.h                        | 14 ++++++++++++++
 samples/bpf/xdp_adjust_tail_user.c                 |  6 ++++--
 samples/bpf/xdp_fwd_user.c                         |  7 ++++---
 samples/bpf/xdp_router_ipv4_user.c                 |  6 +++---
 samples/bpf/xdp_sample_user.c                      | 15 ++++++++-------
 samples/bpf/xdp_tx_iptunnel_user.c                 |  4 ++--
 tools/testing/selftests/landlock/audit.h           |  7 ++++---
 tools/testing/selftests/net/af_unix/diag_uid.c     |  9 +++++----
 tools/testing/selftests/net/busy_poller.c          |  3 ++-
 tools/testing/selftests/net/mptcp/mptcp_diag.c     | 11 ++++++-----
 tools/testing/selftests/net/nettest.c              |  4 ++--
 tools/testing/selftests/net/tcp_ao/icmps-discard.c |  6 +++---
 tools/testing/selftests/net/tcp_ao/lib/netlink.c   |  9 +++++----
 tools/testing/selftests/net/tun.c                  |  5 +++--
 17 files changed, 77 insertions(+), 55 deletions(-)
---
base-commit: 24d479d26b25bce5faea3ddd9fa8f3a6c3129ea7
change-id: 20251222-uapi-sockaddr-cf10e7624729

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh@linutronix.de>

Re: [PATCH net-next v2 0/4] net: uapi: Provide an UAPI definition of 'struct sockaddr'
Posted by Jakub Kicinski 3 days, 19 hours ago
On Tue, 20 Jan 2026 15:10:30 +0100 Thomas Weißschuh wrote:
> Various UAPI headers reference 'struct sockaddr'. Currently the
> definition of this struct is pulled in from the libc header
> sys/socket.h. This is problematic as it introduces a dependency
> on a full userspace toolchain.
> 
> Add a definition of 'struct sockaddr' to the UAPI headers.
> Before that, reorder some problematic header inclusions in the selftests.

>  include/linux/socket.h                             | 10 ----------
>  include/uapi/linux/if.h                            |  4 ----
>  include/uapi/linux/libc-compat.h                   | 12 ++++++++++++
>  include/uapi/linux/socket.h                        | 14 ++++++++++++++
>  samples/bpf/xdp_adjust_tail_user.c                 |  6 ++++--
>  samples/bpf/xdp_fwd_user.c                         |  7 ++++---
>  samples/bpf/xdp_router_ipv4_user.c                 |  6 +++---
>  samples/bpf/xdp_sample_user.c                      | 15 ++++++++-------
>  samples/bpf/xdp_tx_iptunnel_user.c                 |  4 ++--
>  tools/testing/selftests/landlock/audit.h           |  7 ++++---
>  tools/testing/selftests/net/af_unix/diag_uid.c     |  9 +++++----
>  tools/testing/selftests/net/busy_poller.c          |  3 ++-
>  tools/testing/selftests/net/mptcp/mptcp_diag.c     | 11 ++++++-----
>  tools/testing/selftests/net/nettest.c              |  4 ++--
>  tools/testing/selftests/net/tcp_ao/icmps-discard.c |  6 +++---
>  tools/testing/selftests/net/tcp_ao/lib/netlink.c   |  9 +++++----
>  tools/testing/selftests/net/tun.c                  |  5 +++--
>  17 files changed, 77 insertions(+), 55 deletions(-)

Are all those selftests / samples getting broken by this patch set?

I understand that we should avoid libc dependencies in uAPI but at
least speaking for networking - building selftests without libc is..
not a practical proposition?
Re: [PATCH net-next v2 0/4] net: uapi: Provide an UAPI definition of 'struct sockaddr'
Posted by MPTCP CI 5 days, 6 hours ago
Hi Thomas,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Unstable: 1 failed test(s): bpftest_test_progs-cpuv4_mptcp 🔴
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/21175122829

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/81d99f1609e4
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1044679


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)