Skip to content

Commit

Permalink
Merge branch 'nexthop-Small-changes'
Browse files Browse the repository at this point in the history
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: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Sep 15, 2020
2 parents e859536 + 7a5e9d8 commit 897dccb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 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
4 changes: 0 additions & 4 deletions include/net/nexthop.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,9 @@ struct nexthop {
};

enum nexthop_event_type {
NEXTHOP_EVENT_ADD,
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 unregister_nexthop_notifier(struct net *net, struct notifier_block *nb);

Expand Down
17 changes: 9 additions & 8 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 @@ -870,8 +870,6 @@ static void __remove_nexthop_fib(struct net *net, struct nexthop *nh)
bool do_flush = false;
struct fib_info *fi;

call_nexthop_notifiers(net, NEXTHOP_EVENT_DEL, nh);

list_for_each_entry(fi, &nh->fi_list, nh_list) {
fi->fib_flags |= RTNH_F_DEAD;
do_flush = true;
Expand Down Expand Up @@ -909,6 +907,8 @@ static void __remove_nexthop(struct net *net, struct nexthop *nh,
static void remove_nexthop(struct net *net, struct nexthop *nh,
struct nl_info *nlinfo)
{
call_nexthop_notifiers(net, NEXTHOP_EVENT_DEL, nh);

/* remove from the tree */
rb_erase(&nh->rb_node, &net->nexthop.rb_root);

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
14 changes: 14 additions & 0 deletions tools/testing/selftests/net/fib_nexthops.sh
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,16 @@ ipv6_fdb_grp_fcnal()
run_cmd "$IP -6 ro add 2001:db8:101::1/128 nhid 103"
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"
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
}

Expand Down Expand Up @@ -484,9 +491,16 @@ ipv4_fdb_grp_fcnal()
run_cmd "$IP ro add 172.16.0.0/22 nhid 103"
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"
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
}

Expand Down

0 comments on commit 897dccb

Please sign in to comment.