forked from torvalds/linux
Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
net: dsa: Centralize validation of VLAN configuration
There are four kinds of events that have an inpact on VLAN
configuration of DSA ports:
- Adding VLAN uppers
(ip link add dev swp0.1 link swp0 type vlan id 1)
- Bridging VLAN uppers
(ip link set dev swp0.1 master br0)
- Adding bridge VLANs
(bridge vlan add dev swp0 vid 1)
- Changes to a bridge's VLAN filtering setting
(ip link set dev br0 type bridge vlan_filtering 1)
For all of these events, we want to ensure that some invariants are
upheld for offloaded ports belonging to our tree:
- For hardware where VLAN filtering is a global setting, either all
bridges must use VLAN filtering, or no bridge can.
- For all filtering bridges, no VID may be configured on more than one
VLAN upper. An example of a violation of this would be:
.100 br0 .100
\ / \ /
swp0 swp1
$ ip link add dev br0 type bridge vlan_filtering 1
$ ip link add dev swp0.100 link swp0 type vlan id 100
$ ip link set dev swp0 master br0
$ ip link add dev swp1.100 link swp0 type vlan id 100
$ ip link set dev swp1 master br0
- For all filtering bridges, no upper VLAN may share a bridge with
another offloaded port. An example of a violation of this would be:
br0
/ |
/ |
.100 |
| |
swp0 swp1
$ ip link add dev br0 type bridge vlan_filtering 1
$ ip link add dev swp0.100 link swp0 type vlan id 100
$ ip link set dev swp0.100 master br0
$ ip link set dev swp1 master br0
- For all filtering bridges, no VID that exists in the bridge may be
used by a VLAN upper. An example of a violation of this would be:
br0
(100)
|
.100 |
\ |
swp0
$ ip link add dev br0 type bridge vlan_filtering 1
$ ip link add dev swp0.100 link swp0 type vlan id 100
$ ip link set dev swp0 master br0
$ bridge vlan add dev swp0 vid 100
Move the validation of these invariants to a central function, and use
it from all sites where these events are handled. This way, we ensure
that all invariants are always checked, avoiding certain configs being
allowed or disallowed depending on the order in which commands are
given.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>- Loading branch information
1 parent
a25f822
commit 9a35f7597b676a3bdaa9dd753e0a7d11fb132ed5
Showing
4 changed files
with
275 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.