From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Cc: j.d03@cpc.cx, David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 1/2] fwd_rule: Don't attempt dual stack listen()s if only one IP family
Date: Fri, 15 May 2026 18:24:33 +1000 [thread overview]
Message-ID: <20260515082434.630175-2-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20260515082434.630175-1-david@gibson.dropbear.id.au>
With the recent rework to forwarding configuration, we're stricter about
what forwarding rules we allow. In particular we don't allow dual stack
forwards (listening on both IPv4 and IPv6 addresses) if we only have one
IP family enabled.
This makes what I think was a pre-existing minor bug into a nasty failure.
If we use default forwards with no address specified, e.g.:
$ pasta -t 1234 -4
$ pasta -U 4321 -6
these are interpreted as dual-stack forwards. Previously these would be
applied, leading to a surprising dual stack socket. Since 0aeda87ca185,
they instead result in an immediate fatal error.
Add logic to interpret a default "any" address as only one IP family if
only one IP family is enabled.
Link: https://bugs.passt.top/show_bug.cgi?id=205
Reported-by: <j.d03@cpc.cx>
Fixes: 0aeda87ca185 ("conf, fwd: Stricter rule checking in fwd_rule_add()")
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
fwd_rule.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/fwd_rule.c b/fwd_rule.c
index 5fc04d76..cb37a990 100644
--- a/fwd_rule.c
+++ b/fwd_rule.c
@@ -650,8 +650,9 @@ bad:
void fwd_rule_parse(char optname, bool del, const char *optarg,
struct fwd_table *fwd)
{
- union inany_addr addr_buf = inany_any6, *addr = &addr_buf;
char buf[BUFSIZ], *spec, *ifname = NULL;
+ union inany_addr addr_buf = inany_any6;
+ const union inany_addr *addr = &addr_buf;
uint8_t proto;
if (optname == 't' || optname == 'T')
@@ -708,7 +709,7 @@ void fwd_rule_parse(char optname, bool del, const char *optarg,
p++;
}
- if (!inany_pton(p, addr))
+ if (!inany_pton(p, &addr_buf))
die("Bad forwarding address '%s'", p);
}
} else {
@@ -741,6 +742,12 @@ void fwd_rule_parse(char optname, bool del, const char *optarg,
ifname = "lo";
}
+ /* No need for dual stack if we only have one IP version */
+ if (!addr && !(fwd->caps & FWD_CAP_IPV4))
+ addr = &inany_any6;
+ else if (!addr && !(fwd->caps & FWD_CAP_IPV6))
+ addr = &inany_any4;
+
if (ifname && !(fwd->caps & FWD_CAP_IFNAME)) {
die(
"Device binding for '-%c %s' unsupported (requires kernel 5.7+)",
--
2.54.0
next prev parent reply other threads:[~2026-05-15 8:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 8:24 [PATCH 0/2] Fix regression when one IP version is disabled David Gibson
2026-05-15 8:24 ` David Gibson [this message]
2026-05-15 8:24 ` [PATCH 2/2] fwd_rule: Allow parsing * as a forwarding address David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260515082434.630175-2-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=j.d03@cpc.cx \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).