- Notifications
You must be signed in to change notification settings - Fork7.7k
Multipath TCP support#931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
When configured, enables Multipath TCP support on a listen socket.Multipath TCP (MPTCP), standardized in RFC 8684, is enabled with aseparate IPPROTO_MPTCP socket(2) protocol. As of now it works onLinux starting with Linux 5.6 and glibc 2.32.To avoid EADDRINUSE errors in bind() and listen() when transitioningbetween sockets with different protocols, SO_REUSEPORT is temporarilyset on both sockets. Seef7f1607 for potential implications.Based on previous work by Maxime Dourov and Anthony Doeraene.
pluknet commentedOct 24, 2025
Changes: getsockopt(SO_PROTOCOL) moved under SOCK_STREAM |
| #if (NGX_HAVE_REUSEPORT) | ||
| if (!ls[i].reuseport&&ls[i].change_protocol&& !ngx_test_config) { | ||
| if (ngx_noreuseport(s)==-1) { | ||
| ngx_log_error(NGX_LOG_EMERG,log,ngx_socket_errno, | ||
| ngx_noreuseport_n" %V failed", | ||
| &ls[i].addr_text); | ||
| if (ngx_close_socket(s)==-1) { | ||
| ngx_log_error(NGX_LOG_EMERG,log,ngx_socket_errno, | ||
| ngx_close_socket_n" %V failed", | ||
| &ls[i].addr_text); | ||
| } | ||
| returnNGX_ERROR; | ||
| } | ||
| } | ||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What's the point in resetting the reuseport option here?
BTW, when switching from a reuseport-enabled to no-reuseport listen, we do not reset the reuseport flag socket option.
| ls[i].remain=1; | ||
| if (ls[i].protocol!=nls[n].protocol) { | ||
| nls[n].change_protocol=1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Here, we first inheritfd and then rewrite it inngx_open_listening_sockets(). It means that we need to be careful when handling errors below. If an error happens before the rewrite, thefd should be ignored (this actually happens now, see theopen flag below). However, if an error happens after the rewrite, the newfd should be closed. The latter does not happen since multipath listenings havels->open == 0 . This will lead to a socket leak.
| if (ngx_strcmp(value[n].data,"multipath")==0) { | ||
| #ifdefIPPROTO_MPTCP | ||
| lsopt.protocol=IPPROTO_MPTCP; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Shouldn't it be a socket parameter (set flag) ? Not sure aboutbind, it may also be needed.
this adds a preparatory change to reduce diff, where appropriate, and therefore deduplicate the main change