aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dgilbert@redhat.com>2021-04-21 12:28:34 +0100
committerDr. David Alan Gilbert <dgilbert@redhat.com>2021-06-08 19:36:22 +0100
commit8bd1078aebcec5eac196a83ef1a7e74be0ba67b7 (patch)
tree324d7a50afc3362698b9bb56363159b7b3a2eeb4
parenta59136f3b126cfbcaa13a44fbdaf8df6e3d1885f (diff)
sockets: Support multipath TCP
Multipath TCP allows combining multiple interfaces/routes into a single socket, with very little work for the user/admin. It's enabled by 'mptcp' on most socket addresses: ./qemu-system-x86_64 -nographic -incoming tcp:0:4444,mptcp Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-Id: <20210421112834.107651-6-dgilbert@redhat.com> Acked-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
-rw-r--r--io/dns-resolver.c4
-rw-r--r--qapi/sockets.json5
-rw-r--r--util/qemu-sockets.c23
3 files changed, 31 insertions, 1 deletions
diff --git a/io/dns-resolver.c b/io/dns-resolver.c
index 743a0efc87..a5946a93bf 100644
--- a/io/dns-resolver.c
+++ b/io/dns-resolver.c
@@ -122,6 +122,10 @@ static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
.ipv4 = iaddr->ipv4,
.has_ipv6 = iaddr->has_ipv6,
.ipv6 = iaddr->ipv6,
+#ifdef IPPROTO_MPTCP
+ .has_mptcp = iaddr->has_mptcp,
+ .mptcp = iaddr->mptcp,
+#endif
};
(*addrs)[i] = newaddr;
diff --git a/qapi/sockets.json b/qapi/sockets.json
index 2e83452797..735eb4abb5 100644
--- a/qapi/sockets.json
+++ b/qapi/sockets.json
@@ -57,6 +57,8 @@
# @keep-alive: enable keep-alive when connecting to this socket. Not supported
# for passive sockets. (Since 4.2)
#
+# @mptcp: enable multi-path TCP. (Since 6.1)
+#
# Since: 1.3
##
{ 'struct': 'InetSocketAddress',
@@ -66,7 +68,8 @@
'*to': 'uint16',
'*ipv4': 'bool',
'*ipv6': 'bool',
- '*keep-alive': 'bool' } }
+ '*keep-alive': 'bool',
+ '*mptcp': { 'type': 'bool', 'if': 'defined(IPPROTO_MPTCP)' } } }
##
# @UnixSocketAddress:
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 2463c49773..c415c342c1 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -278,6 +278,11 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
/* create socket + bind/listen */
for (e = res; e != NULL; e = e->ai_next) {
+#ifdef IPPROTO_MPTCP
+ if (saddr->has_mptcp && saddr->mptcp) {
+ e->ai_protocol = IPPROTO_MPTCP;
+ }
+#endif
getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen,
uaddr,INET6_ADDRSTRLEN,uport,32,
NI_NUMERICHOST | NI_NUMERICSERV);
@@ -456,6 +461,13 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
for (e = res; e != NULL; e = e->ai_next) {
error_free(local_err);
local_err = NULL;
+
+#ifdef IPPROTO_MPTCP
+ if (saddr->has_mptcp && saddr->mptcp) {
+ e->ai_protocol = IPPROTO_MPTCP;
+ }
+#endif
+
sock = inet_connect_addr(saddr, e, &local_err);
if (sock >= 0) {
break;
@@ -687,6 +699,17 @@ int inet_parse(InetSocketAddress *addr, const char *str, Error **errp)
}
addr->has_keep_alive = true;
}
+#ifdef IPPROTO_MPTCP
+ begin = strstr(optstr, ",mptcp");
+ if (begin) {
+ if (inet_parse_flag("mptcp", begin + strlen(",mptcp"),
+ &addr->mptcp, errp) < 0)
+ {
+ return -1;
+ }
+ addr->has_mptcp = true;
+ }
+#endif
return 0;
}