ipv4: add __unregister_nexthop_notifier()
authorEric Dumazet <edumazet@google.com>
Tue, 6 Feb 2024 14:43:04 +0000 (14:43 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 8 Feb 2024 02:55:11 +0000 (18:55 -0800)
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 <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Reviewed-by: Antoine Tenart <atenart@kernel.org>
Link: https://lore.kernel.org/r/20240206144313.2050392-9-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/nexthop.h
net/ipv4/nexthop.c

index d92046a4a078250eec528f3cb2c3ab557decad03..6647ad509faa02a9a13d58f3405c4a540abc5077 100644 (file)
@@ -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,
index 7270a8631406c508eebf85c42eb29a5268d7d7cf..70509da4f0806d25b3707835c08888d5e57b782e 100644 (file)
@@ -3631,17 +3631,24 @@ unlock:
 }
 EXPORT_SYMBOL(register_nexthop_notifier);
 
-int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb)
+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:
+       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 = __unregister_nexthop_notifier(net, nb);
        rtnl_unlock();
        return err;
 }