From 6bc41c9ce4cb22672db71a7f54f8f733c717f31b Mon Sep 17 00:00:00 2001 From: arctic-alpaca <67190338+arctic-alpaca@users.noreply.github.com> Date: Wed, 20 Nov 2024 19:42:50 +0100 Subject: [PATCH] update/add missing AF_XDP structs & constants --- libc-test/build.rs | 36 +++++++++++++++++++++++++-- libc-test/semver/linux-gnu.txt | 5 ++++ libc-test/semver/linux-musl.txt | 5 ++++ src/unix/linux_like/linux/gnu/mod.rs | 28 +++++++++++++++++++++ src/unix/linux_like/linux/musl/mod.rs | 28 +++++++++++++++++++++ 5 files changed, 100 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 982e060f97cb7..b352add16b327 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3817,12 +3817,25 @@ fn test_linux(target: &str) { // FIXME: Requires >= 5.4 kernel headers. // Everything that uses install-musl.sh has 4.19 kernel headers. - "xdp_umem_reg" | "xdp_ring_offset" | "xdp_mmap_offsets" if musl => true, + "xdp_ring_offset" | "xdp_mmap_offsets" if musl => true, + + // FIXME: Requires >= 6.8 kernel headers. + // A field was added in 6.8. + // https://github.com/torvalds/linux/commit/341ac980eab90ac1f6c22ee9f9da83ed9604d899 + // The previous version of the struct was removed in 6.11 due to a bug. + // https://github.com/torvalds/linux/commit/32654bbd6313b4cfc82297e6634fa9725c3c900f + "xdp_umem_reg" => true, // FIXME: Requires >= 5.9 kernel headers. // Everything that uses install-musl.sh has 4.19 kernel headers. "xdp_statistics" if musl => true, + // FIXME: Requires >= 6.8 kernel headers. + "xsk_tx_metadata" + | "__c_anonymous_xsk_tx_metadata_union" + | "xsk_tx_metadata_request" + | "xsk_tx_metadata_completion" => true, + // A new field was added in kernel 5.4, this is the old version for backwards compatibility. // https://github.com/torvalds/linux/commit/77cd0d7b3f257fd0e3096b4fdcff1a7d38e99e10 "xdp_ring_offset_v1" | "xdp_mmap_offsets_v1" => true, @@ -4267,6 +4280,23 @@ fn test_linux(target: &str) { true } + // FIXME: Requires >= 6.8 kernel headers. + "XDP_UMEM_TX_SW_CSUM" + | "XDP_TXMD_FLAGS_TIMESTAMP" + | "XDP_TXMD_FLAGS_CHECKSUM" + | "XDP_TX_METADATA" + => + { + true + } + + // FIXME: Requires >= 6.11 kernel headers. + "XDP_UMEM_TX_METADATA_LEN" + => + { + true + } + // FIXME: Requires >= 6.6 kernel headers. "SYS_fchmodat2" => true, @@ -4524,7 +4554,9 @@ fn test_linux(target: &str) { (musl && struct_ == "mcontext_t" && field == "__extcontext" && loongarch64) || // FIXME(#4121): a new field was added from `f_spare` (struct_ == "statvfs" && field == "__f_spare") || - (struct_ == "statvfs64" && field == "__f_spare") + (struct_ == "statvfs64" && field == "__f_spare") || + // the `xsk_tx_metadata_union` field is an anonymous union + (struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union") }); cfg.skip_roundtrip(move |s| match s { diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 83dd825584cd0..87fb4e480f7f2 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -489,12 +489,17 @@ XDP_RING_NEED_WAKEUP XDP_RX_RING XDP_SHARED_UMEM XDP_STATISTICS +XDP_TXMD_FLAGS_CHECKSUM +XDP_TXMD_FLAGS_TIMESTAMP +XDP_TX_METADATA XDP_TX_RING XDP_UMEM_COMPLETION_RING XDP_UMEM_FILL_RING XDP_UMEM_PGOFF_COMPLETION_RING XDP_UMEM_PGOFF_FILL_RING XDP_UMEM_REG +XDP_UMEM_TX_METADATA_LEN +XDP_UMEM_TX_SW_CSUM XDP_UMEM_UNALIGNED_CHUNK_FLAG XDP_USE_NEED_WAKEUP XDP_USE_SG diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 62b188dac8288..802e1477ca470 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -48,12 +48,17 @@ XDP_RING_NEED_WAKEUP XDP_RX_RING XDP_SHARED_UMEM XDP_STATISTICS +XDP_TXMD_FLAGS_CHECKSUM +XDP_TXMD_FLAGS_TIMESTAMP +XDP_TX_METADATA XDP_TX_RING XDP_UMEM_COMPLETION_RING XDP_UMEM_FILL_RING XDP_UMEM_PGOFF_COMPLETION_RING XDP_UMEM_PGOFF_FILL_RING XDP_UMEM_REG +XDP_UMEM_TX_METADATA_LEN +XDP_UMEM_TX_SW_CSUM XDP_UMEM_UNALIGNED_CHUNK_FLAG XDP_USE_NEED_WAKEUP XDP_USE_SG diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 79aa59a59f38b..f67b291bf2e2b 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -401,6 +401,7 @@ s! { pub chunk_size: ::__u32, pub headroom: ::__u32, pub flags: ::__u32, + pub tx_metadata_len: ::__u32, } pub struct xdp_umem_reg_v1 { @@ -435,6 +436,15 @@ s! { pub options: ::__u32, } + pub struct xsk_tx_metadata_completion { + pub tx_timestamp: ::__u64, + } + + pub struct xsk_tx_metadata_request { + pub csum_start: ::__u16, + pub csum_offset: ::__u16, + } + pub struct iocb { pub aio_data: ::__u64, #[cfg(target_endian = "little")] @@ -656,6 +666,18 @@ s_no_extra_traits! { pub ut_addr_v6: [i32; 4], __glibc_reserved: [::c_char; 20], } + + #[allow(missing_debug_implementations)] + pub struct xsk_tx_metadata { + pub flags: ::__u64, + pub xsk_tx_metadata_union: __c_anonymous_xsk_tx_metadata_union, + } + + #[allow(missing_debug_implementations)] + pub union __c_anonymous_xsk_tx_metadata_union { + pub request: xsk_tx_metadata_request, + pub completion: xsk_tx_metadata_completion, + } } cfg_if! { @@ -1087,6 +1109,8 @@ pub const XDP_USE_NEED_WAKEUP: ::__u16 = 1 << 3; pub const XDP_USE_SG: ::__u16 = 1 << 4; pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: ::__u32 = 1 << 0; +pub const XDP_UMEM_TX_SW_CSUM: ::__u32 = 1 << 1; +pub const XDP_UMEM_TX_METADATA_LEN: ::__u32 = 1 << 2; pub const XDP_RING_NEED_WAKEUP: ::__u32 = 1 << 0; @@ -1109,7 +1133,11 @@ pub const XDP_UMEM_PGOFF_COMPLETION_RING: ::c_ulonglong = 0x180000000; pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: ::c_int = 48; pub const XSK_UNALIGNED_BUF_ADDR_MASK: ::c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; +pub const XDP_TXMD_FLAGS_TIMESTAMP: ::__u32 = 1 << 0; +pub const XDP_TXMD_FLAGS_CHECKSUM: ::__u32 = 1 << 1; + pub const XDP_PKT_CONTD: ::__u32 = 1 << 0; +pub const XDP_TX_METADATA: ::__u32 = 1 << 1; pub const ELFOSABI_ARM_AEABI: u8 = 64; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 3c13e3a3d131a..82d319ff08649 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -311,6 +311,7 @@ s! { pub chunk_size: ::__u32, pub headroom: ::__u32, pub flags: ::__u32, + pub tx_metadata_len: ::__u32, } pub struct xdp_umem_reg_v1 { @@ -345,6 +346,15 @@ s! { pub options: ::__u32, } + pub struct xsk_tx_metadata_completion { + pub tx_timestamp: ::__u64, + } + + pub struct xsk_tx_metadata_request { + pub csum_start: ::__u16, + pub csum_offset: ::__u16, + } + // netinet/tcp.h pub struct tcp_info { @@ -482,6 +492,18 @@ s_no_extra_traits! { pub ut_addr_v6: [::c_uint; 4], __unused: [::c_char; 20], } + + #[allow(missing_debug_implementations)] + pub struct xsk_tx_metadata { + pub flags: ::__u64, + pub xsk_tx_metadata_union: __c_anonymous_xsk_tx_metadata_union, + } + + #[allow(missing_debug_implementations)] + pub union __c_anonymous_xsk_tx_metadata_union { + pub request: xsk_tx_metadata_request, + pub completion: xsk_tx_metadata_completion, + } } cfg_if! { @@ -887,6 +909,8 @@ pub const XDP_USE_NEED_WAKEUP: ::__u16 = 1 << 3; pub const XDP_USE_SG: ::__u16 = 1 << 4; pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: ::__u32 = 1 << 0; +pub const XDP_UMEM_TX_SW_CSUM: ::__u32 = 1 << 1; +pub const XDP_UMEM_TX_METADATA_LEN: ::__u32 = 1 << 2; pub const XDP_RING_NEED_WAKEUP: ::__u32 = 1 << 0; @@ -909,7 +933,11 @@ pub const XDP_UMEM_PGOFF_COMPLETION_RING: ::c_ulonglong = 0x180000000; pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: ::c_int = 48; pub const XSK_UNALIGNED_BUF_ADDR_MASK: ::c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; +pub const XDP_TXMD_FLAGS_TIMESTAMP: ::__u32 = 1 << 0; +pub const XDP_TXMD_FLAGS_CHECKSUM: ::__u32 = 1 << 1; + pub const XDP_PKT_CONTD: ::__u32 = 1 << 0; +pub const XDP_TX_METADATA: ::__u32 = 1 << 1; pub const _CS_V6_ENV: ::c_int = 1148; pub const _CS_V7_ENV: ::c_int = 1149;