* [PATCH net-next] vxlan: remove fdb when out interface is removed
@ 2020-05-27 16:29 Taehee Yoo
2020-05-29 23:42 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Taehee Yoo @ 2020-05-27 16:29 UTC (permalink / raw)
To: davem, kuba, netdev; +Cc: ap420073
vxlan fdb can have NDA_IFINDEX, which indicates an out interface.
If the interface is removed, that fdb will not work.
So, when interface is removed, vxlan's fdb can be removed.
Test commands:
ip link add dummy0 type dummy
ip link add vxlan0 type vxlan vni 1000
bridge fdb add 11:22:33:44:55:66 dst 1.1.1.1 dev vxlan0 via dummy0 self
ip link del dummy0
Before this patch, fdbs will not be removed.
Result:
bridge fdb show dev vxlan0
11:22:33:44:55:66 dst 1.1.1.1 via if10 self permanent
'if10' indicates 'dummy0' interface index.
But the dummy0 interface was removed so this fdb will not work.
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---
drivers/net/vxlan.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index a0015cdedfaf..52ca735bd91a 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -4440,6 +4440,39 @@ struct net_device *vxlan_dev_create(struct net *net, const char *name,
}
EXPORT_SYMBOL_GPL(vxlan_dev_create);
+static void vxlan_delete_rdst(struct vxlan_dev *vxlan, unsigned int h,
+ int ifindex)
+{
+ struct hlist_node *tmp;
+ struct vxlan_fdb *f;
+
+ spin_lock_bh(&vxlan->hash_lock[h]);
+ hlist_for_each_entry_safe(f, tmp, &vxlan->fdb_head[h], hlist) {
+ struct vxlan_rdst *rd, *rd_next;
+
+ list_for_each_entry_safe(rd, rd_next, &f->remotes, list) {
+ if (rd->remote_ifindex != ifindex)
+ continue;
+
+ if (list_is_singular(&f->remotes))
+ vxlan_fdb_destroy(vxlan, f, true, true);
+ else
+ vxlan_fdb_dst_destroy(vxlan, f, rd, true);
+ }
+ }
+ spin_unlock_bh(&vxlan->hash_lock[h]);
+}
+
+static void vxlan_delete_rdsts(struct vxlan_net *vn, struct net_device *dev)
+{
+ struct vxlan_dev *vxlan, *next;
+ unsigned int h;
+
+ list_for_each_entry_safe(vxlan, next, &vn->vxlan_list, next)
+ for (h = 0; h < FDB_HASH_SIZE; ++h)
+ vxlan_delete_rdst(vxlan, h, dev->ifindex);
+}
+
static void vxlan_handle_lowerdev_unregister(struct vxlan_net *vn,
struct net_device *dev)
{
@@ -4470,6 +4503,7 @@ static int vxlan_netdevice_event(struct notifier_block *unused,
if (event == NETDEV_UNREGISTER) {
vxlan_offload_rx_ports(dev, false);
+ vxlan_delete_rdsts(vn, dev);
vxlan_handle_lowerdev_unregister(vn, dev);
} else if (event == NETDEV_REGISTER) {
vxlan_offload_rx_ports(dev, true);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] vxlan: remove fdb when out interface is removed
2020-05-27 16:29 [PATCH net-next] vxlan: remove fdb when out interface is removed Taehee Yoo
@ 2020-05-29 23:42 ` David Miller
2020-06-01 12:04 ` Taehee Yoo
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2020-05-29 23:42 UTC (permalink / raw)
To: ap420073; +Cc: kuba, netdev
From: Taehee Yoo <ap420073@gmail.com>
Date: Wed, 27 May 2020 16:29:50 +0000
> vxlan fdb can have NDA_IFINDEX, which indicates an out interface.
> If the interface is removed, that fdb will not work.
> So, when interface is removed, vxlan's fdb can be removed.
>
> Test commands:
> ip link add dummy0 type dummy
> ip link add vxlan0 type vxlan vni 1000
> bridge fdb add 11:22:33:44:55:66 dst 1.1.1.1 dev vxlan0 via dummy0 self
> ip link del dummy0
>
> Before this patch, fdbs will not be removed.
> Result:
> bridge fdb show dev vxlan0
> 11:22:33:44:55:66 dst 1.1.1.1 via if10 self permanent
>
> 'if10' indicates 'dummy0' interface index.
> But the dummy0 interface was removed so this fdb will not work.
>
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
But if someone adds an interface afterwards with ifindex 10 that FDB
entry will start using it.
I don't know how desirable that is, but if someone is depending upon
that behavior now this change will break things for them.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] vxlan: remove fdb when out interface is removed
2020-05-29 23:42 ` David Miller
@ 2020-06-01 12:04 ` Taehee Yoo
0 siblings, 0 replies; 3+ messages in thread
From: Taehee Yoo @ 2020-06-01 12:04 UTC (permalink / raw)
To: David Miller; +Cc: Jakub Kicinski, Netdev
On Sat, 30 May 2020 at 08:42, David Miller <davem@davemloft.net> wrote:
>
Hi David,
Thanks a lot for your review!
> From: Taehee Yoo <ap420073@gmail.com>
> Date: Wed, 27 May 2020 16:29:50 +0000
>
> > vxlan fdb can have NDA_IFINDEX, which indicates an out interface.
> > If the interface is removed, that fdb will not work.
> > So, when interface is removed, vxlan's fdb can be removed.
> >
> > Test commands:
> > ip link add dummy0 type dummy
> > ip link add vxlan0 type vxlan vni 1000
> > bridge fdb add 11:22:33:44:55:66 dst 1.1.1.1 dev vxlan0 via dummy0 self
> > ip link del dummy0
> >
> > Before this patch, fdbs will not be removed.
> > Result:
> > bridge fdb show dev vxlan0
> > 11:22:33:44:55:66 dst 1.1.1.1 via if10 self permanent
> >
> > 'if10' indicates 'dummy0' interface index.
> > But the dummy0 interface was removed so this fdb will not work.
> >
> > Signed-off-by: Taehee Yoo <ap420073@gmail.com>
>
> But if someone adds an interface afterwards with ifindex 10 that FDB
> entry will start using it.
>
> I don't know how desirable that is, but if someone is depending upon
> that behavior now this change will break things for them.
I also don't know whether reusing FDBs is a valid way.
But, as you said, this patch may break existing things.
So, I think this patch should be dropped.
Thanks a lot!
Taehee Yoo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-01 12:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 16:29 [PATCH net-next] vxlan: remove fdb when out interface is removed Taehee Yoo
2020-05-29 23:42 ` David Miller
2020-06-01 12:04 ` Taehee Yoo
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.