net: vxlan: when lower dev unregisters remove vxlan dev as well
authorDaniel Borkmann <dborkman@redhat.com>
Mon, 13 Jan 2014 17:41:19 +0000 (18:41 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Jan 2014 07:38:38 +0000 (23:38 -0800)
commitacaf4e70997ff5ef3588f5a8abb1c228de637bd2
tree279418c3f44771f87f830e24f8fba02748aff146
parentfb52cab54deaca28a90fc28d057a7f6487a132ae
net: vxlan: when lower dev unregisters remove vxlan dev as well

We can create a vxlan device with an explicit underlying carrier.
In that case, when the carrier link is being deleted from the
system (e.g. due to module unload) we should also clean up all
created vxlan devices on top of it since otherwise we're in an
inconsistent state in vxlan device. In that case, the user needs
to remove all such devices, while in case of other virtual devs
that sit on top of physical ones, it is usually the case that
these devices do unregister automatically as well and do not
leave the burden on the user.

This work is not necessary when vxlan device was not created with
a real underlying device, as connections can resume in that case
when driver is plugged again. But at least for the other cases,
we should go ahead and do the cleanup on removal.

We don't register the notifier during vxlan_newlink() here since
I consider this event rather rare, and therefore we should not
bloat vxlan's core structure unecessary. Also, we can simply make
use of unregister_netdevice_many() to batch that. fdb is flushed
upon ndo_stop().

E.g. `ip -d link show vxlan13` after carrier removal before
this patch:

5: vxlan13: <BROADCAST,MULTICAST> mtu 1450 qdisc noop state DOWN mode DEFAULT group default
    link/ether 1e:47:da:6d:4d:99 brd ff:ff:ff:ff:ff:ff promiscuity 0
    vxlan id 13 group 239.0.0.10 dev 2 port 32768 61000 ageing 300
                                 ^^^^^
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/vxlan.c