Skip to content

Commit

Permalink
nexthop: Convert to blocking notification chain
Browse files Browse the repository at this point in the history
Currently, the only listener of the nexthop notification chain is the
VXLAN driver. Subsequent patches will add more listeners (e.g., device
drivers such as netdevsim) that need to be able to block when processing
notifications.

Therefore, convert the notification chain to a blocking one. This is
safe as notifications are always emitted from process context.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ido Schimmel authored and David S. Miller committed Sep 15, 2020
1 parent 52f7232 commit 80690ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/net/netns/nexthop.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ struct netns_nexthop {

unsigned int seq; /* protected by rtnl_mutex */
u32 last_id_allocated;
struct atomic_notifier_head notifier_chain;
struct blocking_notifier_head notifier_chain;
};
#endif
13 changes: 7 additions & 6 deletions net/ipv4/nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ static int call_nexthop_notifiers(struct net *net,
{
int err;

err = atomic_notifier_call_chain(&net->nexthop.notifier_chain,
event_type, nh);
err = blocking_notifier_call_chain(&net->nexthop.notifier_chain,
event_type, nh);
return notifier_to_errno(err);
}

Expand Down Expand Up @@ -1959,14 +1959,15 @@ static struct notifier_block nh_netdev_notifier = {

int register_nexthop_notifier(struct net *net, struct notifier_block *nb)
{
return atomic_notifier_chain_register(&net->nexthop.notifier_chain, nb);
return blocking_notifier_chain_register(&net->nexthop.notifier_chain,
nb);
}
EXPORT_SYMBOL(register_nexthop_notifier);

int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb)
{
return atomic_notifier_chain_unregister(&net->nexthop.notifier_chain,
nb);
return blocking_notifier_chain_unregister(&net->nexthop.notifier_chain,
nb);
}
EXPORT_SYMBOL(unregister_nexthop_notifier);

Expand All @@ -1986,7 +1987,7 @@ static int __net_init nexthop_net_init(struct net *net)
net->nexthop.devhash = kzalloc(sz, GFP_KERNEL);
if (!net->nexthop.devhash)
return -ENOMEM;
ATOMIC_INIT_NOTIFIER_HEAD(&net->nexthop.notifier_chain);
BLOCKING_INIT_NOTIFIER_HEAD(&net->nexthop.notifier_chain);

return 0;
}
Expand Down

0 comments on commit 80690ec

Please sign in to comment.