Re: PATCH v3 [1/1]: MPTCP support for Git on Linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

This code below in v2:

+#if defined(__linux__) && defined(IPPROTO_MPTCP)
+ if (mptcp)
+ hints.ai_protocol = IPPROTO_MPTCP;
+ else
+ hints.ai_protocol = IPPROTO_MPTCP;
+#else
+ hints.ai_protocol = IPPROTO_TCP;
+#endif

Has a small bug, which i realised in the v2 patch while debugging the
traffic with wireshark.

So i'm correcting this minor mistake where the else statement
should fallback to regular TCP if flag is disabled in v3:

+#if defined(__linux__) && defined(IPPROTO_MPTCP)
+ if (mptcp)
+ hints.ai_protocol = IPPROTO_MPTCP;
+ else
+ hints.ai_protocol = IPPROTO_TCP;
+#else
+ hints.ai_protocol = IPPROTO_TCP;
+#endif

Changes in v3:
- fix a bug with regards to mptcp flag should switch to regular TCP if false.

Changes in v2:
- Check for whether git is being built for Linux and also if it's on Linux, check if
 IPPROTO_MPTCP exists in both connect.c (client) and daemon.c (server)
- Check for whether the glibc version support IPPROTO_MPTCP in getaddrinfo() function, old versions of glibc does not support this even though header definitions netinet/in.h had already for years. Running getaddinfo() will return EAI_SOCKTYPE error
 if IPPROTO_MPTCP is not supported and we fallback to regular TCP.
- In both client side (connect.c) and server side (daemon.c) check if socket() supports IPPROTO_MPTCP if the git is built in Linux including checks for version 5.6
 and above and below 5.6 for proper error return values,
 else skip and run regular TCP (IPPROTO_TCP)
- Add client side enable/diable environment variable option GIT_ENABLE_MPTCP
 for client side (connect.c) to enable/disable MPTCP on client side.
- Add git server side enable/disable flag "--mptcp" to enable or disable server/side MPTCP.

Link to v2: https://lore.kernel.org/git/6O0FWS.8JJP67DO2U1M1@xxxxxxxxxxxxxx/T/#u Link to v1: https://lore.kernel.org/git/a76dda61-f60c-4221-83db-5e165a2478b1@xxxxxxxxx/T/#t

Signed-off-by: Muhammad Nuzaihan Bin Kamal Luddin
<zaihan@xxxxxxxxxxxxxx>

On Sun, May 18 2025 at 01:02:30 AM +0800, Muhammad Nuzaihan <zaihan@xxxxxxxxxxxxxx> wrote:
Hi,

This patch is about Multi-Path TCP.

Multi-Path TCP (MPTCP) had been in development for the past 15 years
which started with MPTCP v0 (version 0) which initially had issues
for middleboxes and NAT Gateways.

The current iteration is MPTCP v1 which has a fallback mechanism to
regular
TCP to avoid issues with middleboxes and NAT Gateways.

Started to add this code change as a need as i have large git codebases
with around 50 gigabytes and i have multiple WAN links which i can
aggregate
bandwidth across and even when network one path (even in between my
CPE router
to internet) is down, i will not get interrupted.

Also i am using a Linux laptop that has WiFi and 5G module. So this kind
of adds my reason of adding support for git (on Linux)

To get MPTCP to be fully working, both ends of client and server must
implement
MPTCP.

My implementation adds support for the basic git protocol.

MPTCP helps in situations when one of my WAN links have a high latency
and
automatically choose a link with a path with less latency.

Also, MPTCP aggregates the MPTCP connection by using subflows where two
or more
links can be utilised with subflows. A single flow of data can have
multiple
subflows across different IP interfaces and thus increases network
throughput.

Apple for example had been using MPTCP for their cloud services since
MPTCP v0
which had issues with middleboxes (not MPTCP v1) since 2013.

The downside, even though i had never experienced it for other
applications
on Linux like Google Chromium[1], is that the fallback might induce
delays
in connectivity, if i've read it somewhere which i cannot recall where.

How this patch works:

This patch enables MPTCP protocol option only when it's built on Linux
with
IPPROTO_MPTCP support in netinet/in.h.

On Linux, if IPPROTO_MPTCP is not defined in netinet/in.h, it will
skipped.

IPPROTO_MPTCP should and never be enabled when it detects being built on
an OS other than Linux with defined(__linux__) check.

Another challenge is that although "getaddrinfo()" is a POSIX function,
not all glibc "getaddrinfo()" implementation is written with
IPPROTO_MPTCP support out of the box, especially on older glibc
versions.

getaddrinfo() IPPROTO_MPTCP support had only been added to recent glibc
in 2025 eventhough IPPROTO_MPTCP definition had been around for
much longer in netinet/in.h.

So we run getaddrinfo() which is a code in glibc and check for errors,
specifically "EAI_SOCKTYPE" return value which tells us that the socket
type
is not supported and fallback to regular TCP (IPPROTO_TCP)

Also we will also check that we are building on Linux and depending on
version number of Linux we will initialize the socket() accordingly and
if
there is an error return value (like
EINVAL/EPROTONOSUPPORT/ENOPROTOOPT),
we will fall back to regular TCP.

Enabling and disabling MPTCP:

By default on the client side, MPTCP will not be enabled in git client,
however MPTCP
can be enabled by setting an environment variable "GIT_ENABLE_MPTCP" to
any value.

Persisting the configuration can be done in your shell.

Also for server side git server (daemon.c), there is a flag to
optionally
enable mptcp with "--mptcp", example:

git-daemon --base-path=/all/my/repos --export-all --mptcp

This will tell the git server daemon to accept mptcp connections but
fallback to regular tcp when mptcp connection is not available.

PS: Can someone point me about having a "knob" in Makefile or is this
already sufficient?

[1] https://chromium-review.googlesource.com/c/chromium/src/+/6355767

Signed-off-by: Muhammad Nuzaihan Bin Kamal Luddin
<zaihan@xxxxxxxxxxxxxx>







[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux