mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Dong Chenchen <dongchenchen2@huawei.com>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <pabeni@redhat.com>,
	<horms@kernel.org>, <jiri@resnulli.us>, <oscmaes92@gmail.com>,
	<linux@treblig.org>, <pedro.netdev@dondevamos.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<yuehaibing@huawei.com>, <zhangchangzhong@huawei.com>
Subject: Re: [PATCH net] net: vlan: fix VLAN 0 refcount imbalance of toggling filtering during runtime
Date: Tue, 24 Jun 2025 17:42:52 -0700	[thread overview]
Message-ID: <20250624174252.7fbd3dbe@kernel.org> (raw)
In-Reply-To: <20250623113008.695446-1-dongchenchen2@huawei.com>

On Mon, 23 Jun 2025 19:30:08 +0800 Dong Chenchen wrote:
> $ ip link add bond0 type bond mode 0
> $ ip link add link bond0 name vlan0 type vlan id 0 protocol 802.1q
> $ ethtool -K bond0 rx-vlan-filter off
> $ ifconfig bond0 up
> $ ethtool -K bond0 rx-vlan-filter on
> $ ifconfig bond0 down
> $ ifconfig bond0 up
> $ ip link del vlan0

Please try to figure out the reasonable combinations in which we can
change the flags and bring the device up and down. Create a selftest
in bash and add it under tools/testing/selftests/net

> diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
> index 06908e37c3d9..6e01ece0a95c 100644
> --- a/net/8021q/vlan.c
> +++ b/net/8021q/vlan.c
> @@ -504,12 +504,21 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
>  		break;
>  
>  	case NETDEV_CVLAN_FILTER_PUSH_INFO:
> +		flgs = dev_get_flags(dev);

Why call dev_get_flags()? You can test dev->flags & IFF_UP directly

> +		if (flgs & IFF_UP) {
> +			pr_info("adding VLAN 0 to HW filter on device %s\n",
> +				dev->name);
> +			vlan_vid_add(dev, htons(ETH_P_8021Q), 0);

Not sure if this works always, because if we have no vlan at all when
the device comes up vlan_info will be NULL and we won't even get here.

IIUC adding vlan 0 has to be handled early, where UP is handled.

> +		}
>  		err = vlan_filter_push_vids(vlan_info, htons(ETH_P_8021Q));
>  		if (err)
>  			return notifier_from_errno(err);
>  		break;
>  
>  	case NETDEV_CVLAN_FILTER_DROP_INFO:
> +		flgs = dev_get_flags(dev);
> +		if (flgs & IFF_UP)
> +			vlan_vid_del(dev, htons(ETH_P_8021Q), 0);
>  		vlan_filter_drop_vids(vlan_info, htons(ETH_P_8021Q));
-- 
pw-bot: cr

  reply	other threads:[~2025-06-25  0:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23 11:30 Dong Chenchen
2025-06-25  0:42 ` Jakub Kicinski [this message]
2025-06-26  3:41   ` dongchenchen (A)
2025-06-27 14:41     ` Ido Schimmel
2025-06-30  1:25       ` dongchenchen (A)
2025-06-30  8:14         ` Ido Schimmel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250624174252.7fbd3dbe@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dongchenchen2@huawei.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@treblig.org \
    --cc=netdev@vger.kernel.org \
    --cc=oscmaes92@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=pedro.netdev@dondevamos.com \
    --cc=yuehaibing@huawei.com \
    --cc=zhangchangzhong@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®