4

I'm reading "man bridge" and it says something like:

bridge vlan { add | del } dev DEV vid VID [ pvid ] [ untagged ] [ self ] [ master ]

What are "self" and "master" options for?

man says:

self   the vlan is configured on the specified physical device. Required if the device is the bridge device.
master the vlan is configured on the software bridge (default).

Can anyone elaborate?

As I understand "self" is for virtual interfaces like "br0.10" etc to let the bridge (br0) know that recived frames can be for it. Right?

2c9
  • 41
  • 4

1 Answers1

0

yes, self is for the bridge. Vlans are assigned to bridge interfaces.
master is for interfaces that are slaved to bridge interfaces. You don't need to state the keyword master as it is the default.

Create bridge

/ # ip link add br0 type bridge  vlan_filtering 1
/ # ip link set br0 up
/ # bridge vlan
port    vlan ids
br0  1 PVID Egress Untagged

Add vlans

/ # bridge vlan add dev br0 vid 10 self
/ # bridge vlan add dev br0 vid 20 self
/ # bridge vlan add dev br0 vid 30 self
/ # 
/ # bridge vlan
port    vlan ids
br0  1 PVID Egress Untagged
     10
     20
     30

Add eth interfaces as slaves to bridge

/ # ip link set eth0 master br0
/ # ip link set eth1 master br0
/ # ip link set eth2 master br0
/ # bridge vlan
port    vlan ids
eth0     1 PVID Egress Untagged

eth1     1 PVID Egress Untagged

eth2     1 PVID Egress Untagged

br0  1 PVID Egress Untagged
     10
     20
     30

clear default vlan from interfaces

/ # bridge vlan del dev eth0 vid 1
/ # bridge vlan del dev eth1 vid 1
/ # bridge vlan del dev eth2 vid 1
/ # bridge vlan
port    vlan ids
eth0    None
eth1    None
eth2    None
br0  1 PVID Egress Untagged
     10
     20
     30

add necessary VLANs to the ports

/ # bridge vlan add dev eth0 vid 10 pvid untagged master
/ # bridge vlan add dev eth1 vid 20 pvid untagged master
/ # bridge vlan add dev eth2 vid 30 pvid untagged
/ # bridge vlan
port    vlan ids
eth0     10 PVID Egress Untagged

eth1     20 PVID Egress Untagged

eth2     30 PVID Egress Untagged

br0  1 PVID Egress Untagged
     10
     20
     30

as you see I used master keyword for eth0 and eth1, but not for eth2 and it didn't change the outcome.

kaya atabey
  • 113
  • 4
  • Somehow the "self" versus "master" terminology explanation doesn't make too much sense in the master-slave relationship, with bridge interface as master and enslaved interfaces as slaves. An enslaved interface isn't a master when querying RTNETLINK for links. https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/if_bridge.h#L127 says "master" is the bridge device. However, setting VIDs with "bridge vlan add" fails on the slave interface using self. RTNETLINK returns the VIDs always with BRIDGE_VLAN_INFO_MASTER unset, separately for bridge master interface and enslaved interfaces. – TheDiveO Apr 17 '20 at 21:42