aboutgitcodebugslistschat
diff options
context:
space:
mode:
-rw-r--r--conf.c7
-rw-r--r--passt.h2
-rw-r--r--util.c8
3 files changed, 16 insertions, 1 deletions
diff --git a/conf.c b/conf.c
index 6f86940..cd05adf 100644
--- a/conf.c
+++ b/conf.c
@@ -1254,7 +1254,9 @@ void conf(struct ctx *c, int argc, char **argv)
int name, ret;
uid_t uid;
gid_t gid;
-
+
+ if (c->no_ipv6)
+ v4_only = true;
if (c->mode == MODE_PASTA)
c->no_dhcp_dns = c->no_dhcp_dns_search = 1;
@@ -1682,6 +1684,9 @@ void conf(struct ctx *c, int argc, char **argv)
v6_only = false;
break;
case '6':
+ if (c->no_ipv6)
+ die("IPv6 not available but --ipv6-only given");
+
v6_only = true;
v4_only = false;
break;
diff --git a/passt.h b/passt.h
index 1726965..c5f51d1 100644
--- a/passt.h
+++ b/passt.h
@@ -211,6 +211,7 @@ struct ip6_ctx {
* @low_wmem: Low probed net.core.wmem_max
* @low_rmem: Low probed net.core.rmem_max
* @no_bindtodevice: Unprivileged SO_BINDTODEVICE not available
+ * @no_ipv6: IPv6 sockets not available
* @vdev: vhost-user device
* @device_state_fd: Device state migration channel
* @device_state_result: Device state migration result
@@ -296,6 +297,7 @@ struct ctx {
int low_wmem;
int low_rmem;
int no_bindtodevice;
+ bool no_ipv6;
struct vu_dev *vdev;
diff --git a/util.c b/util.c
index b64c29e..fe0aab9 100644
--- a/util.c
+++ b/util.c
@@ -334,6 +334,14 @@ void sock_probe_features(struct ctx *c)
c->no_bindtodevice = 1;
}
+ /* Check if IPv6 sockets are usable */
+ close(s);
+ s = socket(AF_INET6, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
+ if (s < 0) {
+ c->no_ipv6 = true;
+ return;
+ }
+
close(s);
}