aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2026-03-27 15:34:25 +1100
committerStefano Brivio <sbrivio@redhat.com>2026-03-28 14:35:58 +0100
commit72e716245cd0acac8c8db7a70628284f869c7691 (patch)
tree96fdb26fc35da75d80bfd7851649a8b8744b460c
parent9c37a481f12a5fbbeb98dbc16763e444f0322f57 (diff)
downloadpasst-72e716245cd0acac8c8db7a70628284f869c7691.tar
passt-72e716245cd0acac8c8db7a70628284f869c7691.tar.gz
passt-72e716245cd0acac8c8db7a70628284f869c7691.tar.bz2
passt-72e716245cd0acac8c8db7a70628284f869c7691.tar.lz
passt-72e716245cd0acac8c8db7a70628284f869c7691.tar.xz
passt-72e716245cd0acac8c8db7a70628284f869c7691.tar.zst
passt-72e716245cd0acac8c8db7a70628284f869c7691.zip
conf: Move check for disabled interfaces earlier
conf_ports_range_except() generates errors if asked to map an address of a family that's not available. This is quite late to perform the check, most callsites pass a NULL address, making the test moot, the one remaining can check the address earlier. Move the check there, simplifying the lower level function. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--conf.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/conf.c b/conf.c
index dc9468c..d4c2a01 100644
--- a/conf.c
+++ b/conf.c
@@ -160,16 +160,6 @@ static void conf_ports_range_except(const struct ctx *c, char optname,
else
assert(0);
- 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 (base = first; base <= last; base++) {
if (exclude && bitmap_isset(exclude, base))
continue;
@@ -335,6 +325,16 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg,
addr = NULL;
}
+ 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);
+ }
+ }
+
/* Mark all exclusions first, they might be given after base ranges */
p = spec;
do {