core/socket: allow MPTCP protocol
authorMatthieu Baerts (NGI0) <matttbe@kernel.org>
Mon, 20 May 2024 16:37:17 +0000 (18:37 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 11 Jun 2024 23:14:08 +0000 (00:14 +0100)
commit3f69070598b569bf20f5c296ff21f861bfe003e3
treee21dc2a06a38a1744936936955ca8534211939c5
parent608bfe76c18ea4ecda0a78a243363eebae032243
core/socket: allow MPTCP protocol

Multipath TCP (MPTCP), standardized in RFC8684 [1], is a TCP extension
that enables a TCP connection to use different paths. It allows a device
to make use of multiple interfaces at once to send and receive TCP
packets over a single MPTCP connection. MPTCP can aggregate the
bandwidth of multiple interfaces or prefer the one with the lowest
latency, it also allows a fail-over if one path is down, and the traffic
is seamlessly re-injected on other paths.

To benefit from MPTCP, both the client and the server have to support
it. Multipath TCP is a backward-compatible TCP extension that is enabled
by default on recent Linux distributions (Debian, Ubuntu, Redhat, ...).
Multipath TCP is included in the Linux kernel since version 5.6 [2]. To
use it on Linux, an application must explicitly enable it when creating
the socket:

  int sd = socket(AF_INET(6), SOCK_STREAM, IPPROTO_MPTCP);

No need to change anything else in the application.

This patch allows MPTCP protocol in the Socket unit configuration. So
now, a <unit>.socket can contain this to use MPTCP instead of TCP:

  [Socket]
  SocketProtocol=mptcp

MPTCP support has been allowed similarly to what has been already done
to allow SCTP: just one line in core/socket.c, a very simple addition
thanks to the flexible architecture already in place.

On top of that, IPPROTO_MPTCP has also been added in the list of allowed
protocols in two other places, and in the doc. It has also been added to
the missing_network.h file, for systems with an old libc -- note that it
was also required to include <netinet/in.h> in this file to avoid
redefinition errors.

Link: https://www.rfc-editor.org/rfc/rfc8684.html
Link: https://www.mptcp.dev
man/systemd.socket.xml
src/basic/missing_network.h
src/core/dbus-socket.c
src/core/load-fragment.c
src/core/socket.c
src/test/test-ip-protocol-list.c
test/fuzz/fuzz-unit-file/syslog.socket