BRIDGE(4)

NAME
bridge - network bridge device

SYNOPSIS
pseudo-device bridge

DESCRIPTION
The bridge driver creates a logical link between two or more IEEE 802 networks that use the same (or “similar enough”) framing format. For example, it is possible to bridge Ethernet and 802.11 networks together, but it is not possible to bridge Ethernet and Token Ring together.

To use bridge, the administrator must first create the interface and configure the bridge parameters. The bridge is created using the ifconfig(8) create subcommand. See the ifconfig(8) manual page for further information on configuring bridges.

A bridge can be used to provide several services, such as a simple 802.11-to-Ethernet bridge for wireless hosts, and traffic isolation.

A bridge works like a switch, forwarding traffic from one interface to another. Multicast and broadcast packets are always forwarded to all interfaces that are part of the bridge. For unicast traffic, the bridge learns which MAC addresses are associated with which interfaces and will forward the traffic selectively. By default the bridge can keep track of 4096 MAC addresses.

The bridge operates in a safe mode by default, setting the MAC source in the link header on outgoing packets to the outgoing interface MAC. This reduces the chance that the layer-2 switching in your switches will become confused.

The bridge supports various special features via link options.

link0
    The link0 option enables transparent bridging mode. The bridge will make every effort to retain the Ethernet header when forwarding packets between interfaces, making the bridging function work more like a hardware bridge device.

link1
    The link1 option enables keepalive transmission and automatically places a member into a special blocked mode if no keepalive reception occurs. If either sides of the link uses this option then both sides must use this option. This option is implemented by sending CFG updates on the hello interval to the remote. The link is considered lost after 10 intervals (typically 20 seconds).

link2
    The link2 option enables channel bonding (see also ifbondweight and ifpriority parameters). All member interfaces with the same MAC address are considered to be in a bonding group. Packets will be sent on the highest priority interface(s) in the bonding group, and will round-robin output interfaces when multiple (highest priority) interfaces have the same priority. When something like tap(4) is used, you can manually control or copy the MAC to create bonding groups. When interface bonding is enabled, normally blocked interfaces belonging to the same bonding group as an active forwarding interface will be changed to the bonding state. Both sides of link the member represents must operate in bonding mode for this to work, otherwise the remote end may decide to throw away half your packets.

TROUBLESHOOTING
If your network becomes glitchy, with long pauses in TCP sessions, then transparent bridging mode is likely the cause. This mode should only be used when you are bridging networks with devices that do MAC-based security or firewalling (for example, the supremely braindead AT&T U-verse router), or which impose severe limitations on MAC:IP assignments.

If member interfaces constantly enter a “blocked” (link1) state then the other end of those interfaces is not implementing the link1 keepalive. Both sides must implement the keepalive.

If you get an enormous amount of packet loss and are using link2-based bonding, then the other side of those member interfaces are probably not implementing link2-based bonding.

The bridge driver implements the IEEE 802.1D Spanning Tree protocol (STP). Spanning Tree is used to detect and remove loops in a network topology.

Packet filtering can be used with any firewall package that hooks in via the pfil(9) framework. When filtering is enabled, bridged packets will pass through the filter inbound on the originating interface, on the bridge interface and outbound on the appropriate interfaces. Either stage can be disabled as well as the filtering of non IP and IPv6 packets. Note that ARP and REVARP packets are always forwarded without being filtered.

This behaviour can be controlled using sysctl(8): Set net.link.bridge.pfil_member to 1 to enable filtering on the incoming and outgoing member interfaces, set net.link.bridge.pfil_bridge to 1 to enable filtering on the bridge interface and set net.link.bridge.pfil_onlyip to 1 to only allow IP and IPv6 packets to be forwarded when filtering is enabled. For example, setting net.link.bridge.pfil_onlyip to 0 would allow PPPoE traffic over the bridge.

The default value of the net.link.bridge.pfil_* nodes is 1.

Note that packets to and from the bridging host will be seen by the filter on the interface with the appropriate address configured as well as on the interface on which the packet arrives or departs.

The MTU of the first member interface to be added is used as the bridge MTU, all additional members are required to have exactly the same value.

EXTRA FEATURES
DragonFly implements two additional features to make spanning tree operation more resilient.

Specifying link0 on the bridge interface places the bridge in transparent bridging mode. The bridge will make every attempt to retain the original source MAC in the Ethernet link header.

Specifying link1 on the bridge interface forces the bridge to generate a 802.11d CFG message on every hello interval for all interfaces participating in the STP protocol. Normally CFG messages are only generated by the root bridge interface or during topology changes. In addition the bridge code expects to receive 802.11d frames from all interface participating in the STP protocol.

An interface which fails to receive a 802.11d frame within 10 times the hello interval (usually 20 seconds) automatically goes into link1 blocking mode, which can be observed in the ifconfig(8) output for the bridge. This removes the interface from consideration and the bridge code automatically routes around it.

Using link0 and link1 together between two DragonFly boxes allows you to maintain multiple parallel links between those boxes via different networks (if you happen to be on more than one with internet access). For example, use separate OpenVPN instances and tap(4) devices for each VPN link to accomplish this, placing them in the same bridge interface on the two endpoints. The tap(4) devices do not need any IP configuration when bridged and can be assigned the same MAC address; in fact, they have to be if you want the failover to work nicely.

SEE ALSO
pf(4), ifconfig(8)

HISTORY
The bridge driver first appeared in OpenBSD 2.5 and found its way into DragonFly 1.3. Transparent bridging (link0) was added in DragonFly 2.9 in 2011.

AUTHORS
-nosplit The bridge driver was originally written by Jason L. Wright <jason@thought.net> as part of an undergraduate independent study at the University of North Carolina at Greensboro.

This version of the bridge driver has been heavily modified from the original version by Jason R. Thorpe <thorpej@wasabisystems.com>.

BUGS
The bridge driver currently supports only Ethernet and Ethernet-like (e.g., 802.11) network devices, with exactly the same interface MTU size as the bridge device.