Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: provide an option for drivers to always receive bridge VLANs

DSA assumes that a bridge which has vlan filtering disabled is not
vlan aware, and ignores all vlan configuration. However, the kernel
software bridge code allows configuration in this state.

This causes the kernel's idea of the bridge vlan state and the
hardware state to disagree, so "bridge vlan show" indicates a correct
configuration but the hardware lacks all configuration. Even worse,
enabling vlan filtering on a DSA bridge immediately blocks all traffic
which, given the output of "bridge vlan show", is very confusing.

Provide an option that drivers can set to indicate they want to receive
vlan configuration even when vlan filtering is disabled. At the very
least, this is safe for Marvell DSA bridges, which do not look up
ingress traffic in the VTU if the port is in 8021Q disabled state. It is
also safe for the Ocelot switch family. Whether this change is suitable
for all DSA bridges is not known.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Russell King and committed by
David S. Miller
54a0ed0d 26831d78

+26 -4
+7
include/net/dsa.h
··· 282 282 */ 283 283 bool vlan_filtering_is_global; 284 284 285 + /* Pass .port_vlan_add and .port_vlan_del to drivers even for bridges 286 + * that have vlan_filtering=0. All drivers should ideally set this (and 287 + * then the option would get removed), but it is unknown whether this 288 + * would break things or not. 289 + */ 290 + bool configure_vlan_while_not_filtering; 291 + 285 292 /* In case vlan_filtering_is_global is set, the VLAN awareness state 286 293 * should be retrieved from here and not from the per-port settings. 287 294 */
+1
net/dsa/dsa_priv.h
··· 138 138 void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br); 139 139 int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering, 140 140 struct switchdev_trans *trans); 141 + bool dsa_port_skip_vlan_configuration(struct dsa_port *dp); 141 142 int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock, 142 143 struct switchdev_trans *trans); 143 144 int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu,
+14
net/dsa/port.c
··· 257 257 return 0; 258 258 } 259 259 260 + /* This enforces legacy behavior for switch drivers which assume they can't 261 + * receive VLAN configuration when enslaved to a bridge with vlan_filtering=0 262 + */ 263 + bool dsa_port_skip_vlan_configuration(struct dsa_port *dp) 264 + { 265 + struct dsa_switch *ds = dp->ds; 266 + 267 + if (!dp->bridge_dev) 268 + return false; 269 + 270 + return (!ds->configure_vlan_while_not_filtering && 271 + !br_vlan_enabled(dp->bridge_dev)); 272 + } 273 + 260 274 int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock, 261 275 struct switchdev_trans *trans) 262 276 {
+4 -4
net/dsa/slave.c
··· 314 314 if (obj->orig_dev != dev) 315 315 return -EOPNOTSUPP; 316 316 317 - if (dp->bridge_dev && !br_vlan_enabled(dp->bridge_dev)) 317 + if (dsa_port_skip_vlan_configuration(dp)) 318 318 return 0; 319 319 320 320 vlan = *SWITCHDEV_OBJ_PORT_VLAN(obj); ··· 381 381 if (obj->orig_dev != dev) 382 382 return -EOPNOTSUPP; 383 383 384 - if (dp->bridge_dev && !br_vlan_enabled(dp->bridge_dev)) 384 + if (dsa_port_skip_vlan_configuration(dp)) 385 385 return 0; 386 386 387 387 /* Do not deprogram the CPU port as it may be shared with other user ··· 1240 1240 * need to emulate the switchdev prepare + commit phase. 1241 1241 */ 1242 1242 if (dp->bridge_dev) { 1243 - if (!br_vlan_enabled(dp->bridge_dev)) 1243 + if (dsa_port_skip_vlan_configuration(dp)) 1244 1244 return 0; 1245 1245 1246 1246 /* br_vlan_get_info() returns -EINVAL or -ENOENT if the ··· 1274 1274 * need to emulate the switchdev prepare + commit phase. 1275 1275 */ 1276 1276 if (dp->bridge_dev) { 1277 - if (!br_vlan_enabled(dp->bridge_dev)) 1277 + if (dsa_port_skip_vlan_configuration(dp)) 1278 1278 return 0; 1279 1279 1280 1280 /* br_vlan_get_info() returns -EINVAL or -ENOENT if the