public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Jon Maloy <jmaloy@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
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 06:00:37 -0400	[thread overview]
Message-ID: <d737f5e6-2b7f-4d91-b156-3295bf01ea16@redhat.com> (raw)
In-Reply-To: <aPV8_0wwLuTx4IWB@zatzit>



On 2025-10-19 20:06, David Gibson wrote:
> On Fri, Oct 17, 2025 at 02:49:33PM -0400, Jon Maloy wrote:
[...]
>> 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.

So, your are telling me this is expected behaviour?

jmaloy@mimir:~/passt/tests/udp_test$ /home/jmaloy/passt/passt/pasta 
--config-net --no-splice -d -a 192.168.2.2 -g 192.168.2.3 --no-map-gw
Template interface: wlp1s0 (IPv4), wlp1s0 (IPv6)
Namespace interface: wlp1s0
MAC:
     host: 9a:55:9a:55:9a:55
DHCP:
     assign: 192.168.2.2
     mask: 255.255.255.0
     router: 192.168.2.3
DNS:
     10.11.5.19
     10.2.32.1
DNS search list:
     redhat.com
     rmtcaqc.csb
NDP/DHCPv6:
     assign: 2001:4958:2193:9901:6217:960c:2ef1:f0f3
     router: fe80::c23c:4ff:fe04:4638
     our link-local: fe80::c23c:4ff:fe04:4638
DNS search list:
     redhat.com
     rmtcaqc.csb
Sending initial ARP request for guest MAC address
Sending initial NDP NS request for guest MAC address
SO_PEEK_OFF supported
TCP_INFO tcpi_snd_wnd field  supported
TCP_INFO tcpi_bytes_acked field  supported
TCP_INFO tcpi_min_rtt field  supported
root@mimir:~/passt/tests/udp_test# ip r
default via 192.168.2.3 dev wlp1s0
192.168.2.0/24 dev wlp1s0 proto kernel scope link src 192.168.2.2
root@mimir:~/passt/tests/udp_test# ping 192.168.2.3
PING 192.168.2.3 (192.168.2.3) 56(84) bytes of data.
^C^
--- 192.168.2.3 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4080ms

root@mimir:~/passt/tests/udp_test# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=255 time=7.68 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=255 time=20.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=255 time=19.1 ms
^C
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 7.676/15.889/20.876/5.851 ms
root@mimir:~/passt/tests/udp_test#

///jon

> 
>>> 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
>>
>>
> 


  reply	other threads:[~2025-10-20 10:00 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
2025-10-20 10:00         ` Jon Maloy [this message]
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=d737f5e6-2b7f-4d91-b156-3295bf01ea16@redhat.com \
    --to=jmaloy@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=dgibson@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).