From 70f16ea2e4f673fc769fd13c00c20a32b4fe238a Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 6 Feb 2024 14:43:04 +0000 Subject: [PATCH] ipv4: add __unregister_nexthop_notifier() unregister_nexthop_notifier() assumes the caller does not hold rtnl. We need in the following patch to use it from a context already holding rtnl. Add __unregister_nexthop_notifier(). unregister_nexthop_notifier() becomes a wrapper. Signed-off-by: Eric Dumazet Reviewed-by: David Ahern Reviewed-by: Antoine Tenart Link: https://lore.kernel.org/r/20240206144313.2050392-9-edumazet@google.com Signed-off-by: Jakub Kicinski --- include/net/nexthop.h | 1 + net/ipv4/nexthop.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/net/nexthop.h b/include/net/nexthop.h index d92046a4a078..6647ad509faa 100644 --- a/include/net/nexthop.h +++ b/include/net/nexthop.h @@ -218,6 +218,7 @@ struct nh_notifier_info { int register_nexthop_notifier(struct net *net, struct notifier_block *nb, struct netlink_ext_ack *extack); +int __unregister_nexthop_notifier(struct net *net, struct notifier_block *nb); int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb); void nexthop_set_hw_flags(struct net *net, u32 id, bool offload, bool trap); void nexthop_bucket_set_hw_flags(struct net *net, u32 id, u16 bucket_index, diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index 7270a8631406..70509da4f080 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -3631,17 +3631,24 @@ unlock: } EXPORT_SYMBOL(register_nexthop_notifier); +int __unregister_nexthop_notifier(struct net *net, struct notifier_block *nb) +{ + int err; + + err = blocking_notifier_chain_unregister(&net->nexthop.notifier_chain, + nb); + if (!err) + nexthops_dump(net, nb, NEXTHOP_EVENT_DEL, NULL); + return err; +} +EXPORT_SYMBOL(__unregister_nexthop_notifier); + int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb) { int err; rtnl_lock(); - err = blocking_notifier_chain_unregister(&net->nexthop.notifier_chain, - nb); - if (err) - goto unlock; - nexthops_dump(net, nb, NEXTHOP_EVENT_DEL, NULL); -unlock: + err = __unregister_nexthop_notifier(net, nb); rtnl_unlock(); return err; }