summaryrefslogtreecommitdiffhomepage
path: root/src/mail
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@nginx.com>2025-10-16 15:22:56 +0000
committerSergey Kandaurov <s.kandaurov@f5.com>2026-03-19 01:13:51 +0400
commit920dc099c130e0ea23eb36becd157a95901aa5a2 (patch)
tree087aa0949e69c5196c325baa49f38603e7a8a1fc /src/mail
parenta29476464cc86092135401bdcad91e4d38ac6b6d (diff)
downloadnginx-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/mail')
-rw-r--r--src/mail/ngx_mail.c1
-rw-r--r--src/mail/ngx_mail.h1
-rw-r--r--src/mail/ngx_mail_core_module.c12
3 files changed, 14 insertions, 0 deletions
diff --git a/src/mail/ngx_mail.c b/src/mail/ngx_mail.c
index 890d8153a..cc34cb365 100644
--- a/src/mail/ngx_mail.c
+++ b/src/mail/ngx_mail.c
@@ -332,6 +332,7 @@ ngx_mail_optimize_servers(ngx_conf_t *cf, ngx_array_t *ports)
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 --git a/src/mail/ngx_mail.h b/src/mail/ngx_mail.h
index e0c62b7ab..221faf67d 100644
--- a/src/mail/ngx_mail.h
+++ b/src/mail/ngx_mail.h
@@ -47,6 +47,7 @@ typedef struct {
int tcp_keepintvl;
int tcp_keepcnt;
#endif
+ int protocol;
int backlog;
int rcvbuf;
int sndbuf;
diff --git a/src/mail/ngx_mail_core_module.c b/src/mail/ngx_mail_core_module.c
index 228a8d0a8..5532ceeb1 100644
--- a/src/mail/ngx_mail_core_module.c
+++ b/src/mail/ngx_mail_core_module.c
@@ -447,6 +447,18 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
#endif
}
+ if (ngx_strcmp(value[i].data, "multipath") == 0) {
+#ifdef IPPROTO_MPTCP
+ ls->protocol = IPPROTO_MPTCP;
+ ls->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_MAIL_SSL)
ngx_mail_ssl_conf_t *sslcf;