From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>, passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 2/2] pif: Correctly set scope_id for guest-side link local addresses
Date: Wed, 10 Dec 2025 18:02:57 +1100 [thread overview]
Message-ID: <20251210070257.1775739-3-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20251210070257.1775739-1-david@gibson.dropbear.id.au>
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 <david@gibson.dropbear.id.au>
---
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
next prev parent reply other threads:[~2025-12-10 7:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 7:02 [PATCH 0/2] Bug 181 & bug 182 David Gibson
2025-12-10 7:02 ` [PATCH 1/2] tcp: Correct timer expiry value in trace message David Gibson
2025-12-10 7:02 ` David Gibson [this message]
2025-12-10 13:36 ` [PATCH 0/2] Bug 181 & bug 182 Stefano Brivio
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=20251210070257.1775739-3-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/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).