From: Ido Schimmel <idosch@nvidia.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com, dsahern@kernel.org, horms@kernel.org,
willemb@google.com
Subject: Re: [PATCH net-next v2 1/2] ipv6: Honor oif when choosing nexthop for locally generated traffic
Date: Tue, 2 Jun 2026 14:49:35 +0300 [thread overview]
Message-ID: <20260602114935.GA496834@shredder> (raw)
In-Reply-To: <20260601065300.267960-2-idosch@nvidia.com>
On Mon, Jun 01, 2026 at 09:52:59AM +0300, Ido Schimmel wrote:
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index b106e5fef9cb..14633fd72288 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -2272,6 +2272,7 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
> {
> struct fib6_result res = {};
> struct rt6_info *rt = NULL;
> + bool have_oif_match;
> int strict = 0;
>
> WARN_ON_ONCE((flags & RT6_LOOKUP_F_DST_NOREF) &&
> @@ -2288,7 +2289,9 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
> if (res.f6i == net->ipv6.fib6_null_entry)
> goto out;
>
> - fib6_select_path(net, &res, fl6, oif, false, skb, strict);
> + have_oif_match = fl6->flowi6_iif == LOOPBACK_IFINDEX &&
> + oif == res.nh->fib_nh_dev->ifindex;
> + fib6_select_path(net, &res, fl6, oif, have_oif_match, skb, strict);
>
> /*Search through exception table */
> rt = rt6_find_cached_rt(&res, &fl6->daddr, &fl6->saddr);
The patch is fine as-is, but Sashiko [1] is correct that there is a
pre-existing issue when the route is using a nexthop group object. I
will prepend a patch for this in the next version and add test cases.
pw-bot: changes-requested
[1]
This is a pre-existing issue, but does this logic leave the regression unfixed
for routes using Nexthop objects?
The fix relies on res.nh containing the best matching path. However, when a
source address is specified, RT6_LOOKUP_F_IFACE is not set. For Nexthop
objects, the lookup in __find_rr_leaf() evaluates paths using
nexthop_for_each_fib6_nh() with the rt6_nh_find_match() callback.
Because the initial score (*mpri) is -1, the first valid (but non-matching)
path will score 0, which causes find_match() to return true. This aborts the
iteration immediately, without evaluating subsequent paths that might be an
exact oif match (which would score 2).
As a result, in ip6_pol_route(), res.nh is assigned an arbitrary path. The
have_oif_match variable evaluates to false, and the code incorrectly falls
back to hash-based selection via nexthop_path_fib6_result() for Nexthop
objects.
next prev parent reply other threads:[~2026-06-02 11:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 6:52 [PATCH net-next v2 0/2] ipv6: Honor oif when choosing nexthop for locally generated traffic Ido Schimmel
2026-06-01 6:52 ` [PATCH net-next v2 1/2] " Ido Schimmel
2026-06-02 2:51 ` David Ahern
2026-06-02 11:49 ` Ido Schimmel [this message]
2026-06-01 6:53 ` [PATCH net-next v2 2/2] selftests: fib_tests: Add test cases for route lookup with oif Ido Schimmel
2026-06-02 2:53 ` David Ahern
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=20260602114935.GA496834@shredder \
--to=idosch@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox