Skip to content

Commit 897dccb

Browse files
committed
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/[email protected]/ ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents e859536 + 7a5e9d8 commit 897dccb

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

include/net/netns/nexthop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ struct netns_nexthop {
1414

1515
unsigned int seq; /* protected by rtnl_mutex */
1616
u32 last_id_allocated;
17-
struct atomic_notifier_head notifier_chain;
17+
struct blocking_notifier_head notifier_chain;
1818
};
1919
#endif

include/net/nexthop.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,9 @@ struct nexthop {
105105
};
106106

107107
enum nexthop_event_type {
108-
NEXTHOP_EVENT_ADD,
109108
NEXTHOP_EVENT_DEL
110109
};
111110

112-
int call_nexthop_notifier(struct notifier_block *nb, struct net *net,
113-
enum nexthop_event_type event_type,
114-
struct nexthop *nh);
115111
int register_nexthop_notifier(struct net *net, struct notifier_block *nb);
116112
int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb);
117113

net/ipv4/nexthop.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ static int call_nexthop_notifiers(struct net *net,
4242
{
4343
int err;
4444

45-
err = atomic_notifier_call_chain(&net->nexthop.notifier_chain,
46-
event_type, nh);
45+
err = blocking_notifier_call_chain(&net->nexthop.notifier_chain,
46+
event_type, nh);
4747
return notifier_to_errno(err);
4848
}
4949

@@ -870,8 +870,6 @@ static void __remove_nexthop_fib(struct net *net, struct nexthop *nh)
870870
bool do_flush = false;
871871
struct fib_info *fi;
872872

873-
call_nexthop_notifiers(net, NEXTHOP_EVENT_DEL, nh);
874-
875873
list_for_each_entry(fi, &nh->fi_list, nh_list) {
876874
fi->fib_flags |= RTNH_F_DEAD;
877875
do_flush = true;
@@ -909,6 +907,8 @@ static void __remove_nexthop(struct net *net, struct nexthop *nh,
909907
static void remove_nexthop(struct net *net, struct nexthop *nh,
910908
struct nl_info *nlinfo)
911909
{
910+
call_nexthop_notifiers(net, NEXTHOP_EVENT_DEL, nh);
911+
912912
/* remove from the tree */
913913
rb_erase(&nh->rb_node, &net->nexthop.rb_root);
914914

@@ -1959,14 +1959,15 @@ static struct notifier_block nh_netdev_notifier = {
19591959

19601960
int register_nexthop_notifier(struct net *net, struct notifier_block *nb)
19611961
{
1962-
return atomic_notifier_chain_register(&net->nexthop.notifier_chain, nb);
1962+
return blocking_notifier_chain_register(&net->nexthop.notifier_chain,
1963+
nb);
19631964
}
19641965
EXPORT_SYMBOL(register_nexthop_notifier);
19651966

19661967
int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb)
19671968
{
1968-
return atomic_notifier_chain_unregister(&net->nexthop.notifier_chain,
1969-
nb);
1969+
return blocking_notifier_chain_unregister(&net->nexthop.notifier_chain,
1970+
nb);
19701971
}
19711972
EXPORT_SYMBOL(unregister_nexthop_notifier);
19721973

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

19911992
return 0;
19921993
}

tools/testing/selftests/net/fib_nexthops.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,16 @@ ipv6_fdb_grp_fcnal()
411411
run_cmd "$IP -6 ro add 2001:db8:101::1/128 nhid 103"
412412
log_test $? 2 "Route add with fdb nexthop group"
413413

414+
run_cmd "$IP nexthop del id 61"
415+
run_cmd "$BRIDGE fdb get to 02:02:00:00:00:13 dev vx10 self"
416+
log_test $? 0 "Fdb entry after deleting a single nexthop"
417+
414418
run_cmd "$IP nexthop del id 102"
415419
log_test $? 0 "Fdb nexthop delete"
416420

421+
run_cmd "$BRIDGE fdb get to 02:02:00:00:00:13 dev vx10 self"
422+
log_test $? 254 "Fdb entry after deleting a nexthop group"
423+
417424
$IP link del dev vx10
418425
}
419426

@@ -484,9 +491,16 @@ ipv4_fdb_grp_fcnal()
484491
run_cmd "$IP ro add 172.16.0.0/22 nhid 103"
485492
log_test $? 2 "Route add with fdb nexthop group"
486493

494+
run_cmd "$IP nexthop del id 12"
495+
run_cmd "$BRIDGE fdb get to 02:02:00:00:00:13 dev vx10 self"
496+
log_test $? 0 "Fdb entry after deleting a single nexthop"
497+
487498
run_cmd "$IP nexthop del id 102"
488499
log_test $? 0 "Fdb nexthop delete"
489500

501+
run_cmd "$BRIDGE fdb get to 02:02:00:00:00:13 dev vx10 self"
502+
log_test $? 254 "Fdb entry after deleting a nexthop group"
503+
490504
$IP link del dev vx10
491505
}
492506

0 commit comments

Comments
 (0)