All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/5] nexthop: Small changes
@ 2020-09-15 11:40 Ido Schimmel
  2020-09-15 11:40 ` [PATCH net-next 1/5] nexthop: Remove unused function declaration from header file Ido Schimmel
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Ido Schimmel @ 2020-09-15 11:40 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, dsahern, mlxsw, Ido Schimmel

From: Ido Schimmel <idosch@nvidia.com>

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/

Ido Schimmel (5):
  nexthop: Remove unused function declaration from header file
  nexthop: Remove NEXTHOP_EVENT_ADD
  nexthop: Convert to blocking notification chain
  nexthop: Only emit a notification when nexthop is actually deleted
  selftests: fib_nexthops: Test cleanup of FDB entries following nexthop
    deletion

 include/net/netns/nexthop.h                 |  2 +-
 include/net/nexthop.h                       |  4 ----
 net/ipv4/nexthop.c                          | 17 +++++++++--------
 tools/testing/selftests/net/fib_nexthops.sh | 14 ++++++++++++++
 4 files changed, 24 insertions(+), 13 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next 1/5] nexthop: Remove unused function declaration from header file
  2020-09-15 11:40 [PATCH net-next 0/5] nexthop: Small changes Ido Schimmel
@ 2020-09-15 11:40 ` Ido Schimmel
  2020-09-15 11:41 ` [PATCH net-next 2/5] nexthop: Remove NEXTHOP_EVENT_ADD Ido Schimmel
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2020-09-15 11:40 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, dsahern, mlxsw, Ido Schimmel

From: Ido Schimmel <idosch@nvidia.com>

Not used or implemented anywhere.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
---
 include/net/nexthop.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/net/nexthop.h b/include/net/nexthop.h
index 3a4f9e3b91a5..2e44efe5709b 100644
--- a/include/net/nexthop.h
+++ b/include/net/nexthop.h
@@ -109,9 +109,6 @@ enum nexthop_event_type {
 	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);
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 2/5] nexthop: Remove NEXTHOP_EVENT_ADD
  2020-09-15 11:40 [PATCH net-next 0/5] nexthop: Small changes Ido Schimmel
  2020-09-15 11:40 ` [PATCH net-next 1/5] nexthop: Remove unused function declaration from header file Ido Schimmel
@ 2020-09-15 11:41 ` Ido Schimmel
  2020-09-15 11:41 ` [PATCH net-next 3/5] nexthop: Convert to blocking notification chain Ido Schimmel
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2020-09-15 11:41 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, dsahern, mlxsw, Ido Schimmel

From: Ido Schimmel <idosch@nvidia.com>

Not used anywhere.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Suggested-by: David Ahern <dsahern@gmail.com>
---
 include/net/nexthop.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/net/nexthop.h b/include/net/nexthop.h
index 2e44efe5709b..2fd76a9b6dc8 100644
--- a/include/net/nexthop.h
+++ b/include/net/nexthop.h
@@ -105,7 +105,6 @@ struct nexthop {
 };
 
 enum nexthop_event_type {
-	NEXTHOP_EVENT_ADD,
 	NEXTHOP_EVENT_DEL
 };
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 3/5] nexthop: Convert to blocking notification chain
  2020-09-15 11:40 [PATCH net-next 0/5] nexthop: Small changes Ido Schimmel
  2020-09-15 11:40 ` [PATCH net-next 1/5] nexthop: Remove unused function declaration from header file Ido Schimmel
  2020-09-15 11:41 ` [PATCH net-next 2/5] nexthop: Remove NEXTHOP_EVENT_ADD Ido Schimmel
@ 2020-09-15 11:41 ` Ido Schimmel
  2020-09-15 11:41 ` [PATCH net-next 4/5] nexthop: Only emit a notification when nexthop is actually deleted Ido Schimmel
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2020-09-15 11:41 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, dsahern, mlxsw, Ido Schimmel

From: Ido Schimmel <idosch@nvidia.com>

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>
---
 include/net/netns/nexthop.h |  2 +-
 net/ipv4/nexthop.c          | 13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/include/net/netns/nexthop.h b/include/net/netns/nexthop.h
index 1937476c94a0..1849e77eb68a 100644
--- a/include/net/netns/nexthop.h
+++ b/include/net/netns/nexthop.h
@@ -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
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index bf9d4cd2d6e5..13d9219a9aa1 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -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);
 }
 
@@ -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);
 
@@ -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;
 }
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 4/5] nexthop: Only emit a notification when nexthop is actually deleted
  2020-09-15 11:40 [PATCH net-next 0/5] nexthop: Small changes Ido Schimmel
                   ` (2 preceding siblings ...)
  2020-09-15 11:41 ` [PATCH net-next 3/5] nexthop: Convert to blocking notification chain Ido Schimmel
@ 2020-09-15 11:41 ` Ido Schimmel
  2020-09-15 11:41 ` [PATCH net-next 5/5] selftests: fib_nexthops: Test cleanup of FDB entries following nexthop deletion Ido Schimmel
  2020-09-15 23:32 ` [PATCH net-next 0/5] nexthop: Small changes David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2020-09-15 11:41 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, dsahern, mlxsw, Ido Schimmel

From: Ido Schimmel <idosch@nvidia.com>

Currently, the in-kernel delete notification is emitted from the error
path of nexthop_add() and replace_nexthop(), which can be confusing to
in-kernel listeners as they are not familiar with the nexthop.

Instead, only emit the notification when the nexthop is actually
deleted. The following sub-cases are covered:

1. User space deletes the nexthop
2. The nexthop is deleted by the kernel due to a netdev event (e.g.,
   nexthop device going down)
3. A group is deleted because its last nexthop is being deleted
4. The network namespace of the nexthop device is deleted

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
---
 net/ipv4/nexthop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 13d9219a9aa1..8c0f17c6863c 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -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;
@@ -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);
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 5/5] selftests: fib_nexthops: Test cleanup of FDB entries following nexthop deletion
  2020-09-15 11:40 [PATCH net-next 0/5] nexthop: Small changes Ido Schimmel
                   ` (3 preceding siblings ...)
  2020-09-15 11:41 ` [PATCH net-next 4/5] nexthop: Only emit a notification when nexthop is actually deleted Ido Schimmel
@ 2020-09-15 11:41 ` Ido Schimmel
  2020-09-15 23:32 ` [PATCH net-next 0/5] nexthop: Small changes David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2020-09-15 11:41 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, dsahern, mlxsw, Ido Schimmel

From: Ido Schimmel <idosch@nvidia.com>

Commit c7cdbe2efc40 ("vxlan: support for nexthop notifiers") registered
a listener in the VXLAN driver to the nexthop notification chain. Its
purpose is to cleanup FDB entries that use a nexthop that is being
deleted.

Test that such FDB entries are removed when the nexthop group that they
use is deleted. Test that entries are not deleted when a single nexthop
in the group is deleted.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
---
 tools/testing/selftests/net/fib_nexthops.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tools/testing/selftests/net/fib_nexthops.sh b/tools/testing/selftests/net/fib_nexthops.sh
index b74884d52913..eb693a3b7b4a 100755
--- a/tools/testing/selftests/net/fib_nexthops.sh
+++ b/tools/testing/selftests/net/fib_nexthops.sh
@@ -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
 }
 
@@ -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
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 0/5] nexthop: Small changes
  2020-09-15 11:40 [PATCH net-next 0/5] nexthop: Small changes Ido Schimmel
                   ` (4 preceding siblings ...)
  2020-09-15 11:41 ` [PATCH net-next 5/5] selftests: fib_nexthops: Test cleanup of FDB entries following nexthop deletion Ido Schimmel
@ 2020-09-15 23:32 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2020-09-15 23:32 UTC (permalink / raw)
  To: idosch; +Cc: netdev, kuba, dsahern, mlxsw, idosch

From: Ido Schimmel <idosch@idosch.org>
Date: Tue, 15 Sep 2020 14:40:58 +0300

> From: Ido Schimmel <idosch@nvidia.com>
> 
> 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/

Series applied, thank you.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-09-16  0:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15 11:40 [PATCH net-next 0/5] nexthop: Small changes Ido Schimmel
2020-09-15 11:40 ` [PATCH net-next 1/5] nexthop: Remove unused function declaration from header file Ido Schimmel
2020-09-15 11:41 ` [PATCH net-next 2/5] nexthop: Remove NEXTHOP_EVENT_ADD Ido Schimmel
2020-09-15 11:41 ` [PATCH net-next 3/5] nexthop: Convert to blocking notification chain Ido Schimmel
2020-09-15 11:41 ` [PATCH net-next 4/5] nexthop: Only emit a notification when nexthop is actually deleted Ido Schimmel
2020-09-15 11:41 ` [PATCH net-next 5/5] selftests: fib_nexthops: Test cleanup of FDB entries following nexthop deletion Ido Schimmel
2020-09-15 23:32 ` [PATCH net-next 0/5] nexthop: Small changes David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.