aboutgitcodebugslistschat
diff options
context:
space:
mode:
-rw-r--r--conf.c10
-rw-r--r--tcp.c6
-rw-r--r--udp.c6
3 files changed, 14 insertions, 8 deletions
diff --git a/conf.c b/conf.c
index b1fc4b9..9a0d945 100644
--- a/conf.c
+++ b/conf.c
@@ -162,6 +162,16 @@ static void conf_ports_range_except(const struct ctx *c, char optname,
optname, optarg);
}
+ if (addr) {
+ if (!c->ifi4 && inany_v4(addr)) {
+ die("IPv4 is disabled, can't use -%c %s",
+ optname, optarg);
+ } else if (!c->ifi6 && !inany_v4(addr)) {
+ die("IPv6 is disabled, can't use -%c %s",
+ optname, optarg);
+ }
+ }
+
for (i = first; i <= last; i++) {
if (bitmap_isset(exclude, i))
continue;
diff --git a/tcp.c b/tcp.c
index e9f6e3e..2defc2d 100644
--- a/tcp.c
+++ b/tcp.c
@@ -2699,16 +2699,14 @@ int tcp_listen(const struct ctx *c, uint8_t pif,
/* Restrict to v6 only */
addr = &inany_any6;
else if (inany_v4(addr))
- /* Nothing to do */
- return 0;
+ return -EAFNOSUPPORT;
}
if (!c->ifi6) {
if (!addr)
/* Restrict to v4 only */
addr = &inany_any4;
else if (!inany_v4(addr))
- /* Nothing to do */
- return 0;
+ return -EAFNOSUPPORT;
}
if (pif == PIF_HOST) {
diff --git a/udp.c b/udp.c
index 747d4dd..ea28f5b 100644
--- a/udp.c
+++ b/udp.c
@@ -1162,16 +1162,14 @@ int udp_listen(const struct ctx *c, uint8_t pif,
/* Restrict to v6 only */
addr = &inany_any6;
else if (inany_v4(addr))
- /* Nothing to do */
- return 0;
+ return -EAFNOSUPPORT;
}
if (!c->ifi6) {
if (!addr)
/* Restrict to v4 only */
addr = &inany_any4;
else if (!inany_v4(addr))
- /* Nothing to do */
- return 0;
+ return -EAFNOSUPPORT;
}
s = pif_sock_l4(c, EPOLL_TYPE_UDP_LISTEN, pif,