public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Cc: Daniel Worthington-Bodart <dan@bodar.com>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH] fwd: Drop implicit fallbacks to host loopback resolver
Date: Mon, 23 Nov 2026 01:27:28 +0100	[thread overview]
Message-ID: <20261123002728.4072813-1-sbrivio@redhat.com> (raw)

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


                 reply	other threads:[~2026-11-23  0:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261123002728.4072813-1-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=dan@bodar.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /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).