diff --git a/cache.h b/cache.h index eba12487b9..6839b3acbc 100644 --- a/cache.h +++ b/cache.h @@ -944,6 +944,7 @@ extern int verify_ce_order; /* Environment bits from configuration mechanism */ extern int trust_executable_bit; +extern int enable_mptcp; extern int trust_ctime; extern int check_stat; extern int quote_path_fully; diff --git a/config.c b/config.c index 2317a76696..833396aa4b 100644 --- a/config.c +++ b/config.c @@ -1464,6 +1464,11 @@ static int git_default_core_config(const char *var, const char *value, void *cb) if (!strcmp(var, "core.editor")) return git_config_string(&editor_program, var, value); + if (!strcmp(var, "core.mptcp")) { + enable_mptcp = git_config_bool(var, value); + return 0; + } + if (!strcmp(var, "core.commentchar")) { if (!value) return config_error_nonbool(var); diff --git a/connect.c b/connect.c index eaf7d6d261..ebeac99bd6 100644 --- a/connect.c +++ b/connect.c @@ -721,6 +721,16 @@ static void enable_keepalive(int sockfd) error_errno(_("unable to set SO_KEEPALIVE on socket")); } +static const int needs_mptcp(void) +{ + int mptcp = 0; + + if (git_config_get_bool("core.mptcp", &mptcp)) + return mptcp; + + return mptcp; +} + #ifndef NO_IPV6 static const char *ai_name(const struct addrinfo *ai) @@ -770,7 +780,11 @@ static int git_tcp_connect_sock(char *host, int flags) for (ai0 = ai; ai; ai = ai->ai_next, cnt++) { sockfd = socket(ai->ai_family, - ai->ai_socktype, ai->ai_protocol); + ai->ai_socktype, +#ifdef IPPROTO_MPTCP + needs_mptcp() ? IPPROTO_MPTCP : +#endif + ai->ai_protocol); if ((sockfd < 0) || (connect(sockfd, ai->ai_addr, ai->ai_addrlen) < 0)) { strbuf_addf(&error_message, "%s[%d: %s]: errno=%s\n", @@ -817,6 +831,7 @@ static int git_tcp_connect_sock(char *host, int flags) char **ap; unsigned int nport; int cnt; + const int needs_mptcp; get_host_and_port(&host, &port); diff --git a/daemon.c b/daemon.c index b1fcbe0d6f..08a16ccf03 100644 --- a/daemon.c +++ b/daemon.c @@ -17,6 +17,7 @@ static enum log_destination { } log_destination = LOG_DESTINATION_UNSET; static int verbose; static int reuseaddr; +static int mptcp; static int informative_errors; static const char daemon_usage[] = @@ -1007,6 +1008,10 @@ static int setup_named_sock(char *listen_addr, int listen_port, struct socketlis for (ai = ai0; ai; ai = ai->ai_next) { int sockfd; +#if defined(__linux__) && defined(IPPROTO_MPTCP) + sockfd = socket(ai->ai_family, ai->ai_socktype, IPPROTO_MPTCP); + if (sockfd < 0) +#endif sockfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (sockfd < 0) continue; @@ -1360,6 +1365,10 @@ int cmd_main(int argc, const char **argv) reuseaddr = 1; continue; } + if (!strcmp(arg, "--mptcp")) { + mptcp = 1; + continue; + } if (!strcmp(arg, "--user-path")) { user_path = ""; continue; diff --git a/environment.c b/environment.c index 9da7f3c1a1..72f1adef6c 100644 --- a/environment.c +++ b/environment.c @@ -33,6 +33,7 @@ int warn_ambiguous_refs = 1; int warn_on_object_refname_ambiguity = 1; int repository_format_precious_objects; int repository_format_worktree_config; +int enable_mptcp; const char *git_commit_encoding; const char *git_log_output_encoding; char *apply_default_whitespace;