diff options
| author | Sergey Kandaurov <pluknet@nginx.com> | 2025-10-16 15:22:56 +0000 |
|---|---|---|
| committer | Sergey Kandaurov <s.kandaurov@f5.com> | 2026-03-19 01:13:51 +0400 |
| commit | 920dc099c130e0ea23eb36becd157a95901aa5a2 (patch) | |
| tree | 087aa0949e69c5196c325baa49f38603e7a8a1fc /src/http | |
| parent | a29476464cc86092135401bdcad91e4d38ac6b6d (diff) | |
| download | nginx-920dc099c130e0ea23eb36becd157a95901aa5a2.tar.gz nginx-920dc099c130e0ea23eb36becd157a95901aa5a2.tar.bz2 | |
The "multipath" parameter of the "listen" directive.
When configured, it enables Multipath TCP support on a listen socket.
As of now it works on Linux starting with Linux 5.6 and glibc 2.32,
where it is enabled with an IPPROTO_MPTCP socket(2) protocol.
To avoid EADDRINUSE errors in bind() and listen() when transitioning
between sockets with different protocols, SO_REUSEPORT is set on both
sockets. See f7f1607bf for potential implications.
Based on previous work by Maxime Dourov and Anthony Doeraene.
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/ngx_http.c | 1 | ||||
| -rw-r--r-- | src/http/ngx_http_core_module.c | 19 | ||||
| -rw-r--r-- | src/http/ngx_http_core_module.h | 1 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c index 7f2b4225a..a97cc35f1 100644 --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -1846,6 +1846,7 @@ ngx_http_add_listening(ngx_conf_t *cf, ngx_http_conf_addr_t *addr) #endif ls->type = addr->opt.type; + ls->protocol = addr->opt.protocol; ls->backlog = addr->opt.backlog; ls->rcvbuf = addr->opt.rcvbuf; ls->sndbuf = addr->opt.sndbuf; diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index c75ddb849..a2ff53f82 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -4223,6 +4223,19 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) continue; } + if (ngx_strcmp(value[n].data, "multipath") == 0) { +#ifdef IPPROTO_MPTCP + lsopt.protocol = IPPROTO_MPTCP; + lsopt.set = 1; + lsopt.bind = 1; +#else + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "multipath is not supported " + "on this platform, ignored"); +#endif + continue; + } + if (ngx_strcmp(value[n].data, "ssl") == 0) { #if (NGX_HTTP_SSL) lsopt.ssl = 1; @@ -4389,6 +4402,12 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } #endif +#ifdef IPPROTO_MPTCP + if (lsopt.protocol == IPPROTO_MPTCP) { + return "\"multipath\" parameter is incompatible with \"quic\""; + } +#endif + #if (NGX_HTTP_SSL) if (lsopt.ssl) { return "\"ssl\" parameter is incompatible with \"quic\""; diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index 9be565373..6062d3a23 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -88,6 +88,7 @@ typedef struct { int rcvbuf; int sndbuf; int type; + int protocol; #if (NGX_HAVE_SETFIB) int setfib; #endif |
