Anatomy of A Linux Bridge
Anatomy of A Linux Bridge
Nuutti Varis
Aalto University School of Electrical Engineering,
Department of Communications and Networking
P.O.Box 13000, 00076 Aalto, Finland
Email: {firstname.lastname}@aalto.fi
ABSTRACT tures, such as port MAC address limits, and SNMP mon-
Ethernet is the prevalent Local Area Networking (LAN) itoring of the bridge state. OpenSolaris also implements a
technology, offering a cost efficient way to connect end-hosts bridging subsystem [12] that supports STP, RSTP, or a next
to each other. Local area networks are built by network- generation bridging protocol called TRILL [14].
ing devices called switches, that forward Ethernet frames
between end-hosts in the network. The GNU/Linux oper- There has been relatively little evolution in bridging since
ating system can be used to create a software based switch, the inception of the STP. Switches have evolved in con-
called a bridge. This paper explores the architecture, design, junction with other local area network technologies such
and implementation of the Linux bridging component, and as Virtual LANs [16], while the STP has been incremen-
attempts to chart some of the processing characteristics of tally extended to support these new technologies. Currently,
the frame forwarding operation, inside the bridge and in the there are two practical next-generation solutions for switch-
operating system as a whole. ing: RBridges (TRILL), and the Shortest Path Bridging
(SPB) [1]. Both TRILL and SPB diverge from STP based
bridging in several important ways. Some of the key differ-
1. INTRODUCTION ences are improved loop safety, more efficient unicast for-
Network devices, called switches (or synonymously, bridges) warding, and improved multicast forwarding. Additionally,
are responsible for connecting several network links to each the well known scalability issues [2] of the local area net-
other, creating a local area network. Conceptually, the ma- works, and the advent of data center networking has also cre-
jor components of a network switch are a set of network ated a number of academic research papers, such as SPAIN [10],
ports, a control plane, a forwarding plane, and a MAC learn- Port Land [11], VL2 [6], DCell [7], and BCube [8].
ing database. The set of ports are used to forward traffic
between other switches and end-hosts in the network. The This paper explores the architecture, design and the im-
control plane of a switch is typically used to run the Span- plementation of the Linux bridging module. In addition,
ning Tree Protocol (STP) [15], that calculates a minimum the paper also analyzes the processing characteristics of the
spanning tree for the local area network, preventing physi- Linux bridging module by profiling the kernel during for-
cal loops from crashing the network. The forwarding plane warding, and observing various counters that track the per-
is responsible for processing input frames from the network formance of the processors and the memory in the multi-core
ports, and making a forwarding decision on which network CPU. The design and implementation of STP in the Linux
ports the input frame is forwarded to. bridge module is considered out of scope for this paper.
Finally, the MAC learning database is used to keep track of The rest of the paper is structured as follows. Section 2
the host locations in the LAN. It typically contains an entry presents an overview of the central data structures of the
for each host MAC address that traverses the switch, and Linux bridge, creation of a Linux bridge instance, and the
the input port where the frame was received. The forward- processing flow of an incoming frame. Next, Section 3 de-
ing decision is based on this information. For each unicast scribes the forwarding database functionality of the bridge
destination MAC address, the switch looks up the output implementation. Section 4 describes the experimentation
port in the MAC database. If an entry is found, the frame setup, and analyzes some of the performance related aspects
is forwarded through the port further into the network. If of the bridging module and the operating system. Finally,
an entry is not found, the frame is instead flooded from all Section 5 finishes the paper with some general remarks of
other network ports in the switch, except the port where local area networks and the Linux bridging implementation.
the frame was received. This latter provision is required to
guarantee the ”plug-and-play” nature of Ethernet.
2. OVERVIEW
In addition to Linux, several other operating systems also The architectural overview of the Linux bridging module
implement local area network bridging in the network stack. is divided into three parts. First, the key data structures
FreeBSD has a similar bridging implementation to Linux for the bridging module are described in detail. Next, the
kernel, however the FreeBSD implementation also imple- configuration interface of the Linux bridging module is dis-
ments the Rapid Spanning Tree Protocol (RSTP). The FreeBSD cussed by looking at the bridge creation and port addition
bridge implementation also supports more advanced fea- mechanisms. Finally, the input/output processing flow of
net/bridge/br_ioctl.c net/bridge/br_if.c net/core/dev.c
net_bridge net_bridge_port
net_bridge_fdb_ br_ioctl_deviceless_stub br_add_bridge alloc_netdev
entry lock br SIOCBRADDBR
0..1023
hlist port_list dev net/bridge/br_device.c
SIOCBRADDIF
dst 0..255
dev list br_ioctl_dev Bridge Device br_dev_setup
... ... …
updated hash_lock net/core/dev.c