From 72e716245cd0acac8c8db7a70628284f869c7691 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 27 Mar 2026 15:34:25 +1100 Subject: 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 Signed-off-by: Stefano Brivio --- conf.c | 20 ++++++++++---------- 1 file 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 { -- cgit v1.2.3