From: Ido Schimmel <idosch@nvidia.com>
To: liamsmith827 <liamsmith827@grapheneos.org>
Cc: netdev@vger.kernel.org, David Ahern <dsahern@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
liamsmith827 <liamsmith827@proton.me>,
stable@vger.kernel.org
Subject: Re: [PATCH net v2 1/4] ipv4: add FIB_LOOKUP_REPORT_MISS
Date: Thu, 12 Nov 2026 21:33:27 +0200 [thread overview]
Message-ID: <20261112193327.GA3410656@shredder> (raw)
In-Reply-To: <20261110061536.10811-2-liamsmith827@grapheneos.org>
On Tue, Nov 10, 2026 at 06:15:33AM +0000, liamsmith827 wrote:
> From: liamsmith827 <liamsmith827@proton.me>
>
> IPv4 FIB lookup maps a routing miss to -ENETUNREACH, which is also
> returned when an unreachable rule is encountered. This flag prevents the
> mapping, returning -ESRCH instead.
Please include the motivation in the commit message. Something like:
"ip_route_output_key_hash_rcu() will need to distinguish between a route
miss and an unreachable rule. Currently, both result in fib_lookup()
returning the same error code (-ENETUNREACH).
Add a new FIB lookup flag that will instruct fib_lookup() to return a
different error code (-ESRCH) when it encounters a route miss."
>
> Cc: stable@vger.kernel.org
> Signed-off-by: liamsmith827 <liamsmith827@proton.me>
> ---
> include/net/fib_rules.h | 5 +++++
> include/net/ip_fib.h | 6 +++---
> net/ipv4/fib_rules.c | 2 +-
> 3 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
> index c6b94790fa81..bcb6809dbd10 100644
> --- a/include/net/fib_rules.h
> +++ b/include/net/fib_rules.h
> @@ -59,6 +59,11 @@ struct fib_lookup_arg {
> int flags;
> #define FIB_LOOKUP_NOREF 1
> #define FIB_LOOKUP_IGNORE_LINKSTATE 2
> +/* Return -ESRCH instead of mapping it to -ENETUNREACH. Only applies to IPv4
> + * lookups. When used with FIB_LOOKUP_NOREF, -ESRCH indicates the lookup
> + * exhausted all rules and tables without finding a usable route.
> + */
The comment seems redundant and IPv4 always sets FIB_LOOKUP_NOREF. I
suggest removing the comment.
> +#define FIB_LOOKUP_REPORT_MISS 4
> };
>
> struct fib_rules_ops {
> diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
> index 92f4eb8b86d7..d0b4f261585a 100644
> --- a/include/net/ip_fib.h
> +++ b/include/net/ip_fib.h
> @@ -318,7 +318,7 @@ static inline int fib_lookup(struct net *net, const struct flowi4 *flp,
> struct fib_result *res, unsigned int flags)
> {
> struct fib_table *tb;
> - int err = -ENETUNREACH;
> + int err = -EAGAIN;
>
> rcu_read_lock();
>
> @@ -327,7 +327,7 @@ static inline int fib_lookup(struct net *net, const struct flowi4 *flp,
> err = fib_table_lookup(tb, flp, res, flags | FIB_LOOKUP_NOREF);
>
> if (err == -EAGAIN)
> - err = -ENETUNREACH;
> + err = (flags & FIB_LOOKUP_REPORT_MISS) ? -ESRCH : -ENETUNREACH;
>
> rcu_read_unlock();
>
> @@ -398,7 +398,7 @@ static inline int fib_lookup(struct net *net, struct flowi4 *flp,
> err = fib_table_lookup(tb, flp, res, flags);
>
> if (err == -EAGAIN)
> - err = -ENETUNREACH;
> + err = (flags & FIB_LOOKUP_REPORT_MISS) ? -ESRCH : -ENETUNREACH;
> out:
> rcu_read_unlock();
>
> diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
> index 060501b376a8..3d7dcb8d0865 100644
> --- a/net/ipv4/fib_rules.c
> +++ b/net/ipv4/fib_rules.c
> @@ -101,7 +101,7 @@ int __fib_lookup(struct net *net, struct flowi4 *flp,
> res->tclassid = 0;
> #endif
>
> - if (err == -ESRCH)
> + if (err == -ESRCH && !(flags & FIB_LOOKUP_REPORT_MISS))
> err = -ENETUNREACH;
>
> return err;
> --
> 2.47.3
>
next prev parent reply other threads:[~2026-11-12 19:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 6:15 [PATCH net v2 0/4] ipv4: restrict on-link fallback to lookup misses liamsmith827
2026-11-10 6:15 ` [PATCH net v2 1/4] ipv4: add FIB_LOOKUP_REPORT_MISS liamsmith827
2026-11-12 19:33 ` Ido Schimmel [this message]
2026-11-10 6:15 ` [PATCH net v2 2/4] ipv4: restrict on-link fallback to lookup misses liamsmith827
2026-11-12 17:38 ` Jakub Kicinski
2026-11-12 21:17 ` netdev-bot+sashiko
2026-11-12 23:08 ` liamsmith827
2026-11-10 6:15 ` [PATCH net v2 3/4] selftests: net: test restricted on-link fallback liamsmith827
2026-11-10 6:15 ` [PATCH net v2 4/4] ipv4: replace obsolete routing comment liamsmith827
2026-11-12 21:17 ` netdev-bot+sashiko
2026-11-12 23:10 ` liamsmith827
2026-11-12 17:13 ` [PATCH net v2 0/4] ipv4: restrict on-link fallback to lookup misses Ido Schimmel
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=20261112193327.GA3410656@shredder \
--to=idosch@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=liamsmith827@grapheneos.org \
--cc=liamsmith827@proton.me \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=stable@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.