Fix --mptcp on kernels with mainlined MPTCP.

Mainlined MPTCP on Linux 5.6+ is enabled with IPPROTO_MPTCP rather than setsockopt.
This commit is contained in:
Tristan Schmelcher
2022-05-23 09:11:50 +08:00
committed by Max Lv
parent e21f8248b6
commit 1630764b02
5 changed files with 38 additions and 4 deletions
+9 -1
View File
@@ -594,7 +594,13 @@ create_and_bind(const char *host, const char *port, int mptcp)
}
for (/*rp = result*/; rp != NULL; rp = rp->ai_next) {
listen_sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
int protocol = rp->ai_protocol;
#ifdef IPPROTO_MPTCP
if (mptcp == 1) {
protocol = IPPROTO_MPTCP;
}
#endif
listen_sock = socket(rp->ai_family, rp->ai_socktype, protocol);
if (listen_sock == -1) {
continue;
}
@@ -616,6 +622,7 @@ create_and_bind(const char *host, const char *port, int mptcp)
}
}
#ifndef IPPROTO_MPTCP
if (mptcp == 1) {
int i = 0;
while ((mptcp = mptcp_enabled_values[i]) > 0) {
@@ -629,6 +636,7 @@ create_and_bind(const char *host, const char *port, int mptcp)
ERROR("failed to enable multipath TCP");
}
}
#endif
s = bind(listen_sock, rp->ai_addr, rp->ai_addrlen);
if (s == 0) {