From d04c48032bcf724550d0b8f652fd00efcd2dfad0 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 10 Dec 2025 18:02:57 +1100 Subject: pif: Correctly set scope_id for guest-side link local addresses 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 Signed-off-by: Stefano Brivio --- pif.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pif.c b/pif.c index 3d7a90e..6ae970a 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; } } -- cgit v1.2.3