From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=fail (p=quarantine dis=none) header.from=redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id CE5185A026E for ; Fri, 04 Dec 2026 07:30:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796365854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J+jw2cGMUpk8QM+iP+hizJiK3zaVr69FGeZ7mfnm0UM=; b=I1popObOr680eGMpcOyZHYCpQ8Ev19Ei062Q4HW2ks7Br1+Jii05FALqdRbSf2x69OR3Q9 J6+3doCntanM46a3ASJea0xq3iCjijd2jIrVSmBJESplFtTWOdHUvyXcQxzT4L9CEkpCdr zKnP6AyNiLhGzJUybTGlniSQQsKOrnY= X-MC-Rep: binary re single Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-284-0x7fUCwvPgymb2xBD0RU7g-1; Fri, 4 Dec 2026 06:30:52 +0000 X-MC-Unique: 0x7fUCwvPgymb2xBD0RU7g-1 X-Mimecast-MFC-AGG-ID: 0x7fUCwvPgymb2xBD0RU7g_1796365851 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4bb66fc3aa6so4884845e9.2 for ; Thu, 03 Dec 2026 22:30:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796365851; x=1796970651; h=date:content-transfer-encoding:content-type:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=J+jw2cGMUpk8QM+iP+hizJiK3zaVr69FGeZ7mfnm0UM=; b=eIE3kCHrpAcA+SnjBSD/tKqdyaSHfeInVHxrbRfp0cLIvDNqEm1ZmhJxhDRqv5B7WU v1OP50e64hwyVHQL8MccOAA50r0C9MmRybgOoRqD+SMpFGvyTNkVfiUxRI+9iFol0nia VWycQ0p1Igz3FbVKutwDa63ClNr56WEW1RQDBOoAEdS590I9qV52wvrQrT0bWUXFpCJV 0spcKELdDXEvofTaR8Ev5Qxzp6a1ue6udOPOI332mt25xa5f6NL6avN8dKrxO4M7khnM rIg6A1s1zAXzdBnPf1ty912dVN5ButPTKD2hpyNEwJ4DKls4kHQW1OnBvlS1ZBXiasK4 iXiA== X-Gm-Message-State: APuU4Z/+uyVRZs4pn4kpc+t1BmgQy+qpCIL+TgJ+tpFwq5tDZGrI/eLZ FaKxhmYWpCpmha3Ue+eHEr8uSo2VTep5za00OPBXYVIuyCyqjFT1arfyOoeJQwhlFfmGyi2ftIz l8moEug6b3e3/rn3OlvEBmztU7Kcxk2gDSwBNvQe7ih2wwE+mCUNG3g== X-Gm-Gg: AZFdTZefvez1TKV4iLLnchsAgXCGGCy7jEzBvBzBwP95DdD8dnjwOVRRMnlu29oywAN Y4WfZ7DzBSgqaAn3QUzRL7/BnH7HUHOuwnN093cPix888Q36xXS4ZuiJGdSz8U8nfzf9h49AAfB zozhZC29nHArcMDakO6/GMecsTioaow3Xzik/J38REyKZn2GsVqqdGjzJXvc5L50DdGkrppRyEP bT1phuOnddK9ToDWXKyubRrXwLYmnu9I0XGthvusZQdQmpu9s1CqaZ2JZoy8QPZ2yu7mHEZ6zLD XmlIJcOUPRVAsDzAQVlnjWazJqzpls90eDpi3fJie7lKzlxiDRNnc0hAS/UaQBTECjrZnxBk/fX Zrhw0giQMZhb8K4ZDOJ4AvUIjYdIzbAiYpdI6ToSjfF+WgkGAkSdphPSBL1J/f9ekpII= X-Received: by 2002:a05:600c:3488:b0:4bb:6a5a:7839 with SMTP id 5b1f17b1804b1-4bbeb8f992emr15225835e9.34.1796365851243; Thu, 03 Dec 2026 22:30:51 -0800 (PST) X-Received: by 2002:a05:600c:3488:b0:4bb:6a5a:7839 with SMTP id 5b1f17b1804b1-4bbeb8f992emr15225395e9.34.1796365850616; Thu, 03 Dec 2026 22:30:50 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d2e8886eb1sm273115f8f.1.2026.12.03.22.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 22:30:49 -0800 (PST) From: Stefano Brivio To: Jon Maloy , Benjamin Schubert Subject: Re: [PATCH] netlink: Only consider gateway from the selected template interface Message-ID: <20261204073047.085813a6@elisabeth> In-Reply-To: <8d80cd4a-5b4d-487c-9af6-1f7b25d60454@redhat.com> References: <2UuogkMNAhFH_0bGAADpm7VgzMi123uydmdNZpZZ6tWdhkxB8y5S4Z4h4Ela1Vyb0QymFQg2Pe03CsvEWjLtdvbeFhbCuBJthILFuMs-JYo=@benschubert.me> <8d80cd4a-5b4d-487c-9af6-1f7b25d60454@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Fri, 04 Dec 2026 07:30:49 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Oe-5lm9EOKBNJYOIxZx8aQJS2TnZvtvosKrxYtgrugg_1796365851 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: H7AMC3RQFPXHFKGHJVVJN5W57BQFC5YH X-Message-ID-Hash: H7AMC3RQFPXHFKGHJVVJN5W57BQFC5YH X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, 3 Dec 2026 14:37:10 -0500 Jon Maloy wrote: > On 2026-12-03 10:12, Benjamin Schubert wrote: > > From: Benjamin Schubert > > > [...] > > 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 > > --- > > 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