From: David Gibson <david@gibson.dropbear.id.au>
To: Jon Maloy <jmaloy@redhat.com>
Cc: sbrivio@redhat.com, dgibson@redhat.com, passt-dev@passt.top
Subject: Re: [PATCH v14 03/10] fwd: Add cache table for ARP/NDP contents
Date: Mon, 20 Oct 2025 11:06:23 +1100 [thread overview]
Message-ID: <aPV8_0wwLuTx4IWB@zatzit> (raw)
In-Reply-To: <fee75072-42c9-4bc6-959d-9641f0b27ebd@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 4804 bytes --]
On Fri, Oct 17, 2025 at 02:49:33PM -0400, Jon Maloy wrote:
>
>
> On 2025-10-16 23:05, David Gibson wrote:
> > On Tue, Oct 14, 2025 at 10:55:14PM -0400, Jon Maloy wrote:
> > > We add a cache table to keep track of the contents of the kernel ARP
> > > and NDP tables. The table is fed from the just introduced netlink based
> > > neigbour subscription function.
> > >
> > > Signed-off-by: Jon Maloy <jmaloy@redhat.com>
> >
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> >
> > I do see one error here, but it's fairly harmless, so I think a follow
> > up makes more sense than a respin.
> >
> > [snip]
> > > + /* Blocker entries to stop events from hosts using these addresses */
> > > + if (!inany_is_unspecified4(&mhl))
> > > + fwd_neigh_table_update(c, &mhl, c->our_tap_mac, true);
> > > +
> > > + if (!inany_is_unspecified4(&ggw) && !c->no_map_gw)
> > > + fwd_neigh_table_update(c, &ggw, c->our_tap_mac, true);
> > > +
> > > + if (!inany_is_unspecified4(&mga) && !inany_equals(&mhl, &mga)) {
> >
> > That made me realise that we should throw an error during
> > configuration if map_host_loopback == map_guest_addr. It doesn't make
> > sense for these to be the same - if they are, we have no way of
> > knowing if a packet should be mapped to 127.0.0.1 or to guest_addr.
> > *checks* looks like map_host_loopback will take precedence in this
> > case, because of the way nat_outbound() is ordered.
>
> I also noticed it is possible to set guest_gw to some random address while
> at the same time setting no_map_gw. It seems to be harmless, since no_map_gw
> takes precedence, but it is an inconsistency we should fence
> against.
No, the existing behaviour is correct. It gets confusing, because the
guest_gw is used for magic NATs, that's often what we're referring to
when we discuss the guest_gw address.
But the guest_gw is *also* exactly what it says on the tin: the
gateway address the guest uses. Without that, the guest won't have
connectivity at all, so we need it. --no-map-gw means we don't have
the magic NATs, but there's still a gateway, and -g still does and
should control its address.
> > In any case I think you can drop the inany_equals() test - the
> > permanent bit will stop the second update from clobbering the first,
> > even if we are misconfigured.
> >
> > > + uint8_t mac[ETH_ALEN];
> > > + int rc;
> > > +
> > > + rc = nl_link_get_mac(nl_sock, c->ifi4, mac);
> > > + if (rc < 0) {
> > > + debug("Couldn't get ip4 MAC addr: %s", strerror_(-rc));
> > > + memcpy(mac, c->our_tap_mac, ETH_ALEN);
> > > + }
> >
> > Using the host's MAC for --map-guest-addr only makes sense if the
> > guest address is the same as the host address. If -a is used to make
> > the guest address different, then it may shadow some other random
> > node, not the host. We don't need special handling for that case -
> > the nat_inbound() you already have will do what we need.
> >
> > IIUC, the host itself doesn't appear in the neighbour table, so we do
> > need special handling if we want to use the host MAC when
> > --map-guest-addr *does* refer to the host. To handle that, I think
> > what we want is pseudo-codishly:
> >
> > fwd_neigh_table_update(c, nat_inbound(host_addr), host_mac, true);
> >
> > The wrinkle is that while we do get the host address at some point,
> > I'm not sure we keep it around (it's typically irrelevant after init).
> >
> > Strictly speaking 'permanent' isn't really correct here, but it's not
> > worth the hassle of setting up a whole other netlink monitor to watch
> > for changes in the host's MAC address.
> >
> > In fact.. I'm not sure it's worth handling this case at all. I think
> > it would be ok to just drop this clause. That means we'll use
> > our_tap_mac by default for things NATted to the (non loopback) host,
> > which is probably fine.
> >
> Fine with me, but I do think we need a blocker entry just in case somebody
> else comes up with the same address.
We don't need a blocker. If someone else (let's call them X) comes up
with that address, that implies it's not the host's address. If
that's so then --map-guest-gw will NAT to X, and that's intended. In
which case it also makes sense to use X's MAC address. We don't need
to do anything special to make that happen - X will appear in the host
neigh table, and the nat_inbound() call will put it into the slot of
the --map-guest-gw address.
> I'll post a complementary commit once the series has been applied.
>
> ///jon
>
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-10-20 0:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 2:55 [PATCH v14 00/10] Use true MAC address of LAN local remote hosts Jon Maloy
2025-10-15 2:55 ` [PATCH v14 01/10] netlink: add subscription on changes in NDP/ARP table Jon Maloy
2025-10-17 2:36 ` David Gibson
2025-10-19 10:07 ` Stefano Brivio
2025-10-20 0:17 ` David Gibson
2025-10-15 2:55 ` [PATCH v14 02/10] passt: add no_map_gw flag to struct ctx Jon Maloy
2025-10-19 10:07 ` Stefano Brivio
2025-10-15 2:55 ` [PATCH v14 03/10] fwd: Add cache table for ARP/NDP contents Jon Maloy
2025-10-17 3:05 ` David Gibson
2025-10-17 18:49 ` Jon Maloy
2025-10-20 0:06 ` David Gibson [this message]
2025-10-20 10:00 ` Jon Maloy
2025-10-22 1:20 ` David Gibson
2025-10-19 10:07 ` Stefano Brivio
2025-10-15 2:55 ` [PATCH v14 04/10] arp/ndp: respond with true MAC address of LAN local remote hosts Jon Maloy
2025-10-17 3:06 ` David Gibson
2025-10-15 2:55 ` [PATCH v14 05/10] arp/ndp: send ARP announcement / unsolicited NA when neigbour entry added Jon Maloy
2025-10-17 3:08 ` David Gibson
2025-10-19 10:08 ` Stefano Brivio
2025-10-15 2:55 ` [PATCH v14 06/10] flow: add MAC address of LAN local remote hosts to flow Jon Maloy
2025-10-15 2:55 ` [PATCH v14 07/10] udp: forward external source MAC address through tap interface Jon Maloy
2025-10-15 2:55 ` [PATCH v14 08/10] tcp: " Jon Maloy
2025-10-15 2:55 ` [PATCH v14 09/10] tap: change signature of function tap_push_l2h() Jon Maloy
2025-10-15 2:55 ` [PATCH v14 10/10] icmp: let icmp use mac address from flowside structure Jon Maloy
2025-10-19 10:08 ` 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=aPV8_0wwLuTx4IWB@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=dgibson@redhat.com \
--cc=jmaloy@redhat.com \
--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).