Skip to content

Commit

Permalink
ipv4: add __unregister_nexthop_notifier()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Dumazet authored and Jakub Kicinski committed Feb 8, 2024
1 parent 6eedda0 commit 70f16ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/net/nexthop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 13 additions & 6 deletions net/ipv4/nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -3631,17 +3631,24 @@ int register_nexthop_notifier(struct net *net, struct notifier_block *nb,
}
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;
}
Expand Down

0 comments on commit 70f16ea

Please sign in to comment.