diff options
author | David S. Miller <davem@davemloft.net> | 2019-02-22 14:53:32 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-02-22 14:53:32 -0500 |
commit | 2fce40a592daa92f1565152cb68d4c4ca7e97d52 (patch) | |
tree | eaa11fe77005b43a576b173c4bf9a54ae2135f35 /net/dsa/port.c | |
parent | 6d20faecc5949a305946559a38c89578e7d68264 (diff) | |
parent | 061f6a505ac33659eab007731c0f6374df39ab55 (diff) |
Merge branch 'dsa-vlan'
Florian Fainelli says:
====================
net: dsa: VLAN devices w/ filtering
This patch series supports having VLAN devices on top of DSA/switch
ports while the switch has VLAN filtering globally turned on (as is the
case with Broadcom switches). Whether the switch does global or per-port
VLAN filtering, having VLAN entries for these VLAN devices is
beneficial.
We take care of a few possibly problematic cases:
- adding a VLAN device while there is an existing VLAN entry created by
a VLAN aware bridge. The entire bridge's VLAN database and not just
the specific bridge port is being checked to be safe and conserative
- adding a bridge VLAN entry when there is an existing VLAN device
created is also not possible because that would lead to the bridge
being able to manipulate the VLAN device's VID/attributes under its feet
- enslaving a VLAN device into a VLAN aware bridge since that duplicates
functionality already offered by the VLAN aware bridge
Here are the different test cases that were run to exercise this:
ip addr flush dev gphy
ip link add dev br0 type bridge
echo 1 > /sys/class/net/br0/bridge/vlan_filtering
ip link set dev gphy master br0
udhcpc -i br0
vconfig add rgmii_1 100
ifconfig rgmii_1.100 192.168.100.10
ping -c 2 192.168.100.1
vconfig add br0 42
bridge vlan add vid 42 dev gphy
bridge vlan add vid 42 dev br0 self
ifconfig br0.42 192.168.42.2
ping -c 2 192.168.42.1
ip link del rgmii_1.100
vconfig add rgmii_1 100
ifconfig rgmii_1.100 192.168.100.10
ping -c 2 192.168.100.1
echo 0 > /sys/class/net/br0/bridge/vlan_filtering
ping -c 2 192.168.100.1
ip link del rgmii_1.100
echo 1 > /sys/class/net/br0/bridge/vlan_filtering
vconfig add rgmii_1 100
brctl addif br0 rgmii_1
bridge vlan add vid 100 dev rgmii_1
vconfig rem rgmii_1.100
bridge vlan add vid 100 dev rgmii_1
vconfig add rgmii_1 100
bridge vlan del vid 100 dev rgmii_1
vconfig add rgmii_1 100
brctl addif br0 rgmii_1.100
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/port.c')
-rw-r--r-- | net/dsa/port.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/net/dsa/port.c b/net/dsa/port.c index e9b5b50f8cf1..c011dff523d0 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c | |||
@@ -291,7 +291,10 @@ int dsa_port_vlan_add(struct dsa_port *dp, | |||
291 | .vlan = vlan, | 291 | .vlan = vlan, |
292 | }; | 292 | }; |
293 | 293 | ||
294 | if (br_vlan_enabled(dp->bridge_dev)) | 294 | /* Can be called from dsa_slave_port_obj_add() or |
295 | * dsa_slave_vlan_rx_add_vid() | ||
296 | */ | ||
297 | if (!dp->bridge_dev || br_vlan_enabled(dp->bridge_dev)) | ||
295 | return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_ADD, &info); | 298 | return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_ADD, &info); |
296 | 299 | ||
297 | return 0; | 300 | return 0; |
@@ -306,10 +309,13 @@ int dsa_port_vlan_del(struct dsa_port *dp, | |||
306 | .vlan = vlan, | 309 | .vlan = vlan, |
307 | }; | 310 | }; |
308 | 311 | ||
309 | if (netif_is_bridge_master(vlan->obj.orig_dev)) | 312 | if (vlan->obj.orig_dev && netif_is_bridge_master(vlan->obj.orig_dev)) |
310 | return -EOPNOTSUPP; | 313 | return -EOPNOTSUPP; |
311 | 314 | ||
312 | if (br_vlan_enabled(dp->bridge_dev)) | 315 | /* Can be called from dsa_slave_port_obj_del() or |
316 | * dsa_slave_vlan_rx_kill_vid() | ||
317 | */ | ||
318 | if (!dp->bridge_dev || br_vlan_enabled(dp->bridge_dev)) | ||
313 | return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info); | 319 | return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info); |
314 | 320 | ||
315 | return 0; | 321 | return 0; |