Skip to content

Commit

Permalink
[core] disable MPTCP support by default
Browse files Browse the repository at this point in the history
Matthieu Baerts notes:
MPTCP is currently not compatible with KTLS: they both use the
same technique to extend TCP behaviour in the kernel (TCP ULP).

Disable network_mptcp if socket() IPPROTO_MPTCP fails and omit trace,
since it probably indicates MPTCP support is not available, and lighttpd
transparently falls back to IPPROTO_TCP.

Matthieu Baerts notes:
Creating a socket with IPPROTO_MPTCP may fail with
ENOPROTOOPT (Protocol not available: linked to net.mptcp.enabled sysctl)
EPROTONOSUPPORT (Protocol not supported: MPTCP not compiled on >= v5.6)
EINVAL (Invalid argument: MPTCP is not available on kernels < 5.6).

If socket() failed for other reasons, then the socket() IPPROTO_TCP
fallback which immediately follows will likely fail the same way and
lighttpd will error out.

x-ref:
  "[core] add MPTCP support"
  #132

github: closes #132
  • Loading branch information
gstrauss committed Mar 18, 2024
1 parent 4eeedbb commit 4ebc8af
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#define unsetenv(name) _putenv_s((name), "")
#endif

static int network_mptcp = 0;

void
network_accept_tcp_nagle_disable (const int fd)
{
Expand Down Expand Up @@ -541,13 +543,15 @@ static int network_server_init(server *srv, const network_socket_config *s, buff
#endif
{
#ifdef __linux__
if (config_feature_bool(srv, "server.network-mptcp", 1)) {
if (network_mptcp) {
/* manually define mptcp protocol number in case the compiler is using an older version of libc */
#ifndef IPPROTO_MPTCP
#define IPPROTO_MPTCP 262
#endif
if (-1 == (srv_socket->fd = fdevent_socket_nb_cloexec(family, SOCK_STREAM, IPPROTO_MPTCP)))
if (-1 == (srv_socket->fd = fdevent_socket_nb_cloexec(family, SOCK_STREAM, IPPROTO_MPTCP))) {
log_pdebug(srv->errh, __FILE__, __LINE__, "socket() IPPROTO_MPTCP");
network_mptcp = 0;
}
}
if (-1 != srv_socket->fd) { } else /*fallback to tcp*/
#endif
Expand Down Expand Up @@ -831,6 +835,8 @@ int network_init(server *srv, int stdin_fd) {
network_merge_config(&p->defaults, cpv);
}

network_mptcp = config_feature_bool(srv, "server.network-mptcp", 0);

if (config_feature_bool(srv, "server.graceful-restart-bg", 0))
srv->srvconf.systemd_socket_activation = 1;

Expand Down

0 comments on commit 4ebc8af

Please sign in to comment.