From 2a212c84fb24aa17283af5bb87ff60f4fdc5affd Mon Sep 17 00:00:00 2001 From: George Hopkins Date: Wed, 21 Oct 2020 07:22:41 +0200 Subject: [PATCH 1/2] linux: Add definitions for Multipath TCP We leave IPPROTO_MAX as is for the time being. However, in recent kernel releases IPPROTO_MAX is actually higher and reflects the addition of IPPROTO_MPTCP. --- libc-test/build.rs | 4 ++++ src/unix/linux_like/android/mod.rs | 4 ++++ src/unix/linux_like/emscripten/mod.rs | 2 ++ src/unix/linux_like/linux/mod.rs | 10 ++++++++++ src/unix/linux_like/mod.rs | 1 - 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 3a5c857dda260..93efd55703472 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2649,6 +2649,10 @@ fn test_linux(target: &str) { // Require Linux kernel 5.6: "VMADDR_CID_LOCAL" => true, + // IPPROTO_MAX was increased in 5.6 for IPPROTO_MPTCP: + | "IPPROTO_MAX" + | "IPPROTO_MPTCP" => true, + // Defined in kernel headers but musl removes it; need musl 1.2 for definition in musl // headers. "P_PIDFD" => true, diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index fb49108056003..bcf478bf10144 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1008,6 +1008,8 @@ pub const SOCK_SEQPACKET: ::c_int = 5; pub const SOCK_DCCP: ::c_int = 6; pub const SOCK_PACKET: ::c_int = 10; +pub const IPPROTO_MAX: ::c_int = 256; + pub const SOL_SOCKET: ::c_int = 1; pub const SOL_SCTP: ::c_int = 132; pub const SOL_IPX: ::c_int = 256; @@ -1068,6 +1070,8 @@ pub const SO_RXQ_OVFL: ::c_int = 40; pub const SO_PEEK_OFF: ::c_int = 42; pub const SO_BUSY_POLL: ::c_int = 46; +pub const TCP_ULP: ::c_int = 31; + pub const IPTOS_ECN_NOTECT: u8 = 0x00; pub const O_ACCMODE: ::c_int = 3; diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 2584a3ba07bcf..945efeea74ea2 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1557,6 +1557,8 @@ pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; pub const SOCK_SEQPACKET: ::c_int = 5; +pub const IPPROTO_MAX: ::c_int = 256; + pub const SOL_SOCKET: ::c_int = 1; pub const SO_REUSEADDR: ::c_int = 2; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index d6962778e7f86..3494a13369f12 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1228,6 +1228,7 @@ pub const RTLD_NOW: ::c_int = 0x2; pub const AT_EACCESS: ::c_int = 0x200; pub const TCP_MD5SIG: ::c_int = 14; +pub const TCP_ULP: ::c_int = 31; align_const! { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { @@ -1262,6 +1263,15 @@ pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000; // netinet/in.h // NOTE: These are in addition to the constants defined in src/unix/mod.rs + +/// Multipath TCP +pub const IPPROTO_MPTCP: ::c_int = 262; +#[deprecated( + since = "0.2.79", + note = "IPPROTO_MAX depends on the kernel version on the target system" +)] +pub const IPPROTO_MAX: ::c_int = 263; + pub const AF_IB: ::c_int = 27; pub const AF_MPLS: ::c_int = 28; pub const AF_NFC: ::c_int = 39; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 08f7222ee9999..80c4f5bc0b7dd 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -869,7 +869,6 @@ pub const IPPROTO_UDPLITE: ::c_int = 136; pub const IPPROTO_MPLS: ::c_int = 137; /// raw IP packet pub const IPPROTO_RAW: ::c_int = 255; -pub const IPPROTO_MAX: ::c_int = 256; pub const MCAST_EXCLUDE: ::c_int = 0; pub const MCAST_INCLUDE: ::c_int = 1; From 7f2619fdf93581a2822a3f63035e05f55d0df8be Mon Sep 17 00:00:00 2001 From: George Hopkins Date: Sat, 24 Oct 2020 19:19:56 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Yuki Okushi --- src/unix/linux_like/linux/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 3494a13369f12..51a0e4b5ed2e6 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1267,10 +1267,12 @@ pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000; /// Multipath TCP pub const IPPROTO_MPTCP: ::c_int = 262; #[deprecated( - since = "0.2.79", - note = "IPPROTO_MAX depends on the kernel version on the target system" + since = "0.2.80", + note = "This value was increased in the newer kernel \ + and we'll change this following upstream in the future release. \ + See #1896 for more info." )] -pub const IPPROTO_MAX: ::c_int = 263; +pub const IPPROTO_MAX: ::c_int = 256; pub const AF_IB: ::c_int = 27; pub const AF_MPLS: ::c_int = 28;