From: Ido Schimmel <idosch@idosch.org>
To: Ziyang Xuan <william.xuanziyang@huawei.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, j.vosburgh@gmail.com, andy@greyhouse.net,
tglx@linutronix.de, vadim.fedorenko@linux.dev, kaber@trash.net,
netdev@vger.kernel.org
Subject: Re: [PATCH net v2] bonding: Fix incorrect deletion of ETH_P_8021AD protocol vid from slaves
Date: Fri, 4 Aug 2023 15:40:17 +0300 [thread overview]
Message-ID: <ZMzxsYwiejVov13M@shredder> (raw)
In-Reply-To: <20230802114320.4156068-1-william.xuanziyang@huawei.com>
On Wed, Aug 02, 2023 at 07:43:20PM +0800, Ziyang Xuan wrote:
> BUG_ON(!vlan_info) is triggered in unregister_vlan_dev() with
> following testcase:
>
> # ip netns add ns1
> # ip netns exec ns1 ip link add bond0 type bond mode 0
> # ip netns exec ns1 ip link add bond_slave_1 type veth peer veth2
> # ip netns exec ns1 ip link set bond_slave_1 master bond0
> # ip netns exec ns1 ip link add link bond_slave_1 name vlan10 type vlan id 10 protocol 802.1ad
> # ip netns exec ns1 ip link add link bond0 name bond0_vlan10 type vlan id 10 protocol 802.1ad
> # ip netns exec ns1 ip link set bond_slave_1 nomaster
> # ip netns del ns1
>
> The logical analysis of the problem is as follows:
>
> 1. create ETH_P_8021AD protocol vlan10 for bond_slave_1:
> register_vlan_dev()
> vlan_vid_add()
> vlan_info_alloc()
> __vlan_vid_add() // add [ETH_P_8021AD, 10] vid to bond_slave_1
>
> 2. create ETH_P_8021AD protocol bond0_vlan10 for bond0:
> register_vlan_dev()
> vlan_vid_add()
> __vlan_vid_add()
> vlan_add_rx_filter_info()
> if (!vlan_hw_filter_capable(dev, proto)) // condition established because bond0 without NETIF_F_HW_VLAN_STAG_FILTER
> return 0;
>
> if (netif_device_present(dev))
> return dev->netdev_ops->ndo_vlan_rx_add_vid(dev, proto, vid); // will be never called
> // The slaves of bond0 will not refer to the [ETH_P_8021AD, 10] vid.
>
> 3. detach bond_slave_1 from bond0:
> __bond_release_one()
> vlan_vids_del_by_dev()
> list_for_each_entry(vid_info, &vlan_info->vid_list, list)
> vlan_vid_del(dev, vid_info->proto, vid_info->vid);
> // bond_slave_1 [ETH_P_8021AD, 10] vid will be deleted.
> // bond_slave_1->vlan_info will be assigned NULL.
>
> 4. delete vlan10 during delete ns1:
> default_device_exit_batch()
> dev->rtnl_link_ops->dellink() // unregister_vlan_dev() for vlan10
> vlan_info = rtnl_dereference(real_dev->vlan_info); // real_dev of vlan10 is bond_slave_1
> BUG_ON(!vlan_info); // bond_slave_1->vlan_info is NULL now, bug is triggered!!!
>
> Add S-VLAN tag related features support to bond driver. So the bond driver
> will always propagate the VLAN info to its slaves.
>
> Fixes: 8ad227ff89a7 ("net: vlan: add 802.1ad support")
> Suggested-by: Ido Schimmel <idosch@idosch.org>
> Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
next prev parent reply other threads:[~2023-08-04 12:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 11:43 [PATCH net v2] bonding: Fix incorrect deletion of ETH_P_8021AD protocol vid from slaves Ziyang Xuan
2023-08-04 12:40 ` Ido Schimmel [this message]
2023-08-07 19:30 ` patchwork-bot+netdevbpf
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=ZMzxsYwiejVov13M@shredder \
--to=idosch@idosch.org \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=j.vosburgh@gmail.com \
--cc=kaber@trash.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tglx@linutronix.de \
--cc=vadim.fedorenko@linux.dev \
--cc=william.xuanziyang@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