* [PATCH net-next] vxlan: Use a per-namespace nexthop listener instead of a global one
@ 2020-11-01 11:39 Ido Schimmel
2020-11-03 1:45 ` David Ahern
0 siblings, 1 reply; 3+ messages in thread
From: Ido Schimmel @ 2020-11-01 11:39 UTC (permalink / raw)
To: netdev; +Cc: davem, kuba, roopa, dsahern, mlxsw, Ido Schimmel
From: Ido Schimmel <idosch@nvidia.com>
The nexthop notification chain is a per-namespace chain and not a global
one like the netdev notification chain.
Therefore, a single (global) listener cannot be registered to all these
chains simultaneously as it will result in list corruptions whenever
listeners are registered / unregistered.
Instead, register a different listener in each namespace.
Currently this is not an issue because only the VXLAN driver registers a
listener to this chain, but this is going to change with netdevsim and
mlxsw also registering their own listeners.
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
drivers/net/vxlan.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 1a557aeba32b..876679af6f7c 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -66,6 +66,7 @@ struct vxlan_net {
struct list_head vxlan_list;
struct hlist_head sock_list[PORT_HASH_SIZE];
spinlock_t sock_lock;
+ struct notifier_block nexthop_notifier_block;
};
/* Forwarding table entry */
@@ -4693,10 +4694,6 @@ static int vxlan_nexthop_event(struct notifier_block *nb,
return NOTIFY_DONE;
}
-static struct notifier_block vxlan_nexthop_notifier_block __read_mostly = {
- .notifier_call = vxlan_nexthop_event,
-};
-
static __net_init int vxlan_init_net(struct net *net)
{
struct vxlan_net *vn = net_generic(net, vxlan_net_id);
@@ -4704,11 +4701,12 @@ static __net_init int vxlan_init_net(struct net *net)
INIT_LIST_HEAD(&vn->vxlan_list);
spin_lock_init(&vn->sock_lock);
+ vn->nexthop_notifier_block.notifier_call = vxlan_nexthop_event;
for (h = 0; h < PORT_HASH_SIZE; ++h)
INIT_HLIST_HEAD(&vn->sock_list[h]);
- return register_nexthop_notifier(net, &vxlan_nexthop_notifier_block);
+ return register_nexthop_notifier(net, &vn->nexthop_notifier_block);
}
static void vxlan_destroy_tunnels(struct net *net, struct list_head *head)
@@ -4740,8 +4738,11 @@ static void __net_exit vxlan_exit_batch_net(struct list_head *net_list)
LIST_HEAD(list);
rtnl_lock();
- list_for_each_entry(net, net_list, exit_list)
- unregister_nexthop_notifier(net, &vxlan_nexthop_notifier_block);
+ list_for_each_entry(net, net_list, exit_list) {
+ struct vxlan_net *vn = net_generic(net, vxlan_net_id);
+
+ unregister_nexthop_notifier(net, &vn->nexthop_notifier_block);
+ }
list_for_each_entry(net, net_list, exit_list)
vxlan_destroy_tunnels(net, &list);
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] vxlan: Use a per-namespace nexthop listener instead of a global one
2020-11-01 11:39 [PATCH net-next] vxlan: Use a per-namespace nexthop listener instead of a global one Ido Schimmel
@ 2020-11-03 1:45 ` David Ahern
2020-11-03 23:24 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: David Ahern @ 2020-11-03 1:45 UTC (permalink / raw)
To: Ido Schimmel, netdev; +Cc: davem, kuba, roopa, mlxsw, Ido Schimmel
On 11/1/20 4:39 AM, Ido Schimmel wrote:
> From: Ido Schimmel <idosch@nvidia.com>
>
> The nexthop notification chain is a per-namespace chain and not a global
> one like the netdev notification chain.
>
> Therefore, a single (global) listener cannot be registered to all these
> chains simultaneously as it will result in list corruptions whenever
> listeners are registered / unregistered.
>
> Instead, register a different listener in each namespace.
>
> Currently this is not an issue because only the VXLAN driver registers a
> listener to this chain, but this is going to change with netdevsim and
> mlxsw also registering their own listeners.
>
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> ---
> drivers/net/vxlan.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] vxlan: Use a per-namespace nexthop listener instead of a global one
2020-11-03 1:45 ` David Ahern
@ 2020-11-03 23:24 ` Jakub Kicinski
0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2020-11-03 23:24 UTC (permalink / raw)
To: David Ahern; +Cc: Ido Schimmel, netdev, davem, roopa, mlxsw, Ido Schimmel
On Mon, 2 Nov 2020 18:45:10 -0700 David Ahern wrote:
> On 11/1/20 4:39 AM, Ido Schimmel wrote:
> > From: Ido Schimmel <idosch@nvidia.com>
> >
> > The nexthop notification chain is a per-namespace chain and not a global
> > one like the netdev notification chain.
> >
> > Therefore, a single (global) listener cannot be registered to all these
> > chains simultaneously as it will result in list corruptions whenever
> > listeners are registered / unregistered.
> >
> > Instead, register a different listener in each namespace.
> >
> > Currently this is not an issue because only the VXLAN driver registers a
> > listener to this chain, but this is going to change with netdevsim and
> > mlxsw also registering their own listeners.
> >
> > Signed-off-by: Ido Schimmel <idosch@nvidia.com>
>
> Reviewed-by: David Ahern <dsahern@kernel.org>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-03 23:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-01 11:39 [PATCH net-next] vxlan: Use a per-namespace nexthop listener instead of a global one Ido Schimmel
2020-11-03 1:45 ` David Ahern
2020-11-03 23:24 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).