From: EJ Campbell <ej.campbell@gmail.com>
To: passt-dev@passt.top
Subject: [PATCH] tap: don't let overheard traffic move addr_seen when serving a fixed address
Date: Tue, 2 Jun 2026 18:15:24 -0700 [thread overview]
Message-ID: <CABXAF12gPjPODONguXTezTyTSeEGma5ti0Zt3-rT5ZpRh1hRwA@mail.gmail.com> (raw)
The latest source address seen on the tap interface (ip4.addr_seen) is
taken to be the guest's and is used as the target for inbound port
forwarding. The update accepts any source address.
On a point-to-point tap that is always correct. But when the tap sits on
a shared L2 segment -- for example when it is bridged together with other
hosts -- pasta also sees frames from those other hosts. With a static
configuration (-a / address set, DHCP disabled), an overheard frame from
another host silently moves addr_seen to that host, and every subsequent
inbound forwarded connection is sent there instead of to the guest, so
connections are reset or hang.
I hit this running pasta with its tap enslaved to a Linux bridge that also
carries other traffic: inbound port forwarding to the guest broke as soon
as another address was seen on the segment.
Restrict the update so that, when DHCP is disabled (no_dhcp), only frames
sourced from the configured guest address may move addr_seen. With DHCP
enabled -- the default -- behaviour is unchanged, since the guest's
address is whatever pasta leases and tracking it is still correct.
The same reasoning applies to ip6.addr_seen on a shared segment; I left
IPv6 alone for now since I only exercise IPv4 in this setup, and would be
glad to extend it the same way if you prefer.
Signed-off-by: EJ Campbell <ej.campbell@gmail.com>
---
tap.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/tap.c b/tap.c
index 4cba4c7..514379e 100644
--- a/tap.c
+++ b/tap.c
@@ -770,7 +770,19 @@ resume:
continue;
}
- if (iph->saddr && c->ip4.addr_seen.s_addr != iph->saddr)
+ /* The latest source address seen on the tap is taken to be the
+ * guest's, and becomes the target for inbound forwarding. On a
+ * point-to-point tap that's always correct. But if the tap sits
+ * on a shared L2 segment (for example bridged together with
+ * other hosts) and we serve a fixed address (DHCP disabled), a
+ * frame overheard from another host on that segment must not
+ * move addr_seen and silently retarget forwarded connections
+ * away from the guest. When DHCP is disabled, only the
+ * configured guest address may update addr_seen; with DHCP
+ * enabled (the default) behaviour is unchanged.
+ */
+ if (iph->saddr && c->ip4.addr_seen.s_addr != iph->saddr &&
+ (!c->no_dhcp || iph->saddr == c->ip4.addr.s_addr))
c->ip4.addr_seen.s_addr = iph->saddr;
if (!iov_drop_header(&data, hlen))
base-commit: 4b2823784aab04a70dfc295b16fd6f0592955790
--
2.53.0
reply other threads:[~2026-06-03 1:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=CABXAF12gPjPODONguXTezTyTSeEGma5ti0Zt3-rT5ZpRh1hRwA@mail.gmail.com \
--to=ej.campbell@gmail.com \
--cc=ej@campbell.name \
--cc=passt-dev@passt.top \
/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).