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=jA8Gtq86; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id D72045A061B for ; Tue, 02 Dec 2025 05:02:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1764648138; bh=dAdxRX6XuASiP42W99GtF5esNQcb/EefJ2ALxwJjb1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jA8Gtq86TWARhhJxcwxTblMsS1Vw988OihiRkv7zfHVIFWIB2dQc94IYQ1PEB838Y xC0q0P4c/uVe/8rLCovfKgnBcxQcveRSzVX1oAFE89RqjuSiYoFr/6FjnD8C3XRvhk bdDGP8d8sO0rw3jzFBf/2HH7a+XgGvkCnQXZTT3hKD/L9xVHaZcLupTJ0QrqIWFInV /xblzDC8SJUuw8Wi2QPK4ej3ugfhXPtEOz9DDLTwC9aipD/8izXqA+rGUSmPjEge7d HbjrF7oP34eLzrTafpsIZ2Yu2GqceM3sgMt1JIinm45sdfKhRpg4ibMlUpukl39Qb4 AR1rWIXmFxZoQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dL6Y61vthz4wQl; Tue, 02 Dec 2025 15:02:18 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v5 15/15] fwd: Preserve non-standard loopback address when splice forwarding Date: Tue, 2 Dec 2025 15:02:15 +1100 Message-ID: <20251202040215.2351792-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251202040215.2351792-1-david@gibson.dropbear.id.au> References: <20251202040215.2351792-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: U2DGH5FZH3VFEKRALB4AMTDRBWFOIXL4 X-Message-ID-Hash: U2DGH5FZH3VFEKRALB4AMTDRBWFOIXL4 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.52.0