public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Jon Maloy <jmaloy@redhat.com>,
	Benjamin Schubert <contact@benschubert.me>
Cc: passt-dev@passt.top
Subject: Re: [PATCH] netlink: Only consider gateway from the selected template interface
Date: Fri, 04 Dec 2026 07:30:49 +0100 (CET)	[thread overview]
Message-ID: <20261204073047.085813a6@elisabeth> (raw)
In-Reply-To: <8d80cd4a-5b4d-487c-9af6-1f7b25d60454@redhat.com>

On Thu, 3 Dec 2026 14:37:10 -0500
Jon Maloy <jmaloy@redhat.com> wrote:

> On 2026-12-03 10:12, Benjamin Schubert wrote:
> > From: Benjamin Schubert <bschubert15@bloomberg.net>
> >   
> [...]
> > This considers only nexthops from the current interface instead of all
> > interfaces when looking at the template interface, ensuring that the ip
> > and the gateway are always aligned.  
> 
> The change looks correct to me. A couple of comments:
> 
> - passt.1 still says that, for a multipath default route, "the gateway
>    is the first nexthop router returned by the kernel which has the
>    highest weight in the set of paths". With this change, it's the
>    highest-weight one on the template interface, so I think the man
>    page should be updated accordingly.

But wait, that was already the intended behaviour, maybe a bit
implicitly but I still think very clearly.  The paragraph goes like
this, emphasis mine:

  -g, --gateway addr
    Assign IPv4 addr as default gateway via DHCP (option 3), or IPv6 addr
    as source for NDP Router Advertisement and DHCPv6 messages.
    This option can be specified zero (for defaults) to two times (once
    for IPv4, once for IPv6).

    *** By default, IPv4 and IPv6 gateways are taken from the host
    interface with the first default route, if any, for the corresponding
    IP version. ***

    If the default route is a multipath one, the gateway is the first
    nexthop router returned by the kernel which has the highest weight in
    the set of paths.

The part I highlighted describes the idea of template interface.

I proposed the "template interface" name after writing that part of
documentation, and maybe we should explicitly define that concept and
update the man page throughout at some point.

But I think it's obvious enough that the additional multipath
specification still refers to the template interface, and to *that*
default route.

Making this last sentence more correct might actually harm
readability, at least until we clearly define the concept of
template interface (then it's two convenient words).

Maybe for the moment being we could go with "If that default route
[...]" instead of "If the default route [...]".  Would that help?

> 
> - Alternatively, nl_get_ext_if() could pick the template interface
>    from the highest-weight nexthop instead of the first one, which
>    would keep the documented behaviour. I'm fine with either, maybe
>    Stefano has a preference.

I think this patch is preferable to that, and also fairly convinced
that it implements the only reasonable, intended, and I also
think documented behaviour.

> > 
> > Link: https://bugs.passt.top/show_bug.cgi?id=232
> > Signed-off-by: Benjamin Schubert <bschubert15@bloomberg.net>
> > ---
> >   netlink.c                            |  8 +++--
> >   test/pasta_options/multipath_gateway | 46 ++++++++++++++++++++++++++--
> >   2 files changed, 50 insertions(+), 4 deletions(-)
> > 
> > diff --git a/netlink.c b/netlink.c
> > index 37c55cc..f7bc7ab 100644
> > --- a/netlink.c
> > +++ b/netlink.c
> > @@ -362,26 +362,30 @@ unsigned int nl_get_ext_if(int s, sa_family_t af)
> >   }
> >   
> >   /**
> >    * nl_route_get_def_multipath() - Get first highest-weight route from nexthop list
> >    * @rta:	Routing netlink attribute with type RTA_MULTIPATH
> > + * @ifi:	Interface index
> >    * @gw:		Default gateway to fill
> >    *
> >    * Return: true if a gateway was found, false otherwise
> >    */
> > -static bool nl_route_get_def_multipath(struct rtattr *rta, void *gw)
> > +static bool nl_route_get_def_multipath(struct rtattr *rta, unsigned int ifi, void *gw)  
> 
> This line exceeds 80 columns.

Meaning, Benjamin, that you should wrap it like this (see also
CONTRIBUTING.md):

static bool nl_route_get_def_multipath(struct rtattr *rta, unsigned int ifi,
				       void *gw)
{
	[...]

> 
> >   {
> >   	int nh_len = RTA_PAYLOAD(rta);
> >   	struct rtnexthop *rtnh;  
> [...]
> 
> > +def	ipv4_other_interface
> > +ipv4
> > +set	OTHER_PREFIX 192.51.100.  
> 
>   I guess you meant 198.51.100. (TEST-NET-2, RFC 5737): 192.51.100.0/24
>   is regular address space.
> 
> > +set	OTHER_INTERFACE_SETUP ip link add dummy1 type dummy; ip link set dummy1 up; ip -4 address add __OTHER_PREFIX__10/24 dev dummy1
> > +endef
> > +  
> [...]
> 
> > +set	NEXTHOPS nexthop via __OTHER_PREFIX__1 dev dummy1 weight 3 nexthop via __PREFIX__1 dev dummy0 weight 1
> > +set	EXPECTED __PREFIX__1
> > +check_gateway  
> 
> Nit: a Fixes: tag for 6c7623d0 ("netlink: Add support to fetch default
> gateway from multipath routes") would be nice, as that's where we
> started picking the gateway from any nexthop, including ones on
> interfaces other than the template interface.

commit-msg git hook I still use for those, if it helps:

  https://lore.kernel.org/all/20190220213729.49deb54f@redhat.com/

-- 
Stefano

      reply	other threads:[~2026-12-04  6:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 15:12 Benjamin Schubert
2026-12-03 19:37 ` Jon Maloy
2026-12-04  6:30   ` Stefano Brivio [this message]

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=20261204073047.085813a6@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=contact@benschubert.me \
    --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).