public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] fwd: Drop implicit fallbacks to host loopback resolver
@ 2026-11-23  0:27 Stefano Brivio
  0 siblings, 0 replies; only message in thread
From: Stefano Brivio @ 2026-11-23  0:27 UTC (permalink / raw)
  To: passt-dev; +Cc: Daniel Worthington-Bodart, David Gibson

If a DNS forward option is (maybe mistakenly) passed for an IP
version that doesn't have a matching host-side resolver configured,
we currently fall back to translating the destination of DNS queries
to 0.0.0.0 / ::.  This was intended as fallback, at least for IPv6.

The IPv6 version was there almost from the beginning (and then
refactored several times) as a convenient workaround for Podman
containers where the container's resolv.conf did *not* include an IPv6
resolver, even though they were running on a system where
systemd-resolved would offer DNS resolution over IPv6 on the host.

However, checking against a recent version of Podman, this doesn't
seem to be the case anymore, and moby / rootlesskit never had this
issue anyway, so it can go away at this point.

I'm not sure if the IPv4 version was ever needed.  It might have
hidden some setup issues at some point, but I can't reproduce anything
like that with Podman right now.

In any case, this might be confusing for users, as Dan reported, and
doesn't seem to serve any practical purpose anymore,

Drop the fallbacks: if no host-side resolver is configured for a given
IP version, don't apply any special NAT, even if we see a DNS query
with a destination address matching a --dns-forward option for that
IP version.

Reported-by: Daniel Worthington-Bodart <dan@bodar.com>
Suggested-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 fwd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fwd.c b/fwd.c
index 48764c5..add01c0 100644
--- a/fwd.c
+++ b/fwd.c
@@ -976,10 +976,12 @@ uint8_t fwd_nat_from_tap(const struct ctx *c, uint8_t proto,
 			 const struct flowside *ini, struct flowside *tgt)
 {
 	if (is_dns_flow(proto, ini) &&
-	    inany_equals4(&ini->oaddr, &c->ip4.dns_match))
+	    inany_equals4(&ini->oaddr, &c->ip4.dns_match) &&
+	    !IN4_IS_ADDR_UNSPECIFIED(&c->ip4.dns_host))
 		tgt->eaddr = inany_from_v4(c->ip4.dns_host);
 	else if (is_dns_flow(proto, ini) &&
-		   inany_equals6(&ini->oaddr, &c->ip6.dns_match))
+		 inany_equals6(&ini->oaddr, &c->ip6.dns_match) &&
+		 !IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns_host))
 		tgt->eaddr.a6 = c->ip6.dns_host;
 	else
 		nat_outbound(c, &ini->oaddr, &tgt->eaddr);
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-23  0:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23  0:27 [PATCH] fwd: Drop implicit fallbacks to host loopback resolver Stefano Brivio

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).