From: Muhammad Nuzaihan <zaihan@unrealasia.net>
To: git@vger.kernel.org
Cc: "phillip.wood" <phillip.wood@dunelm.org.uk>,
"brian m. carlson" <sandals@crustytoothpaste.net>
Subject: Re: PATCH v3 [1/1]: MPTCP support for Git on Linux
Date: Sun, 18 May 2025 02:30:45 +0800 [thread overview]
Message-ID: <9R4FWS.9NR30V555Q5S@unrealasia.net> (raw)
In-Reply-To: <6O0FWS.8JJP67DO2U1M1@unrealasia.net>
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@unrealasia.net/T/#u
Link to v1:
https://lore.kernel.org/git/a76dda61-f60c-4221-83db-5e165a2478b1@gmail.com/T/#t
Signed-off-by: Muhammad Nuzaihan Bin Kamal Luddin
<zaihan@unrealasia.net>
On Sun, May 18 2025 at 01:02:30 AM +0800, Muhammad Nuzaihan
<zaihan@unrealasia.net> 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@unrealasia.net>
>
next prev parent reply other threads:[~2025-05-17 18:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-17 17:02 PATCH v2 [1/1]: MPTCP support for Git on Linux Muhammad Nuzaihan
2025-05-17 18:30 ` Muhammad Nuzaihan [this message]
2025-05-17 18:46 ` Junio C Hamano
2025-05-17 19:25 ` Muhammad Nuzaihan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9R4FWS.9NR30V555Q5S@unrealasia.net \
--to=zaihan@unrealasia.net \
--cc=git@vger.kernel.org \
--cc=phillip.wood@dunelm.org.uk \
--cc=sandals@crustytoothpaste.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).