From: David Ahern <dsahern@kernel.org>
To: netdev@vger.kernel.org
Cc: dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, ralf@mandelbit.com, ja@ssi.bg,
David Ahern <dahern@nvidia.com>
Subject: [PATCH net-next v2 08/13] nexthop: factor out nh_has_f6i()
Date: Wed, 25 Nov 2026 18:33:34 -0700 [thread overview]
Message-ID: <445f336e64d9d09682c9c9d5cd01d2e6ac290004.1795642432.git.dahern@nvidia.com> (raw)
In-Reply-To: <cover.1795642432.git.dahern@nvidia.com>
From: David Ahern <dahern@nvidia.com>
nh_rt_cache_flush() open codes a locked check of whether any IPv6
routes use a nexthop. Move it into a helper, placed ahead of
remove_nexthop_from_groups(), so the next patch can use it there as
well.
No functional change.
Signed-off-by: David Ahern <dahern@nvidia.com>
---
net/ipv4/nexthop.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 42e55b5a755e..53431fe7d328 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -2109,6 +2109,17 @@ remove_nh_grp_entry(struct net *net, struct nh_grp_entry *nhge,
return false;
}
+static bool nh_has_f6i(struct nexthop *nh)
+{
+ bool have_f6i;
+
+ spin_lock_bh(&nh->lock);
+ have_f6i = !list_empty(&nh->f6i_list);
+ spin_unlock_bh(&nh->lock);
+
+ return have_f6i;
+}
+
static bool __must_check
remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
struct nl_info *nlinfo)
@@ -2248,16 +2259,12 @@ static void nh_rt_cache_flush(struct net *net, struct nexthop *nh,
struct nexthop *replaced_nh)
{
struct nh_group *nhg;
- bool have_f6i;
int i;
if (!list_empty(&nh->fi_list))
rt_cache_flush(net);
- spin_lock_bh(&nh->lock);
- have_f6i = !list_empty(&nh->f6i_list);
- spin_unlock_bh(&nh->lock);
- if (have_f6i)
+ if (nh_has_f6i(nh))
rt_genid_bump_ipv6(net);
/* if an IPv6 group was replaced, we have to release all old
--
2.54.0 (Apple Git-157)
next prev parent reply other threads:[~2026-11-26 1:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 1:33 [PATCH net-next v2 00/13] ipv6: validate cached dsts against the netns route generation David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 01/13] ipv6: allocate the exception entry before removing the one it replaces David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 02/13] ipv6: keep a superseded pcpu dst working until its holders notice David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 03/13] ipv6: don't insert a PMTU exception whose MTU could not be stored David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 04/13] ipv6: invalidate the failing dst in ip6_link_failure() David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 05/13] ipv6: tell route dumps about exception inserts with a table sequence David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 06/13] ipv6: validate dsts against the netns route generation David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 07/13] ipv6: make rt_genid_bump_ipv6() a plain counter increment David Ahern
2026-11-26 1:33 ` David Ahern [this message]
2026-11-26 1:33 ` [PATCH net-next v2 09/13] nexthop: bump the IPv6 route generation on group changes David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 10/13] ipv6: stamp dsts with the generation sampled before the FIB lookup David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 11/13] selftests: net: pmtu: check that a deleted cached exception stays deleted David Ahern
2026-11-26 1:33 ` [PATCH net-next v2 12/13] selftests: net: fib_tests: Add stale pcpu test 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=445f336e64d9d09682c9c9d5cd01d2e6ac290004.1795642432.git.dahern@nvidia.com \
--to=dsahern@kernel.org \
--cc=dahern@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=ja@ssi.bg \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ralf@mandelbit.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