From e6e2e2e3817f917f8868575706769f4bb460b3fa Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 30 Jul 2025 06:43:32 +0000 Subject: [PATCH] Revert "net: vlan: fix VLAN 0 refcount imbalance of toggling filtering during runtime" This reverts commit bb515c41306454937464da055609b5fb0a27821b which is commit 579d4f9ca9a9a605184a9b162355f6ba131f678d upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: Ifc93239dd363a86deab7507780d22f4bc31dddcc Signed-off-by: Greg Kroah-Hartman --- net/8021q/vlan.c | 42 +++++++++--------------------------------- net/8021q/vlan.h | 1 - 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 422f726346ea..b477ba37a699 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -358,35 +358,6 @@ static int __vlan_device_event(struct net_device *dev, unsigned long event) return err; } -static void vlan_vid0_add(struct net_device *dev) -{ - struct vlan_info *vlan_info; - int err; - - if (!(dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) - return; - - pr_info("adding VLAN 0 to HW filter on device %s\n", dev->name); - - err = vlan_vid_add(dev, htons(ETH_P_8021Q), 0); - if (err) - return; - - vlan_info = rtnl_dereference(dev->vlan_info); - vlan_info->auto_vid0 = true; -} - -static void vlan_vid0_del(struct net_device *dev) -{ - struct vlan_info *vlan_info = rtnl_dereference(dev->vlan_info); - - if (!vlan_info || !vlan_info->auto_vid0) - return; - - vlan_info->auto_vid0 = false; - vlan_vid_del(dev, htons(ETH_P_8021Q), 0); -} - static int vlan_device_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -408,10 +379,15 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, return notifier_from_errno(err); } - if (event == NETDEV_UP) - vlan_vid0_add(dev); - else if (event == NETDEV_DOWN) - vlan_vid0_del(dev); + if ((event == NETDEV_UP) && + (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) { + pr_info("adding VLAN 0 to HW filter on device %s\n", + dev->name); + vlan_vid_add(dev, htons(ETH_P_8021Q), 0); + } + if (event == NETDEV_DOWN && + (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) + vlan_vid_del(dev, htons(ETH_P_8021Q), 0); vlan_info = rtnl_dereference(dev->vlan_info); if (!vlan_info) diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h index c7ffe591d593..5eaf38875554 100644 --- a/net/8021q/vlan.h +++ b/net/8021q/vlan.h @@ -33,7 +33,6 @@ struct vlan_info { struct vlan_group grp; struct list_head vid_list; unsigned int nr_vids; - bool auto_vid0; struct rcu_head rcu; };