Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add GSO flags for linux and android #3405

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ i686-linux-android \
i686-unknown-freebsd \
i686-unknown-linux-gnu \
i686-unknown-linux-musl \
mips-unknown-linux-gnu \
mips-unknown-linux-musl \
mips64-unknown-linux-gnuabi64 \
mips64el-unknown-linux-gnuabi64 \
mipsel-unknown-linux-gnu \
mipsel-unknown-linux-musl \
powerpc-unknown-linux-gnu \
powerpc64-unknown-linux-gnu \
powerpc64le-unknown-linux-gnu \
Expand All @@ -118,6 +112,14 @@ x86_64-unknown-linux-musl \
x86_64-unknown-netbsd \
"

# FIXME: builds of MIPS targets are currently broken on nightly.
# mips-unknown-linux-gnu \
# mips-unknown-linux-musl \
# mips64-unknown-linux-gnuabi64 \
# mips64el-unknown-linux-gnuabi64 \
# mipsel-unknown-linux-gnu \
# mipsel-unknown-linux-musl \

RUST_GT_1_13_LINUX_TARGETS="\
arm-unknown-linux-musleabi \
arm-unknown-linux-musleabihf \
Expand Down
3 changes: 3 additions & 0 deletions ci/install-rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ else
# https://github.com/rust-lang/rust/issues/103673 contains related information.
case "$TARGET" in
*android*) toolchain=nightly-2022-10-09;;
# FIXME: Unpin once mips' components are available on nightly.
# https://rust-lang.github.io/rustup-components-history/mips-unknown-linux-gnu.html
*mips*) toolchain=nightly-2023-07-04;;
*) toolchain=nightly;;
esac
fi
Expand Down
3 changes: 3 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3859,6 +3859,9 @@ fn test_linux(target: &str) {
// kernel 6.1 minimum
"MADV_COLLAPSE" => true,

// kernel 6.2 minimum
"TUN_F_USO4" | "TUN_F_USO6" | "IFF_NO_CARRIER" => true,

// FIXME: Requires more recent kernel headers
| "IFLA_PARENT_DEV_NAME" // linux v5.13+
| "IFLA_PARENT_DEV_BUS_NAME" // linux v5.13+
Expand Down
8 changes: 8 additions & 0 deletions libc-test/semver/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ IFF_MASTER
IFF_MULTICAST
IFF_NOARP
IFF_NOTRAILERS
IFF_NO_CARRIER
IFF_NO_PI
IFF_POINTOPOINT
IFF_PORTSEL
Expand Down Expand Up @@ -2740,6 +2741,13 @@ TIOCSWINSZ
TMPFS_MAGIC
TMP_MAX
TOSTOP
TUN_F_CSUM
TUN_F_TSO4
TUN_F_TSO6
TUN_F_TSO_ECN
TUN_F_UFO
TUN_F_USO4
TUN_F_USO6
UINPUT_MAX_NAME_SIZE
UINPUT_VERSION
UIO_MAXIOV
Expand Down
13 changes: 13 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,11 @@ IFF_MULTICAST
IFF_MULTI_QUEUE
IFF_NOARP
IFF_NOFILTER
TUN_TX_TIMESTAMP
TUN_PKT_STRIP
TUN_FLT_ALLMULTI
IFF_NOTRAILERS
IFF_NO_CARRIER
IFF_NO_PI
IFF_ONE_QUEUE
IFF_PERSIST
Expand All @@ -906,6 +910,8 @@ IFF_RUNNING
IFF_SLAVE
IFF_TAP
IFF_TUN
IFF_NAPI
IFF_NAPI_FRAGS
IFF_TUN_EXCL
IFF_UP
IFF_VNET_HDR
Expand Down Expand Up @@ -2861,6 +2867,13 @@ TUN_READQ_SIZE
TUN_TAP_DEV
TUN_TUN_DEV
TUN_TYPE_MASK
TUN_F_CSUM
TUN_F_TSO4
TUN_F_TSO6
TUN_F_TSO_ECN
TUN_F_UFO
TUN_F_USO4
TUN_F_USO6
T_FMT
T_FMT_AMPM
UDP_CORK
Expand Down
9 changes: 9 additions & 0 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2481,6 +2481,7 @@ pub const IFF_TUN: ::c_int = 0x0001;
pub const IFF_TAP: ::c_int = 0x0002;
pub const IFF_NAPI: ::c_int = 0x0010;
pub const IFF_NAPI_FRAGS: ::c_int = 0x0020;
pub const IFF_NO_CARRIER: ::c_int = 0x0040;
pub const IFF_NO_PI: ::c_int = 0x1000;
pub const IFF_ONE_QUEUE: ::c_int = 0x2000;
pub const IFF_VNET_HDR: ::c_int = 0x4000;
Expand All @@ -2490,6 +2491,14 @@ pub const IFF_ATTACH_QUEUE: ::c_int = 0x0200;
pub const IFF_DETACH_QUEUE: ::c_int = 0x0400;
pub const IFF_PERSIST: ::c_int = 0x0800;
pub const IFF_NOFILTER: ::c_int = 0x1000;
// Features for GSO (TUNSETOFFLOAD)
pub const TUN_F_CSUM: ::c_uint = 0x01;
pub const TUN_F_TSO4: ::c_uint = 0x02;
pub const TUN_F_TSO6: ::c_uint = 0x04;
pub const TUN_F_TSO_ECN: ::c_uint = 0x08;
pub const TUN_F_UFO: ::c_uint = 0x10;
pub const TUN_F_USO4: ::c_uint = 0x20;
pub const TUN_F_USO6: ::c_uint = 0x40;

// start android/platform/bionic/libc/kernel/uapi/linux/if_ether.h
// from https://android.googlesource.com/platform/bionic/+/HEAD/libc/kernel/uapi/linux/if_ether.h
Expand Down
18 changes: 18 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,10 @@ pub const IFLA_INFO_SLAVE_DATA: ::c_ushort = 5;
// linux/if_tun.h
pub const IFF_TUN: ::c_int = 0x0001;
pub const IFF_TAP: ::c_int = 0x0002;
pub const IFF_NAPI: ::c_int = 0x0010;
pub const IFF_NAPI_FRAGS: ::c_int = 0x0020;
// Used in TUNSETIFF to bring up tun/tap without carrier
pub const IFF_NO_CARRIER: ::c_int = 0x0040;
pub const IFF_NO_PI: ::c_int = 0x1000;
// Read queue size
pub const TUN_READQ_SIZE: ::c_short = 500;
Expand All @@ -1847,6 +1851,20 @@ pub const IFF_DETACH_QUEUE: ::c_int = 0x0400;
// read-only flag
pub const IFF_PERSIST: ::c_int = 0x0800;
pub const IFF_NOFILTER: ::c_int = 0x1000;
// Socket options
pub const TUN_TX_TIMESTAMP: ::c_int = 1;
// Features for GSO (TUNSETOFFLOAD)
pub const TUN_F_CSUM: ::c_uint = 0x01;
pub const TUN_F_TSO4: ::c_uint = 0x02;
pub const TUN_F_TSO6: ::c_uint = 0x04;
pub const TUN_F_TSO_ECN: ::c_uint = 0x08;
pub const TUN_F_UFO: ::c_uint = 0x10;
pub const TUN_F_USO4: ::c_uint = 0x20;
pub const TUN_F_USO6: ::c_uint = 0x40;
// Protocol info prepended to the packets (when IFF_NO_PI is not set)
pub const TUN_PKT_STRIP: ::c_int = 0x0001;
// Accept all multicast packets
pub const TUN_FLT_ALLMULTI: ::c_int = 0x0001;

// Since Linux 3.1
pub const SEEK_DATA: ::c_int = 3;
Expand Down
27 changes: 22 additions & 5 deletions src/vxworks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,21 @@ pub const O_WRONLY: ::c_int = 0x0001;
pub const O_RDONLY: ::c_int = 0;
pub const O_NONBLOCK: ::c_int = 0x4000;

// mman.h
pub const PROT_NONE: ::c_int = 0x0000;
pub const PROT_READ: ::c_int = 0x0001;
pub const PROT_WRITE: ::c_int = 0x0002;
pub const PROT_EXEC: ::c_int = 0x0004;

pub const MAP_SHARED: ::c_int = 0x0001;
pub const MAP_PRIVATE: ::c_int = 0x0002;
pub const MAP_ANON: ::c_int = 0x0004;
pub const MAP_ANONYMOUS: ::c_int = MAP_ANON;
pub const MAP_FIXED: ::c_int = 0x0010;
pub const MAP_CONTIG: ::c_int = 0x0020;

pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;

#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum FILE {}
impl ::Copy for FILE {}
Expand Down Expand Up @@ -1218,6 +1233,8 @@ extern "C" {
) -> *mut ::c_void;
pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int;
pub fn shm_unlink(name: *const ::c_char) -> ::c_int;

pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
pub fn pthread_exit(value: *mut ::c_void) -> !;
Expand Down Expand Up @@ -1909,19 +1926,19 @@ cfg_if! {
if #[cfg(target_arch = "aarch64")] {
mod aarch64;
pub use self::aarch64::*;
} else if #[cfg(any(target_arch = "arm"))] {
} else if #[cfg(target_arch = "arm")] {
mod arm;
pub use self::arm::*;
} else if #[cfg(any(target_arch = "x86"))] {
} else if #[cfg(target_arch = "x86")] {
mod x86;
pub use self::x86::*;
} else if #[cfg(any(target_arch = "x86_64"))] {
} else if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
} else if #[cfg(any(target_arch = "powerpc"))] {
} else if #[cfg(target_arch = "powerpc")] {
mod powerpc;
pub use self::powerpc::*;
} else if #[cfg(any(target_arch = "powerpc64"))] {
} else if #[cfg(target_arch = "powerpc64")] {
mod powerpc64;
pub use self::powerpc64::*;
} else {
Expand Down