Commit 897dccb8 authored by David S. Miller's avatar David S. Miller

Merge branch 'nexthop-Small-changes'

Ido Schimmel says:

====================
nexthop: Small changes

This patch set contains a few small changes that I split out of the RFC
I sent last week [1]. Main change is the conversion of the nexthop
notification chain to a blocking chain so that it could be reused by
device drivers for nexthop objects programming in the future.

Tested with fib_nexthops.sh:

Tests passed: 164
Tests failed:   0

[1] https://lore.kernel.org/netdev/20200908091037.2709823-1-idosch@idosch.org/
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents e859536d 7a5e9d84
...@@ -14,6 +14,6 @@ struct netns_nexthop { ...@@ -14,6 +14,6 @@ struct netns_nexthop {
unsigned int seq; /* protected by rtnl_mutex */ unsigned int seq; /* protected by rtnl_mutex */
u32 last_id_allocated; u32 last_id_allocated;
struct atomic_notifier_head notifier_chain; struct blocking_notifier_head notifier_chain;
}; };
#endif #endif
...@@ -105,13 +105,9 @@ struct nexthop { ...@@ -105,13 +105,9 @@ struct nexthop {
}; };
enum nexthop_event_type { enum nexthop_event_type {
NEXTHOP_EVENT_ADD,
NEXTHOP_EVENT_DEL NEXTHOP_EVENT_DEL
}; };
int call_nexthop_notifier(struct notifier_block *nb, struct net *net,
enum nexthop_event_type event_type,
struct nexthop *nh);
int register_nexthop_notifier(struct net *net, struct notifier_block *nb); int register_nexthop_notifier(struct net *net, struct notifier_block *nb);
int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb); int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb);
......
...@@ -42,8 +42,8 @@ static int call_nexthop_notifiers(struct net *net, ...@@ -42,8 +42,8 @@ static int call_nexthop_notifiers(struct net *net,
{ {
int err; int err;
err = atomic_notifier_call_chain(&net->nexthop.notifier_chain, err = blocking_notifier_call_chain(&net->nexthop.notifier_chain,
event_type, nh); event_type, nh);
return notifier_to_errno(err); return notifier_to_errno(err);
} }
...@@ -870,8 +870,6 @@ static void __remove_nexthop_fib(struct net *net, struct nexthop *nh) ...@@ -870,8 +870,6 @@ static void __remove_nexthop_fib(struct net *net, struct nexthop *nh)
bool do_flush = false; bool do_flush = false;
struct fib_info *fi; struct fib_info *fi;
call_nexthop_notifiers(net, NEXTHOP_EVENT_DEL, nh);
list_for_each_entry(fi, &nh->fi_list, nh_list) { list_for_each_entry(fi, &nh->fi_list, nh_list) {
fi->fib_flags |= RTNH_F_DEAD; fi->fib_flags |= RTNH_F_DEAD;
do_flush = true; do_flush = true;
...@@ -909,6 +907,8 @@ static void __remove_nexthop(struct net *net, struct nexthop *nh, ...@@ -909,6 +907,8 @@ static void __remove_nexthop(struct net *net, struct nexthop *nh,
static void remove_nexthop(struct net *net, struct nexthop *nh, static void remove_nexthop(struct net *net, struct nexthop *nh,
struct nl_info *nlinfo) struct nl_info *nlinfo)
{ {
call_nexthop_notifiers(net, NEXTHOP_EVENT_DEL, nh);
/* remove from the tree */ /* remove from the tree */
rb_erase(&nh->rb_node, &net->nexthop.rb_root); rb_erase(&nh->rb_node, &net->nexthop.rb_root);
...@@ -1959,14 +1959,15 @@ static struct notifier_block nh_netdev_notifier = { ...@@ -1959,14 +1959,15 @@ static struct notifier_block nh_netdev_notifier = {
int register_nexthop_notifier(struct net *net, struct notifier_block *nb) 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); 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)
{ {
return atomic_notifier_chain_unregister(&net->nexthop.notifier_chain, return blocking_notifier_chain_unregister(&net->nexthop.notifier_chain,
nb); nb);
} }
EXPORT_SYMBOL(unregister_nexthop_notifier); EXPORT_SYMBOL(unregister_nexthop_notifier);
...@@ -1986,7 +1987,7 @@ static int __net_init nexthop_net_init(struct net *net) ...@@ -1986,7 +1987,7 @@ static int __net_init nexthop_net_init(struct net *net)
net->nexthop.devhash = kzalloc(sz, GFP_KERNEL); net->nexthop.devhash = kzalloc(sz, GFP_KERNEL);
if (!net->nexthop.devhash) if (!net->nexthop.devhash)
return -ENOMEM; return -ENOMEM;
ATOMIC_INIT_NOTIFIER_HEAD(&net->nexthop.notifier_chain); BLOCKING_INIT_NOTIFIER_HEAD(&net->nexthop.notifier_chain);
return 0; return 0;
} }
......
...@@ -411,9 +411,16 @@ ipv6_fdb_grp_fcnal() ...@@ -411,9 +411,16 @@ ipv6_fdb_grp_fcnal()
run_cmd "$IP -6 ro add 2001:db8:101::1/128 nhid 103" run_cmd "$IP -6 ro add 2001:db8:101::1/128 nhid 103"
log_test $? 2 "Route add with fdb nexthop group" log_test $? 2 "Route add with fdb nexthop group"
run_cmd "$IP nexthop del id 61"
run_cmd "$BRIDGE fdb get to 02:02:00:00:00:13 dev vx10 self"
log_test $? 0 "Fdb entry after deleting a single nexthop"
run_cmd "$IP nexthop del id 102" run_cmd "$IP nexthop del id 102"
log_test $? 0 "Fdb nexthop delete" log_test $? 0 "Fdb nexthop delete"
run_cmd "$BRIDGE fdb get to 02:02:00:00:00:13 dev vx10 self"
log_test $? 254 "Fdb entry after deleting a nexthop group"
$IP link del dev vx10 $IP link del dev vx10
} }
...@@ -484,9 +491,16 @@ ipv4_fdb_grp_fcnal() ...@@ -484,9 +491,16 @@ ipv4_fdb_grp_fcnal()
run_cmd "$IP ro add 172.16.0.0/22 nhid 103" run_cmd "$IP ro add 172.16.0.0/22 nhid 103"
log_test $? 2 "Route add with fdb nexthop group" log_test $? 2 "Route add with fdb nexthop group"
run_cmd "$IP nexthop del id 12"
run_cmd "$BRIDGE fdb get to 02:02:00:00:00:13 dev vx10 self"
log_test $? 0 "Fdb entry after deleting a single nexthop"
run_cmd "$IP nexthop del id 102" run_cmd "$IP nexthop del id 102"
log_test $? 0 "Fdb nexthop delete" log_test $? 0 "Fdb nexthop delete"
run_cmd "$BRIDGE fdb get to 02:02:00:00:00:13 dev vx10 self"
log_test $? 254 "Fdb entry after deleting a nexthop group"
$IP link del dev vx10 $IP link del dev vx10
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment