From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202510 header.b=ZZ3vd8O1; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id DD4E05A0275 for ; Thu, 20 Nov 2025 05:34:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1763613296; bh=V3W6gz98fFVY4sagQl+MVGTwNbTLBICW4ITht0Q9q5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZZ3vd8O1ENg5EyLmNfA7Rg55IdOu6LxcEzHJiRWP9Nt0jnBH2e7TJdamkbxUUzyQU yOhaifR2agfpL1Xn970/nFxem03wYBPDcLulYQEo0+ChyT3qvK/X0FqxOrC+vlVul7 pVmBx0mWsqcRoaD3Ugr9zGbHy0lvX7QVbP1T1k1Ghvo7I/N0+wno260lk0P+AI88yw 26CnaKMeNT+Ig+81t8t0OsM0cNwdDi/mRDxanL/XrM/zS4t0a20CQoCA6+3E5tf+ZU aXbVWgvW+Fclafc8iYNpGJsdThH3wrFIdtOiJggDEHfbmMozOh+X9oUrd9xF/jYFYi yYASMb5deQ7Uw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dBlrJ2K7lz4wH7; Thu, 20 Nov 2025 15:34:56 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 3/3] fwd: Preserve non-standard loopback address when splice forwarding Date: Thu, 20 Nov 2025 15:34:53 +1100 Message-ID: <20251120043453.108919-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251120043453.108919-1-david@gibson.dropbear.id.au> References: <20251120043453.108919-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: XLJQO6MFFO2ZZWDQ7ELYBNQLO6CRLRLY X-Message-ID-Hash: XLJQO6MFFO2ZZWDQ7ELYBNQLO6CRLRLY X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: When forwarding "spliced" connections outwards (-T or -U) we listen on the guest's loopback and always forward to 127.0.0.1 (or ::1) on the host. However, it's also possible for clients on the guest to attempt connecting to other addresses in 127.0.0.0/8 (systemd-resolved uses 127.0.0.53 in practice). If the host side server is only listening on that specific non-standard loopback address, the forward won't work. Fix this by preserving the specific (loopback) address when forwarding such connections. Link: https://bugs.passt.top/show_bug.cgi?id=113 Signed-off-by: David Gibson --- fwd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fwd.c b/fwd.c index c417e0f5..44a0e109 100644 --- a/fwd.c +++ b/fwd.c @@ -660,7 +660,9 @@ uint8_t fwd_nat_from_splice(const struct ctx *c, uint8_t proto, return PIF_NONE; } - if (inany_v4(&ini->eaddr)) + if (!inany_is_unspecified(&ini->oaddr)) + tgt->eaddr = ini->oaddr; + else if (inany_v4(&ini->oaddr)) tgt->eaddr = inany_loopback4; else tgt->eaddr = inany_loopback6; -- 2.51.1