netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Russell King - ARM Linux admin <linux@armlinux.org.uk>,
	Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Ido Schimmel <idosch@idosch.org>,
	Vivien Didelot <vivien.didelot@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Ivan Vecera <ivecera@redhat.com>,
	Jakub Kicinski <kuba@kernel.org>, Jiri Pirko <jiri@resnulli.us>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next 0/3] VLANs, DSA switches and multiple bridges
Date: Tue, 18 Feb 2020 11:26:52 -0800	[thread overview]
Message-ID: <00bd9511-65ae-7adc-782e-c40b60d81658@gmail.com> (raw)
In-Reply-To: <20200218114515.GL18808@shell.armlinux.org.uk>

On 2/18/20 3:45 AM, Russell King - ARM Linux admin wrote:
> Hi,
> 
> This is a repost of the previously posted RFC back in December, which
> did not get fully reviewed.  I've dropped the RFC tag this time as no
> one really found anything too problematical in the RFC posting.
> 
> I've been trying to configure DSA for VLANs and not having much success.
> The setup is quite simple:
> 
> - The main network is untagged
> - The wifi network is a vlan tagged with id $VN running over the main
>   network.
> 
> I have an Armada 388 Clearfog with a PCIe wifi card which I'm trying to
> setup to provide wifi access to the vlan $VN network, while the switch
> is also part of the main network.
> 
> However, I'm encountering problems:
> 
> 1) vlan support in DSA has a different behaviour from the Linux
>    software bridge implementation.
> 
>     # bridge vlan
>     port    vlan ids
>     lan1     1 PVID Egress Untagged
>     ...
> 
>    shows the default setup - the bridge ports are all configured for
>    vlan 1, untagged egress, and vlan 1 as the port vid.  Issuing:
> 
>     # ip li set dev br0 type bridge vlan_filtering 1
> 
>    with no other vlan configuration commands on a Linux software bridge
>    continues to allow untagged traffic to flow across the bridge.
>    
>    This difference in behaviour is because the MV88E6xxx VTU is
>    completely empty - because net/dsa ignores all vlan settings for
>    a port if br_vlan_enabled(dp->bridge_dev) is false - this reflects
>    the vlan filtering state of the bridge, not whether the bridge is
>    vlan aware.
>    
>    What this means is that attempting to configure the bridge port
>    vlans before enabling vlan filtering works for Linux software
>    bridges, but fails for DSA bridges.

FWIW, because VLAN filtering is global with b53 switches, we do actually
program every port with a valid VLAN entry into VID 0 which ensures that
standalone (non-bridged) ports, with, or without VLAN interfaces on top
(e.g.: sw0p0.N) continue to work as soon as another port gets enslaved
into a bridge that does request vlan_filtering.

> 
> 2) Assuming the above is sorted, we move on to the next issue, which
>    is altogether more weird.  Let's take a setup where we have a
>    DSA bridge with lan1..6 in a bridge device, br0, with vlan
>    filtering enabled.  lan1 is the upstream port, lan2 is a downstream
>    port that also wants to see traffic on vlan id $VN.
> 
>    Both lan1 and lan2 are configured for that:
> 
>      # bridge vlan add vid $VN dev lan1
>      # bridge vlan add vid $VN dev lan2
>      # ip li set br0 type bridge vlan_filtering 1
> 
>    Untagged traffic can now pass between all the six lan ports, and
>    vlan $VN between lan1 and lan2 only.  The MV88E6xxx 8021q_mode
>    debugfs file shows all lan ports are in mode "secure" - this is
>    important!  /sys/class/net/br0/bridge/vlan_filtering contains 1.
> 
>    tcpdumping from another machine on lan4 shows that no $VN traffic
>    reaches it.  Everything seems to be working correctly...
>    
>    In order to further bridge vlan $VN traffic to hostapd's wifi
>    interface, things get a little more complex - we can't add hostapd's
>    wifi interface to br0 directly, because hostapd will bring up the
>    wifi interface and leak the main, untagged traffic onto the wifi.
>    (hostapd does have vlan support, but only as a dynamic per-client
>    thing, and there's no hooks I can see to allow script-based config
>    of the network setup before hostapd up's the wifi interface.)
> 
>    So, what I tried was:
> 
>      # ip li add link br0 name br0.$VN type vlan id $VN
>      # bridge vlan add vid $VN dev br0 self
>      # ip li set dev br0.$VN up
> 
>    So far so good, we get a vlan interface on top of the bridge, and
>    tcpdumping it shows we get traffic.  The 8021q_mode file has not
>    changed state.  Everything still seems to be correct.
> 
>      # bridge addbr br1
> 
>    Still nothing has changed.
> 
>      # bridge addif br1 br0.$VN
> 
>    And now the 8021q_mode debugfs file shows that all ports are now in
>    "disabled" mode, but /sys/class/net/br0/bridge/vlan_filtering still
>    contains '1'.  In other words, br0 still thinks vlan filtering is
>    enabled, but the hardware has had vlan filtering disabled.
> 
>    Adding some stack traces to an appropriate point indicates that this
>    is because __switchdev_handle_port_attr_set() recurses down through
>    the tree of interfaces, skipping over the vlan interface, applying
>    br1's configuration to br0's ports.
> 
>    This surely can not be right - surely
>    __switchdev_handle_port_attr_set() and similar should stop recursing
>    down through another master bridge device?  There are probably other
>    network device classes that switchdev shouldn't recurse down too.
> 
>    I've considered whether switchdev is the right level to do it, and
>    I think it is - as we want the check/set callbacks to be called for
>    the top level device even if it is a master bridge device, but we
>    don't want to recurse through a lower master bridge device.
> 


-- 
Florian

  parent reply	other threads:[~2020-02-18 19:27 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18 11:45 [PATCH net-next 0/3] VLANs, DSA switches and multiple bridges Russell King - ARM Linux admin
2020-02-18 11:46 ` [PATCH net-next 1/3] net: switchdev: do not propagate bridge updates across bridges Russell King
2020-02-18 11:46 ` [PATCH net-next 2/3] net: dsa: mv88e6xxx: fix duplicate vlan warning Russell King
2020-02-18 11:51   ` Russell King - ARM Linux admin
2020-02-18 16:27     ` Andrew Lunn
2020-02-18 16:31       ` Russell King - ARM Linux admin
2020-02-20 18:12       ` Russell King - ARM Linux admin
2020-02-18 11:46 ` [PATCH net-next 3/3] net: dsa: mv88e6xxx: fix vlan setup Russell King
2020-02-18 19:09   ` Vivien Didelot
2020-02-18 19:34     ` Florian Fainelli
2020-02-18 23:48       ` Russell King - ARM Linux admin
2020-02-19  0:52         ` Vivien Didelot
2020-02-18 19:26 ` Florian Fainelli [this message]
2020-02-19  0:00 ` [PATCH net-next 0/3] VLANs, DSA switches and multiple bridges Florian Fainelli
2020-02-19  0:17   ` Russell King - ARM Linux admin
2020-02-19  0:33     ` Florian Fainelli
2020-02-19  0:58     ` Vivien Didelot
2020-02-19  3:47     ` Andrew Lunn
2020-02-19  9:19       ` Russell King - ARM Linux admin
2020-02-19 18:07         ` Vivien Didelot
2020-02-19 18:20           ` Florian Fainelli
2020-02-20 11:35           ` Russell King - ARM Linux admin
2020-02-19 18:52   ` Vladimir Oltean
2020-02-19 19:18     ` Florian Fainelli
2020-02-19 23:15       ` Russell King - ARM Linux admin
2020-02-20 18:56         ` Florian Fainelli
2020-02-21  0:21           ` Russell King - ARM Linux admin
2020-03-16 11:15             ` Russell King - ARM Linux admin
2020-03-17 12:00               ` Russell King - ARM Linux admin
2020-03-17 14:21                 ` Vladimir Oltean
2020-03-17 15:12                   ` Russell King - ARM Linux admin
2020-03-17 18:49                     ` Vivien Didelot
2020-03-17 21:24                       ` Russell King - ARM Linux admin
2020-03-18  2:26                         ` Vivien Didelot

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=00bd9511-65ae-7adc-782e-c40b60d81658@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=idosch@idosch.org \
    --cc=ivecera@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.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;
as well as URLs for NNTP newsgroup(s).