public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: Jon Maloy <jmaloy@redhat.com>, passt-dev@passt.top
Subject: Re: [PATCH v7 02/13] passt, pasta: Introduce unified multi-address data structures
Date: Thu, 25 Jun 2026 00:56:54 +0200 (CEST)	[thread overview]
Message-ID: <20260625005652.569401b4@elisabeth> (raw)
In-Reply-To: <ajiSZKQpLjzfj2zO@zatzit>

On Mon, 22 Jun 2026 11:39:48 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:

> On Sat, Jun 20, 2026 at 12:09:51AM +0200, Stefano Brivio wrote:
> > On Sun, 12 Apr 2026 20:53:08 -0400
> > Jon Maloy <jmaloy@redhat.com> wrote:
> >   
> > > As preparation for supporting multiple addresses per interface,
> > > we replace the single addr/prefix_len fields with an array. The
> > > array consists of a new struct inany_addr_entry containing an
> > > address and prefix length, both in inany_addr format.
> > > 
> > > Despite a lot of code refactoring, there are only two real functional
> > > changes:
> > > - The indicated IPv6 prefix length is now properly stored, instead
> > >   of being ignored and overridden with the hardcoded value 64, as
> > >   has been the case until now.
> > > - Since even IPv4 addresses now are stored in IPv6 format, we
> > >   also store the corresponding prefix length in that format,
> > >   i.e. using the range [96,128] instead of [0,32].
> > > 
> > > Signed-off-by: Jon Maloy <jmaloy@redhat.com>
> > > 
> > > ---
> > > v2: -Using inany_addr instead of protocol specific addresses as
> > >      entry address field.
> > > 
> > > v3: -Merging into one array, directly in struct ctx
> > >     -Changed prefix_len and flags fields in struct inany_addr_entry
> > >      to uint8_t, since that makes the struct directly migratable
> > > 
> > > v4: -Updated according to changes in previous commits
> > >     -Updated according to feedback from David G.
> > >     -Squashed IP4_MASK macro commit into this one
> > > 
> > > v6: -Renamed and moved some definitions
> > >     -Introduced fwd_set_addr() and fwd_get_addr() already in this commit
> > >     -Eliminated first_v4/v6() functions, replaced with fwd_get_addr()
> > >     -Some other changes as suggested by David G.
> > >     -I kept the flag CONF_ADDR_LINKLOCAL, since it will be
> > >      needed later in an address selection function.
> > > 
> > > v7: -Introduced CONF_ADDR_GENERATED flag
> > >     -Other fixes based on feedback from David and Stefano.
> > >     -I changed signature of inany_prefix_len(), but I did not change
> > >      its semantics, since the premise of David's comment is wrong: the
> > >      caller does *not* explicitly know he is dealing with an IPv4 address.
> > >      In fact, there are examples later in this series where it may be an
> > >      IPv6 address, and the caller just trusts he gets the return value in
> > >      the appropriate format.
> > >     -Introduced the inverse of inany_prefix_len(), called inany_prefix_len6()
> > >      which always returns the prefix in IPv6 or mapped IPv4 format.
> > >      The name of the function isn't great, but any alternative I came up
> > >      with became too long to be practical.
> > > ---
> > >  arp.c    |  12 ++++-
> > >  conf.c   | 143 ++++++++++++++++++++++++++++++-------------------------
> > >  dhcp.c   |  14 ++++--
> > >  dhcpv6.c |  15 ++++--
> > >  fwd.c    | 109 ++++++++++++++++++++++++++++++++++--------
> > >  fwd.h    |   4 ++
> > >  inany.h  |  41 ++++++++++++++++
> > >  ip.h     |   2 +
> > >  ndp.c    |  16 +++++--
> > >  passt.h  |  67 ++++++++++++++++++++++----
> > >  pasta.c  |  25 ++++++----
> > >  tap.c    |   7 ++-
> > >  12 files changed, 340 insertions(+), 115 deletions(-)
> > > 
> > > diff --git a/arp.c b/arp.c
> > > index bb042e9..a7fd82f 100644
> > > --- a/arp.c
> > > +++ b/arp.c
> > > @@ -41,6 +41,8 @@
> > >  static bool ignore_arp(const struct ctx *c,
> > >  		       const struct arphdr *ah, const struct arpmsg *am)
> > >  {
> > > +	const struct guest_addr *a;
> > > +
> > >  	if (ah->ar_hrd != htons(ARPHRD_ETHER)	||
> > >  	    ah->ar_pro != htons(ETH_P_IP)	||
> > >  	    ah->ar_hln != ETH_ALEN		||
> > > @@ -54,7 +56,8 @@ static bool ignore_arp(const struct ctx *c,
> > >  		return true;
> > >  
> > >  	/* Don't resolve the guest's assigned address, either. */
> > > -	if (!memcmp(am->tip, &c->ip4.addr, sizeof(am->tip)))
> > > +	a = fwd_get_addr(c, AF_INET, 0, 0);  
> > 
> > I guess it's not strictly needed right now to avoid breaking things,
> > but, eventually, if we support multiple assigned / configured /
> > observed addresses for the guest, we should make sure we don't resolve
> > any of them. That is, we should eventually pass am->tip to a lookup
> > function. It might be in scope for this series but not necessarily.  
> 
> I think one of the later patches already does that.

Ah, right, I actually realised but I then decided to keep this comment
(and forgot to update it) because this is another argument in favour of
a lookup function (which doesn't appear in the series at all).

> I do wonder if for supporting multiple guest addresses it makes sense
> at some point to switch from resolving everything _except_ a known
> guest address to only resolving addresses that passt "owns" on the
> guest link (basically the gateway address, maybe some NATs).

That will break compatibility with containers / guests that don't use
the address of the default gateway we set (anymore), assuming we set
one, or that we advertise.

We also had some reports of users setting up a device route only
(perhaps for Wireguard, even though that would more naturally be a
point-to-point configuration). I can't find them right now but I have a
rather clear memory. If those are *not* point-to-point (just like in
those setups if I recall correctly), pasta resolving any IP address is
rather convenient.

-- 
Stefano


  reply	other threads:[~2026-06-24 22:56 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13  0:53 [PATCH v7 00/13] Introduce multiple addresses and late binding Jon Maloy
2026-04-13  0:53 ` [PATCH v7 01/13] dhcpv6: Fix reply destination to match client's source address Jon Maloy
2026-05-14  5:21   ` David Gibson
2026-06-19 22:11     ` Stefano Brivio
2026-06-22  3:39       ` David Gibson
2026-06-19 22:09   ` Stefano Brivio
2026-04-13  0:53 ` [PATCH v7 02/13] passt, pasta: Introduce unified multi-address data structures Jon Maloy
2026-05-14  6:30   ` David Gibson
2026-05-14 23:28     ` Stefano Brivio
2026-05-25  9:35       ` David Gibson
2026-06-19 22:09   ` Stefano Brivio
2026-06-22  1:39     ` David Gibson
2026-06-24 22:56       ` Stefano Brivio [this message]
2026-04-13  0:53 ` [PATCH v7 03/13] fwd: Unify guest accessibility checks with unified address array Jon Maloy
2026-05-25  9:38   ` David Gibson
2026-06-19 22:09   ` Stefano Brivio
2026-04-13  0:53 ` [PATCH v7 04/13] arp: Check all configured addresses in ARP filtering Jon Maloy
2026-06-19 22:10   ` Stefano Brivio
2026-04-13  0:53 ` [PATCH v7 05/13] conf: Allow multiple -a/--address options per address family Jon Maloy
2026-05-25  9:47   ` David Gibson
2026-06-19 22:10   ` Stefano Brivio
2026-04-13  0:53 ` [PATCH v7 06/13] netlink, conf: Read all addresses from template interface at startup Jon Maloy
2026-04-13  0:53 ` [PATCH v7 07/13] netlink, pasta: refactor function pasta_ns_conf() Jon Maloy
2026-05-26  1:58   ` David Gibson
2026-04-13  0:53 ` [PATCH v7 08/13] conf, pasta: Track observed guest IPv4 addresses in unified address array Jon Maloy
2026-05-27  2:46   ` David Gibson
2026-06-19 22:10   ` Stefano Brivio
2026-06-22  1:46     ` David Gibson
2026-06-24 22:56       ` Stefano Brivio
2026-04-13  0:53 ` [PATCH v7 09/13] conf, pasta: Track observed guest IPv6 " Jon Maloy
2026-05-27  3:40   ` David Gibson
2026-06-19 22:11     ` Stefano Brivio
2026-04-13  0:53 ` [PATCH v7 10/13] migrate: Update protocol to v3 for multi-address support Jon Maloy
2026-05-27  3:55   ` David Gibson
2026-06-19 22:11   ` Stefano Brivio
2026-04-13  0:53 ` [PATCH v7 11/13] dhcp: Select address for DHCP distribution Jon Maloy
2026-05-27  4:30   ` David Gibson
2026-06-19 22:11   ` Stefano Brivio
2026-04-13  0:53 ` [PATCH v7 12/13] dhcpv6: Select addresses for DHCPv6 distribution Jon Maloy
2026-05-27  4:40   ` David Gibson
2026-06-19 22:11   ` Stefano Brivio
2026-04-13  0:53 ` [PATCH v7 13/13] ndp: Support advertising multiple prefixes in Router Advertisements Jon Maloy
2026-05-27  4:52   ` David Gibson
2026-06-19 22:11   ` 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=20260625005652.569401b4@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=jmaloy@redhat.com \
    --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).