# HG changeset patch # User Anthony Doeraene <anthony.doeraene....@gmail.com> # Date 1723532381 -7200 # Tue Aug 13 08:59:41 2024 +0200 # Node ID 19780d9b772a8b7192c20fc0fe7890dd381f0cce # Parent d5b3c722c6796f5b163821b9a8402457420ade4a Mail: added MPTCP support.
Multipath TCP (MPTCP), standardized in RFC8684 [1], is a TCP extension that enables a TCP connection to use different paths. Multipath TCP has been used for several use cases. On smartphones, MPTCP enables seamless handovers between cellular and Wi-Fi networks while preserving Established connections. This use-case is what pushed Apple to use MPTCP since 2013 in multiple applications [2]. On dual-stack hosts, Multipath TCP enables the TCP connection to automatically use the best performing path, either IPv4 or IPv6. If one path fails, MPTCP automatically uses the other path. The 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 [3]. To use it on Linux, an application must explicitly enable it when creating the socket. No need to change anything else in the application. Even if MPTCP is supported by different OS, only Linux supports the `IPPROTO_MPTCP` protocol, which is why this feature is currently limited to Linux only. This patch adds a new parameter 'multipath' to the 'listen' directive in the Mail module. Co-developed-by: Maxime Dourov <mu...@live.be> Link: https://www.rfc-editor.org/rfc/rfc8684.html [1] Link: https://www.tessares.net/apples-mptcp-story-so-far/ [2] Link: https://www.mptcp.dev [3] diff -r d5b3c722c679 -r 19780d9b772a src/mail/ngx_mail.c --- a/src/mail/ngx_mail.c Tue Aug 13 08:55:43 2024 +0200 +++ b/src/mail/ngx_mail.c Tue Aug 13 08:59:41 2024 +0200 @@ -332,6 +332,7 @@ ls->log.data = &ls->addr_text; ls->log.handler = ngx_accept_log_error; + ls->protocol = addr[i].opt.protocol; ls->backlog = addr[i].opt.backlog; ls->rcvbuf = addr[i].opt.rcvbuf; ls->sndbuf = addr[i].opt.sndbuf; diff -r d5b3c722c679 -r 19780d9b772a src/mail/ngx_mail.h --- a/src/mail/ngx_mail.h Tue Aug 13 08:55:43 2024 +0200 +++ b/src/mail/ngx_mail.h Tue Aug 13 08:59:41 2024 +0200 @@ -47,6 +47,7 @@ int tcp_keepintvl; int tcp_keepcnt; #endif + int protocol; int backlog; int rcvbuf; int sndbuf; diff -r d5b3c722c679 -r 19780d9b772a src/mail/ngx_mail_core_module.c --- a/src/mail/ngx_mail_core_module.c Tue Aug 13 08:55:43 2024 +0200 +++ b/src/mail/ngx_mail_core_module.c Tue Aug 13 08:59:41 2024 +0200 @@ -477,6 +477,13 @@ #endif } +#ifdef IPPROTO_MPTCP + if (ngx_strcmp(value[i].data, "multipath") == 0) { + ls->protocol = IPPROTO_MPTCP; + continue; + } +#endif + if (ngx_strncmp(value[i].data, "so_keepalive=", 13) == 0) { if (ngx_strcmp(&value[i].data[13], "on") == 0) {