Small patch to add support for MPTCP on Linux
- From
Muhammad Nuzaihan <zaihan@unrealasia.net>
- Date
- May 16, 2025, 17:56 UTC
- Message-ID
- <JH8DWS.72DKHPTI873H3@unrealasia.net>
Patch to enable the use of MPTCP on Linux (when available)
IPPROTO_MPTCP v1 (not the old v0) has been improved to go about the limitations of middleboxes.
MPTCP protocol is an extension of vanilla TCP which enables multiple IP to aggregate bandwidth at layer 4 of the OSI stack across as said IP(s).
Similar to link aggregation which works at layer 2. MPTCP works on top of IP layer.
Other than aggregating bandwidth, MPTCP also allows seamless failover when one network path (not just link) is down (or having high latency) by reinjecting the packets to a path that is available.
This patch enables IPPROTO_MPTCP if IPPROTO_MPTCP is available and uses plain TCP if the Linux system does not support it.
Signed-off-by: Muhammad Nuzaihan Bin Kamal Luddin <zaihan@unrealasia.net>
diff --git a/connect.c b/connect.c index 3280435331..8473f0b02e 100644 --- a/connect.c +++ b/connect.c @@ -827,8 +827,11 @@ static int git_tcp_connect_sock(char *host, int flags) else if (flags & CONNECT_IPV6) hints.ai_family = AF_INET6; hints.ai_socktype = SOCK_STREAM; - hints.ai_protocol = IPPROTO_TCP; - +#ifdef IPPROTO_MPTCP + hints.ai_protocol = IPPROTO_MPTCP; +#else + hints.ai_protocol = IPPROTO_TCP; +#endif if (flags & CONNECT_VERBOSE) fprintf(stderr, _("Looking up %s ... "), host);