Skip to content

Commit

Permalink
Update linux-raw-sys to 0.6 (#1061)
Browse files Browse the repository at this point in the history
* Update linux-raw-sys to 0.6 release

* Add tx_metadata_len field to XdpUmemReg

This field is introduced in kernel version 6.8.
  • Loading branch information
oherrala authored Dec 8, 2024
1 parent 7355af2 commit b030081
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ once_cell = { version = "1.5.2", optional = true }
# libc backend can be selected via adding `--cfg=rustix_use_libc` to
# `RUSTFLAGS` or enabling the `use-libc` cargo feature.
[target.'cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", any(target_endian = "little", target_arch = "s390x"), any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "s390x"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))'.dependencies]
linux-raw-sys = { version = "0.4.14", default-features = false, features = ["general", "errno", "ioctl", "no_std", "elf"] }
linux-raw-sys = { version = "0.6", default-features = false, features = ["general", "errno", "ioctl", "no_std", "elf"] }
libc_errno = { package = "errno", version = "0.3.10", default-features = false, optional = true }
libc = { version = "0.2.161", default-features = false, optional = true }

Expand All @@ -53,7 +53,7 @@ libc = { version = "0.2.161", default-features = false }
# Some syscalls do not have libc wrappers, such as in `io_uring`. For these,
# the libc backend uses the linux-raw-sys ABI and `libc::syscall`.
[target.'cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", any(target_endian = "little", target_arch = "s390x"), any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "s390x"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))))))'.dependencies]
linux-raw-sys = { version = "0.4.14", default-features = false, features = ["general", "ioctl", "no_std"] }
linux-raw-sys = { version = "0.6", default-features = false, features = ["general", "ioctl", "no_std"] }

# For the libc backend on Windows, use the Winsock API in windows-sys.
[target.'cfg(windows)'.dependencies.windows-sys]
Expand Down
29 changes: 21 additions & 8 deletions src/io_uring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,9 @@ pub struct io_uring_sync_cancel_reg {
pub fd: i32,
pub flags: IoringAsyncCancelFlags,
pub timeout: Timespec,
pub pad: [u64; 4],
pub opcode: u8,
pub pad: [u8; 7],
pub pad2: [u64; 3],
}

impl Default for io_uring_sync_cancel_reg {
Expand All @@ -1225,7 +1227,9 @@ impl Default for io_uring_sync_cancel_reg {
tv_sec: 0,
tv_nsec: 0,
},
opcode: Default::default(),
pad: Default::default(),
pad2: Default::default(),
}
}
}
Expand Down Expand Up @@ -1291,7 +1295,7 @@ pub struct io_sqring_offsets {
pub dropped: u32,
pub array: u32,
pub resv1: u32,
pub resv2: u64,
pub user_addr: u64,
}

#[allow(missing_docs)]
Expand All @@ -1306,7 +1310,7 @@ pub struct io_cqring_offsets {
pub cqes: u32,
pub flags: u32,
pub resv1: u32,
pub resv2: u64,
pub user_addr: u64,
}

#[allow(missing_docs)]
Expand Down Expand Up @@ -1419,7 +1423,7 @@ pub struct io_uring_buf_reg {
pub ring_addr: u64,
pub ring_entries: u32,
pub bgid: u16,
pub pad: u16,
pub flags: u16,
pub resv: [u64; 3_usize],
}

Expand Down Expand Up @@ -1605,7 +1609,7 @@ mod tests {
dropped,
array,
resv1,
resv2
user_addr
);
check_struct!(
io_cqring_offsets,
Expand All @@ -1617,7 +1621,7 @@ mod tests {
cqes,
flags,
resv1,
resv2
user_addr
);
check_struct!(io_uring_recvmsg_out, namelen, controllen, payloadlen, flags);
check_struct!(io_uring_probe, last_op, ops_len, resv, resv2, ops);
Expand All @@ -1629,9 +1633,18 @@ mod tests {
check_struct!(io_uring_getevents_arg, sigmask, sigmask_sz, pad, ts);
check_struct!(iovec, iov_base, iov_len);
check_struct!(open_how, flags, mode, resolve);
check_struct!(io_uring_buf_reg, ring_addr, ring_entries, bgid, pad, resv);
check_struct!(io_uring_buf_reg, ring_addr, ring_entries, bgid, flags, resv);
check_struct!(io_uring_buf, addr, len, bid, resv);
check_struct!(io_uring_sync_cancel_reg, addr, fd, flags, timeout, pad);
check_struct!(
io_uring_sync_cancel_reg,
addr,
fd,
flags,
timeout,
opcode,
pad,
pad2
);

check_renamed_type!(tail_or_bufs_struct, io_uring_buf_ring__bindgen_ty_1);
check_renamed_type!(
Expand Down
6 changes: 5 additions & 1 deletion src/net/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ pub mod xdp {
/// XDP umem registration.
///
/// `struct xdp_umem_reg`
// https://github.com/torvalds/linux/blob/v6.6/include/uapi/linux/if_xdp.h#L73-L79
// https://github.com/torvalds/linux/blob/v6.8/include/uapi/linux/if_xdp.h#L79-L86
#[repr(C)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct XdpUmemReg {
Expand All @@ -1674,6 +1674,10 @@ pub mod xdp {
///
/// Requires kernel version 5.4.
pub flags: XdpUmemRegFlags,
/// AF_XDP TX metadata length
///
/// Requires kernel version 6.8.
pub tx_metadata_len: u32,
}

/// XDP statistics.
Expand Down
2 changes: 1 addition & 1 deletion tests/io_uring/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fn io_uring_buf_ring_can_be_registered() {
ring_addr: br_ptr as u64,
ring_entries: ENTRIES as u32,
bgid: BGID,
pad: 0,
flags: 0,
resv: [0u64; 3],
};

Expand Down

0 comments on commit b030081

Please sign in to comment.