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/stream | |
| 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/stream')
| -rw-r--r-- | src/stream/ngx_stream.c | 1 | ||||
| -rw-r--r-- | src/stream/ngx_stream.h | 1 | ||||
| -rw-r--r-- | src/stream/ngx_stream_core_module.c | 19 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/stream/ngx_stream.c b/src/stream/ngx_stream.c index b6eeb23af..508ce6082 100644 --- a/src/stream/ngx_stream.c +++ b/src/stream/ngx_stream.c @@ -1010,6 +1010,7 @@ ngx_stream_add_listening(ngx_conf_t *cf, ngx_stream_conf_addr_t *addr) ls->log.handler = ngx_accept_log_error; 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/stream/ngx_stream.h b/src/stream/ngx_stream.h index dc05dc5ba..9bc689e99 100644 --- a/src/stream/ngx_stream.h +++ b/src/stream/ngx_stream.h @@ -62,6 +62,7 @@ typedef struct { int rcvbuf; int sndbuf; int type; + int protocol; #if (NGX_HAVE_SETFIB) int setfib; #endif diff --git a/src/stream/ngx_stream_core_module.c b/src/stream/ngx_stream_core_module.c index a09c7c634..6556c5a73 100644 --- a/src/stream/ngx_stream_core_module.c +++ b/src/stream/ngx_stream_core_module.c @@ -1202,6 +1202,19 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) continue; } + if (ngx_strcmp(value[i].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[i].data, "ssl") == 0) { #if (NGX_STREAM_SSL) lsopt.ssl = 1; @@ -1338,6 +1351,12 @@ ngx_stream_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 \"udp\""; + } +#endif + #if (NGX_STREAM_SSL) if (lsopt.ssl) { return "\"ssl\" parameter is incompatible with \"udp\""; |
