While I am studying on RTNETLINK, I understand that the kernel will send RTM_ADDLINK or RTM_DELLINK if interface is added/removed at kernel space. However, I have a question regarding to the RTNETLINK message if adding or removing ethernet to/from bridge? Since adding or removing ethernet to / from bridge is not actually adding or removing interface, is there any RTNETLINK message actually transferring in between?
1 Answers
Rtnetlink handles routing and other layer 3 details for interfaces. To simply add an interface to a bridge will not involve rtnetlink at all. Bridging - and attaching interfaces to bridges - happens entirely at layer 2.
It's only when we apply IP addresses and start needing to modify the routing table that we need to involve rtnetlink. Since any layer 3 addressing starts above the bridge rather than below it, this is never a concern when adding interfaces.
You don't even need an IP on a bridge for it to function as a layer 2 switching device. You also don't need to give a bridge an IP in order to bring it up. When you give it a layer 3 address, rtnetlink is called to intelligently modify your routing tables. It's irrelevant whether this layer 3 address is ties to a bridge, a physical NIC, or a tap device.

- 7,046
- 18
- 29
-
Thanks for the help! This is what I am thinking actually. However, I am not sure why I am receiving a RTM_DELLINK after removing interface from bridge. Also, net/bridge/br_netlink.c suggests that this is the behavior, is this correct? – user4826904 Mar 13 '17 at 08:30
-
No, the RTM_NEWLINK, RTM_DELLINK are events for link-level events. These netlink events are generated even by link bridging, as experienced by question author. – Petr Gotthard Sep 25 '22 at 19:54