vlan: drop the promisc/allmulti references on the real device on delete

Since commit 27b918007d96 ("net: vlan: don't propagate flags on open"),
vlan_dev_change_rx_flags() passes IFF_PROMISC and IFF_ALLMULTI changes
on to the real device whether or not the VLAN device is up, and
vlan_dev_open()/vlan_dev_stop() no longer take or drop those references.
Nothing drops them when the VLAN device is deleted, so the real device
stays promiscuous or allmulti for good:

  ip link add link veth0 name vlan10 type vlan id 10
  ip link set vlan10 promisc on
  ip link del vlan10
  ip -d link show veth0    # promiscuity 1

Drop them in vlan_dev_uninit(). The device flags are still set there,
and no instance lock is held, so this does not bring back the recursive
locking that the commit above removed.

After that, stop passing flag changes on to the real device. When a
VLAN and a VLAN stacked on it are deleted in one batch
("ip link del group N"), the upper VLAN's vlan_dev_uninit() can run
after the lower one's and clear its IFF_PROMISC or IFF_ALLMULTI, which
would drop the real device's reference a second time.

Fixes: 27b918007d96 ("net: vlan: don't propagate flags on open")
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Link: https://patch.msgid.link/179562437889.3453587.11037378125876087336@gmail.com
Signed-off-by: Willem de Bruijn <willemb@google.com>
2 files changed