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 #3420

Merged
merged 1 commit into from Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions libc-test/build.rs
Expand Up @@ -1830,6 +1830,9 @@ fn test_android(target: &str) {
// kernel 5.6 minimum required
"IPPROTO_MPTCP" | "IPPROTO_ETHERNET" => true,

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

// FIXME: NDK r22 minimum required
| "FDB_NOTIFY_BIT"
| "FDB_NOTIFY_INACTIVE_BIT"
Expand Down Expand Up @@ -3862,6 +3865,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
Expand Up @@ -699,6 +699,7 @@ IFF_MASTER
IFF_MULTICAST
IFF_NOARP
IFF_NOTRAILERS
IFF_NO_CARRIER
IFF_NO_PI
IFF_POINTOPOINT
IFF_PORTSEL
Expand All @@ -708,6 +709,13 @@ IFF_SLAVE
IFF_TAP
IFF_TUN
IFF_UP
TUN_F_CSUM
TUN_F_TSO4
TUN_F_TSO6
TUN_F_TSO_ECN
TUN_F_UFO
TUN_F_USO4
TUN_F_USO6
IFNAMSIZ
IF_NAMESIZE
IFA_UNSPEC
Expand Down
3 changes: 3 additions & 0 deletions libc-test/semver/linux.txt
Expand Up @@ -932,6 +932,7 @@ IFF_LOWER_UP
IFF_MASTER
IFF_MULTICAST
IFF_MULTI_QUEUE
IFF_NO_CARRIER
IFF_NOARP
IFF_NOFILTER
TUN_TX_TIMESTAMP
Expand All @@ -940,6 +941,8 @@ TUN_F_TSO4
TUN_F_TSO6
TUN_F_TSO_ECN
TUN_F_UFO
TUN_F_USO4
TUN_F_USO6
TUN_PKT_STRIP
TUN_FLT_ALLMULTI
IFF_NOTRAILERS
Expand Down
9 changes: 9 additions & 0 deletions src/unix/linux_like/android/mod.rs
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
14 changes: 9 additions & 5 deletions src/unix/linux_like/linux/mod.rs
Expand Up @@ -1866,6 +1866,8 @@ 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 @@ -1886,11 +1888,13 @@ 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_ushort = 0x01; /* You can hand me unchecksummed packets. */
pub const TUN_F_TSO4: ::c_ushort = 0x02; /* I can handle TSO for IPv4 packets */
pub const TUN_F_TSO6: ::c_ushort = 0x04; /* I can handle TSO for IPv6 packets */
pub const TUN_F_TSO_ECN: ::c_ushort = 0x08; /* I can handle TSO with ECN bits. */
pub const TUN_F_UFO: ::c_ushort = 0x10; /* I can handle UFO packets */
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
Expand Down