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=202512 header.b=qRb7gllZ; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id A1DB75A0626 for ; Wed, 10 Dec 2025 08:03:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1765350179; bh=VVsoXVkZnGsbKm79WiytrAUAXNLjG8fTZ/oSPK4P83A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qRb7gllZajXI3U5ZVV2xeismNC7LjPw2PyAf/9x3mOz7lF9I5WsctmBj+XSvbI0k3 ToEfOYxyEenMVELXDhekp62FwISne1YKWq6MxR+MDYwsaIuQvl/hzzJzYt0nydShii S3v5TvSJDhGDGrkwZFfDgZqQj08I3G8oxpGy76MQWpL+o9EHxIehaZ/0a2AVGCcI0y kc5b16Rd7yGfvWdZBr7GR6EnqTYVkZsTChzZwWHXEzvD7a0T7Uio4qJs/jkoHJsXlJ znECWWGYYD43ZJ49c3DDoXL+9Lsb/Mk51QWrtdgvtdPJiPhtj9TEoTUugLWDdG5gA5 gCnur7ssAjNvw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dR69v0PSdz4wQq; Wed, 10 Dec 2025 18:02:59 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 2/2] pif: Correctly set scope_id for guest-side link local addresses Date: Wed, 10 Dec 2025 18:02:57 +1100 Message-ID: <20251210070257.1775739-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210070257.1775739-1-david@gibson.dropbear.id.au> References: <20251210070257.1775739-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: BHY5RR4TQRAVGBDFXZ5JZAS4HWVF2EU6 X-Message-ID-Hash: BHY5RR4TQRAVGBDFXZ5JZAS4HWVF2EU6 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: pif_sockaddr() is supposed to generate a suitable socket address, either for the host, or for the guest, depending on the 'pif' parameter. When given a link-local address, this means it needs to generate a suitable scope_id to specify which link. It does this for the host, but not for the guest. I think this was done on the assumption that we won't ever generate guest side link local addresses when forwarding connections. That, however, is not the case, at least with the recent extensions to "local mode". Fix the problem by properly populating the scope_id field for guest addresses. Link: https://bugs.passt.top/show_bug.cgi?id=181 Signed-off-by: David Gibson --- pif.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pif.c b/pif.c index 3d7a90e5..6ae970a0 100644 --- a/pif.c +++ b/pif.c @@ -50,10 +50,14 @@ void pif_sockaddr(const struct ctx *c, union sockaddr_inany *sa, sa->sa_family = AF_INET6; sa->sa6.sin6_addr = addr->a6; sa->sa6.sin6_port = htons(port); - if (pif == PIF_HOST && IN6_IS_ADDR_LINKLOCAL(&addr->a6)) - sa->sa6.sin6_scope_id = c->ifi6; - else + if (IN6_IS_ADDR_LINKLOCAL(&addr->a6)) { + if (pif == PIF_HOST) + sa->sa6.sin6_scope_id = c->ifi6; + else if (pif == PIF_SPLICE) + sa->sa6.sin6_scope_id = c->pasta_ifi; + } else { sa->sa6.sin6_scope_id = 0; + } sa->sa6.sin6_flowinfo = 0; } } -- 2.52.0