Skip to content

Commit e0a4fb0

Browse files
committed
Auto merge of #1902 - george-hopkins:mptcp, r=JohnTitor
linux: Add definitions for Multipath TCP The Linux kernel recently gained support for [Multipath TCP](https://en.wikipedia.org/wiki/Multipath_TCP), a protocol which builds upon TCP. This patch adds `IPPROTO_MPTCP` to open new sockets and `TCP_ULP` to query the upper layer protocol of traditional TCP sockets (which is set to `mptcp` for all underlying connections) Source: [tcp: Define IPPROTO_MPTCP](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=faf391c3826cd29feae02078ca2022d2f912f7cc) cc #1896
2 parents 7b0b5f8 + 7f2619f commit e0a4fb0

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

libc-test/build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2613,6 +2613,10 @@ fn test_linux(target: &str) {
26132613
// Require Linux kernel 5.6:
26142614
"VMADDR_CID_LOCAL" => true,
26152615

2616+
// IPPROTO_MAX was increased in 5.6 for IPPROTO_MPTCP:
2617+
| "IPPROTO_MAX"
2618+
| "IPPROTO_MPTCP" => true,
2619+
26162620
// Defined in kernel headers but musl removes it; need musl 1.2 for definition in musl
26172621
// headers.
26182622
"P_PIDFD" => true,

src/unix/linux_like/android/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,8 @@ pub const SOCK_SEQPACKET: ::c_int = 5;
10251025
pub const SOCK_DCCP: ::c_int = 6;
10261026
pub const SOCK_PACKET: ::c_int = 10;
10271027

1028+
pub const IPPROTO_MAX: ::c_int = 256;
1029+
10281030
pub const SOL_SOCKET: ::c_int = 1;
10291031
pub const SOL_SCTP: ::c_int = 132;
10301032
pub const SOL_IPX: ::c_int = 256;
@@ -1085,6 +1087,8 @@ pub const SO_RXQ_OVFL: ::c_int = 40;
10851087
pub const SO_PEEK_OFF: ::c_int = 42;
10861088
pub const SO_BUSY_POLL: ::c_int = 46;
10871089

1090+
pub const TCP_ULP: ::c_int = 31;
1091+
10881092
pub const IPTOS_ECN_NOTECT: u8 = 0x00;
10891093

10901094
pub const O_ACCMODE: ::c_int = 3;

src/unix/linux_like/emscripten/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,8 @@ pub const SOCK_STREAM: ::c_int = 1;
15571557
pub const SOCK_DGRAM: ::c_int = 2;
15581558
pub const SOCK_SEQPACKET: ::c_int = 5;
15591559

1560+
pub const IPPROTO_MAX: ::c_int = 256;
1561+
15601562
pub const SOL_SOCKET: ::c_int = 1;
15611563

15621564
pub const SO_REUSEADDR: ::c_int = 2;

src/unix/linux_like/linux/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,7 @@ pub const RTLD_NOW: ::c_int = 0x2;
12401240
pub const AT_EACCESS: ::c_int = 0x200;
12411241

12421242
pub const TCP_MD5SIG: ::c_int = 14;
1243+
pub const TCP_ULP: ::c_int = 31;
12431244

12441245
align_const! {
12451246
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
@@ -1274,6 +1275,17 @@ pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000;
12741275

12751276
// netinet/in.h
12761277
// NOTE: These are in addition to the constants defined in src/unix/mod.rs
1278+
1279+
/// Multipath TCP
1280+
pub const IPPROTO_MPTCP: ::c_int = 262;
1281+
#[deprecated(
1282+
since = "0.2.80",
1283+
note = "This value was increased in the newer kernel \
1284+
and we'll change this following upstream in the future release. \
1285+
See #1896 for more info."
1286+
)]
1287+
pub const IPPROTO_MAX: ::c_int = 256;
1288+
12771289
pub const AF_IB: ::c_int = 27;
12781290
pub const AF_MPLS: ::c_int = 28;
12791291
pub const AF_NFC: ::c_int = 39;

src/unix/linux_like/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,6 @@ pub const IPPROTO_UDPLITE: ::c_int = 136;
869869
pub const IPPROTO_MPLS: ::c_int = 137;
870870
/// raw IP packet
871871
pub const IPPROTO_RAW: ::c_int = 255;
872-
pub const IPPROTO_MAX: ::c_int = 256;
873872

874873
pub const MCAST_EXCLUDE: ::c_int = 0;
875874
pub const MCAST_INCLUDE: ::c_int = 1;

0 commit comments

Comments
 (0)