Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multipath TCP patches from BZ 69292 #476

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/manual/mod/mod_proxy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,10 @@ ProxyPass "/example" "http://backend.example.com" max=20 ttl=120 retry=300
<td><p>TTL in seconds for how long DNS resolutions of the backend address are cached.
-1 means until restart of Apache httpd.</p>
</td></tr>
<tr><td><a id="multipathtcp" name="multipathtcp">multipathtcp</a></td>
<td>Off</td>
<td><p>Enable/disable the use of <a href="https://mptcp.dev">Multipath TCP (MPTCP)</a></p>
</td></tr>

</table>

Expand Down
6 changes: 6 additions & 0 deletions docs/manual/mod/mpm_common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ Listen 192.170.2.5:8000
to the same port. (If the server is built with IPv4-mapped
addresses <em>disabled</em>, this is the default behaviour and
this option has no effect.)</li>

<li><code>multipathtcp</code>: Enable the use of
<a href="https://mptcp.dev">Multipath TCP (MPTCP)</a> for the
sockets. Beware that this option is currently limited to Linux
only.
</li>
</ul>

<note><title>Error condition</title>
Expand Down
1 change: 1 addition & 0 deletions include/ap_listen.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ typedef apr_status_t (*accept_function)(void **csd, ap_listen_rec *lr, apr_pool_
#define AP_LISTEN_FREEBIND (0x0002)
#define AP_LISTEN_REUSEPORT (0x0004)
#define AP_LISTEN_V6ONLY (0x0008)
#define AP_LISTEN_MPTCP (0x0010)

/**
* @brief Apache's listeners record.
Expand Down
12 changes: 12 additions & 0 deletions modules/proxy/mod_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,18 @@ static const char *set_worker_param(apr_pool_t *p,
worker->s->response_field_size = (s ? s : HUGE_STRING_LEN);
worker->s->response_field_size_set = 1;
}
else if (!strcasecmp(key, "multipathtcp")) {
#ifdef IPPROTO_MPTCP
if (!strcasecmp(val, "On"))
worker->s->sock_proto = IPPROTO_MPTCP;
else if (!strcasecmp(val, "Off"))
worker->s->sock_proto = APR_PROTO_TCP;
else
return "multipathtcp must be On|Off";
#else
return "multipathtcp is not supported on your platform";
#endif
}
else {
if (set_worker_hc_param_f) {
return set_worker_hc_param_f(p, s, worker, key, val, NULL);
Expand Down
1 change: 1 addition & 0 deletions modules/proxy/mod_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ typedef struct {
unsigned int address_ttl_set:1;
apr_int32_t address_ttl; /* backend address' TTL (seconds) */
apr_uint32_t address_expiry; /* backend address' next expiry time */
int sock_proto; /* The protocol to use to create the socket */
} proxy_worker_shared;

#define ALIGNED_PROXY_WORKER_SHARED_SIZE (APR_ALIGN_DEFAULT(sizeof(proxy_worker_shared)))
Expand Down
2 changes: 1 addition & 1 deletion modules/proxy/proxy_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3858,7 +3858,7 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
#endif
{
if ((rv = apr_socket_create(&newsock, backend_addr->family,
SOCK_STREAM, APR_PROTO_TCP,
SOCK_STREAM, worker->s->sock_proto,
conn->scpool)) != APR_SUCCESS) {
loglevel = backend_addr->next ? APLOG_DEBUG : APLOG_ERR;
ap_log_error(APLOG_MARK, loglevel, rv, s, APLOGNO(00952)
Expand Down
22 changes: 20 additions & 2 deletions server/listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,12 @@ static const char *alloc_listener(process_rec *process, const char *addr,

while (sa) {
ap_listen_rec *new;
int sock_proto = 0;

#ifdef IPPROTO_MPTCP
if (flags & AP_LISTEN_MPTCP)
sock_proto = IPPROTO_MPTCP;
#endif

/* this has to survive restarts */
new = apr_palloc(process->pool, sizeof(ap_listen_rec));
Expand All @@ -509,7 +515,7 @@ static const char *alloc_listener(process_rec *process, const char *addr,
sa = sa->next;

status = apr_socket_create(&new->sd, new->bind_addr->family,
SOCK_STREAM, 0, process->pool);
SOCK_STREAM, sock_proto, process->pool);

#if APR_HAVE_IPV6
/* What could happen is that we got an IPv6 address, but this system
Expand Down Expand Up @@ -864,6 +870,7 @@ AP_DECLARE(apr_status_t) ap_duplicate_listeners(apr_pool_t *p, server_rec *s,
char *hostname;
apr_port_t port;
apr_sockaddr_t *sa;
int sock_proto = 0;
#ifdef HAVE_SYSTEMD
if (use_systemd) {
int thesock;
Expand Down Expand Up @@ -891,8 +898,12 @@ AP_DECLARE(apr_status_t) ap_duplicate_listeners(apr_pool_t *p, server_rec *s,
duplr->bind_addr = sa;
duplr->next = NULL;
duplr->flags = lr->flags;
#ifdef IPPROTO_MPTCP
if (duplr->flags & AP_LISTEN_MPTCP)
sock_proto = IPPROTO_MPTCP;
#endif
stat = apr_socket_create(&duplr->sd, duplr->bind_addr->family,
SOCK_STREAM, 0, p);
SOCK_STREAM, sock_proto, p);
if (stat != APR_SUCCESS) {
ap_log_perror(APLOG_MARK, APLOG_CRIT, 0, p, APLOGNO(02640)
"ap_duplicate_listeners: for address %pI, "
Expand Down Expand Up @@ -1038,6 +1049,13 @@ static const char *parse_listen_flags(apr_pool_t *temp_pool, const char *arg,
flags |= AP_LISTEN_REUSEPORT;
else if (ap_cstr_casecmp(token, "v6only") == 0)
flags |= AP_LISTEN_V6ONLY;
else if (ap_cstr_casecmp(token, "multipathtcp") == 0)
#ifdef IPPROTO_MPTCP
flags |= AP_LISTEN_MPTCP;
#else
return apr_psprintf(temp_pool, "Listen option '%s' in '%s' is not supported on this system",
token, arg);
#endif
else
return apr_psprintf(temp_pool, "Unknown Listen option '%s' in '%s'",
token, arg);
Expand Down
Loading