From: Florian Fainelli <f.fainelli@gmail.com>
To: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>,
davem@davemloft.net, grygorii.strashko@ti.com
Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, jiri@mellanox.com,
ilias.apalodimas@linaro.org
Subject: Re: [PATCH net-next 3/6] net: 8021q: vlan_dev: add vid tag for vlan device own address
Date: Wed, 27 Feb 2019 20:13:34 -0800 [thread overview]
Message-ID: <ec699573-87b3-76d2-6faa-3c23f32d7095@gmail.com> (raw)
In-Reply-To: <20190226184556.16082-4-ivan.khoronzhuk@linaro.org>
On 2/26/2019 10:45 AM, Ivan Khoronzhuk wrote:
> The vlan device address is held separately from uc/mc lists and
> handled differently. The vlan dev address is bound with real device
> address only if it's inherited from init, in all other cases it's
> separate address entry in uc list. With vid set, the address becomes
> not inherited from real device after it's set manually as before, but
> is part of uc list any way, with appropriate vid tag set. If vid_len
> for real device is 0, the behaviour is the same as before this change,
> so shouldn't be any impact on systems w/o individual virtual device
> filtering (IVDF) enabled. This allows to control and sync vlan device
> address and disable concrete vlan packet income when vlan interface is
> down.
>
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
> ---
[snip]
>
> +static int vlan_dev_add_addr(struct net_device *dev, u8 *addr)
> +{
> + struct net_device *real_dev = vlan_dev_real_dev(dev);
> + unsigned char naddr[ETH_ALEN + NET_8021Q_VID_TSIZE];
> +
> + if (real_dev->vid_len) {
Don't you need to check that real_dev->vid_len is >= NET_8021Q_VID_TSIZE
here?
> + memcpy(naddr, addr, dev->addr_len);
> + vlan_dev_set_addr_vid(dev, naddr);
> + return dev_vid_uc_add(real_dev, naddr);
> + }
> +
> + if (ether_addr_equal(addr, real_dev->dev_addr))
> + return 0;
> +
> + return dev_uc_add(real_dev, addr);
> +}
> +
> +static void vlan_dev_del_addr(struct net_device *dev, u8 *addr)
> +{
> + struct net_device *real_dev = vlan_dev_real_dev(dev);
> + unsigned char naddr[ETH_ALEN + NET_8021Q_VID_TSIZE];
> +
> + if (real_dev->vid_len) {
Same here.
> + memcpy(naddr, addr, dev->addr_len);
> + vlan_dev_set_addr_vid(dev, naddr);
> + dev_vid_uc_del(real_dev, naddr);
> + return;
> + }
> +
> + if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr))
> + dev_uc_del(real_dev, addr);
> +}
> +
> +static int vlan_dev_subs_addr(struct net_device *dev, u8 *addr)
> +{
> + int err;
> +
> + err = vlan_dev_add_addr(dev, addr);
> + if (err < 0)
> + return err;
> +
> + vlan_dev_del_addr(dev, dev->dev_addr);
> + return err;
> +}
> +
> bool vlan_dev_inherit_address(struct net_device *dev,
> struct net_device *real_dev)
> {
> if (dev->addr_assign_type != NET_ADDR_STOLEN)
> return false;
>
> + if (real_dev->vid_len)
> + if (vlan_dev_subs_addr(dev, real_dev->dev_addr))
> + return false;
The check on real_dev->vid_len can be absorbed into vlan_dev_subs_addr()?
> +
> ether_addr_copy(dev->dev_addr, real_dev->dev_addr);
> call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
> return true;
> @@ -278,9 +327,10 @@ static int vlan_dev_open(struct net_device *dev)
> !(vlan->flags & VLAN_FLAG_LOOSE_BINDING))
> return -ENETDOWN;
>
> - if (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr) &&
> - !vlan_dev_inherit_address(dev, real_dev)) {
> - err = dev_uc_add(real_dev, dev->dev_addr);
> + if (ether_addr_equal(dev->dev_addr, real_dev->dev_addr) ||
> + (!ether_addr_equal(dev->dev_addr, real_dev->dev_addr) &&
> + !vlan_dev_inherit_address(dev, real_dev))) {
Should this condition simply become if !vlan_dev_inherit_address() now?
--
Florian
next prev parent reply other threads:[~2019-02-28 4:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-26 18:45 [PATCH net-next 0/6] net: add individual virtual device filtering Ivan Khoronzhuk
2019-02-26 18:45 ` [PATCH net-next 1/6] net: core: dev_addr_lists: add VID to device address Ivan Khoronzhuk
2019-02-28 4:24 ` Florian Fainelli
2019-03-01 12:21 ` Ivan Khoronzhuk
2019-02-26 18:45 ` [PATCH net-next 2/6] net: 8021q: vlan_dev: add vid tag to addresses of uc and mc lists Ivan Khoronzhuk
2019-02-28 4:09 ` Florian Fainelli
2019-03-01 12:24 ` Ivan Khoronzhuk
2019-03-02 3:19 ` Florian Fainelli
2019-02-26 18:45 ` [PATCH net-next 3/6] net: 8021q: vlan_dev: add vid tag for vlan device own address Ivan Khoronzhuk
2019-02-28 4:13 ` Florian Fainelli [this message]
2019-03-01 12:28 ` Ivan Khoronzhuk
2019-03-02 3:24 ` Florian Fainelli
2019-02-26 18:45 ` [PATCH net-next 4/6] ethernet: eth: add default vid len for all ehternet kind devices Ivan Khoronzhuk
2019-02-28 4:29 ` Florian Fainelli
2019-03-01 13:11 ` Ivan Khoronzhuk
2019-03-02 3:33 ` Florian Fainelli
2019-02-26 18:45 ` [PATCH net-next 5/6] net: ethernet: ti: cpsw: update mc filtering to use IVDF Ivan Khoronzhuk
2019-02-28 4:17 ` Florian Fainelli
2019-02-26 18:45 ` [PATCH net-next 6/6] net: ethernet: ti: cpsw: add macvlan and ucast/vlan filtering support Ivan Khoronzhuk
2019-02-28 0:23 ` [PATCH net-next 0/6] net: add individual virtual device filtering Florian Fainelli
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=ec699573-87b3-76d2-6faa-3c23f32d7095@gmail.com \
--to=f.fainelli@gmail.com \
--cc=davem@davemloft.net \
--cc=grygorii.strashko@ti.com \
--cc=ilias.apalodimas@linaro.org \
--cc=ivan.khoronzhuk@linaro.org \
--cc=jiri@mellanox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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