6

In the following diagram, each color stands for a network namespace, which is connected by a Linux bridge v-net-0.

  • veth-red and veth-red-br are a pair of veth.
  • veth-blue and veth-blue-br are a pair of veth.
  • v-net-0 is a linux bridge.

enter image description here

what does "master" mean in this command?

ip link set veth-blue-br master v-net-0

I have checked the man page of ip link set, but still don't understand the meaning of flag master.

Ryan Lyu
  • 194
  • 1
  • 10

2 Answers2

4

I will assume:

  • v-net-0 was created with something like ip link add name v-net-0 type bridge
  • veth-blue-br was created with something like ip link add veth-blue-br type veth peer name veth-blue

It is my understanding that the "master" parameter adds your virtual interface "veth-blue-br" into the bridge called "v-net-0".

I find the term "master" to be a bit confusing for bridging, but I suppose from a certain point of view, it makes sense. From the point of view of the "ip" command, which is generic in the sense that it can configure a number of types of interfaces (e.g. bond, vlan - not just bridge), it is useful to have similar terms (e.g. master) when indicating that an interface is dependant upon another. However, if you happen to be familiar with bridging / switching outside of the iproute2 software world (the ip command is part of iproute2), then the term "master" might be a bit confusing.

The obsolete command "brctl", has a sub-command called "addif", and if you read the man page for brctl, there is a reasonable description under "addif" (quoted below), and I believe this is what the "master" parameter in "ip link set" is doing. Note that brctl makes no mention of the word "master". The functionality from brctl has been added to ip/bridge from iproute2. However, there are useful sections from the brctl man page which don't seem to have made it into the ip/bridge man pages.

The command brctl addif <brname> <ifname> will make the interface <ifname> a port of the bridge <brname>. This means that all frames received on <ifname> will be processed as if destined for the bridge. Also, when sending frames on <brname>, <ifname> will be considered as a potential output interface.

DericS
  • 691
  • 2
  • 5
  • Thanks for your feedback. I have added more details as context. – Ryan Lyu Apr 28 '22 at 08:22
  • There's a number of interface constructs that can point to another interface, and they all share the property that this interface is now dependent on the "master", which is the reason for the name. – dirkt Apr 28 '22 at 11:11
  • @dirkt Agreed. From the point of view of the "ip" command, which is generic in the sense that it can configure a number of types of interfaces (not just bridge), it is useful to have similar terms (e.g. master) when indicating that an interface is dependant upon another. However, if you happen to be familiar with bridging / switching outside of the iproute2 software world, then the term "master" might be a bit confusing. I will attempt to clarify my answer on that point. – DericS Apr 28 '22 at 12:57
2

The purpose of the master option is to attach the network device (veth-blue-br) to a network bridge (v-net-o).

In the context of network devices and Linux network configuration, a network bridge can be considered a "master" in the sense that it acts as a central point of connectivity and control for devices attached to it.

When you add a network device, such as a virtual Ethernet (veth) pair, to a network bridge using the master option, you are effectively making that network bridge the "master" of the device. The bridge assumes control over the device's connectivity, forwarding packets between the devices attached to the bridge.

Amin
  • 121
  • 1
  • For the inner workings: https://vincent.bernat.ch/en/blog/2017-linux-bridge-isolation#bridge-processing – A.B Jul 23 '23 at 11:02