xref: /freebsd-src/share/man/man4/bridge.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
14e1c3993SAndrew Thompson.\"	$NetBSD: bridge.4,v 1.5 2004/01/31 20:14:11 jdc Exp $
24e1c3993SAndrew Thompson.\"
34e1c3993SAndrew Thompson.\" Copyright 2001 Wasabi Systems, Inc.
44e1c3993SAndrew Thompson.\" All rights reserved.
54e1c3993SAndrew Thompson.\"
64e1c3993SAndrew Thompson.\" Written by Jason R. Thorpe for Wasabi Systems, Inc.
74e1c3993SAndrew Thompson.\"
84e1c3993SAndrew Thompson.\" Redistribution and use in source and binary forms, with or without
94e1c3993SAndrew Thompson.\" modification, are permitted provided that the following conditions
104e1c3993SAndrew Thompson.\" are met:
114e1c3993SAndrew Thompson.\" 1. Redistributions of source code must retain the above copyright
124e1c3993SAndrew Thompson.\"    notice, this list of conditions and the following disclaimer.
134e1c3993SAndrew Thompson.\" 2. Redistributions in binary form must reproduce the above copyright
144e1c3993SAndrew Thompson.\"    notice, this list of conditions and the following disclaimer in the
154e1c3993SAndrew Thompson.\"    documentation and/or other materials provided with the distribution.
164e1c3993SAndrew Thompson.\" 3. All advertising materials mentioning features or use of this software
174e1c3993SAndrew Thompson.\"    must display the following acknowledgement:
184e1c3993SAndrew Thompson.\"	This product includes software developed for the NetBSD Project by
194e1c3993SAndrew Thompson.\"	Wasabi Systems, Inc.
204e1c3993SAndrew Thompson.\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
214e1c3993SAndrew Thompson.\"    or promote products derived from this software without specific prior
224e1c3993SAndrew Thompson.\"    written permission.
234e1c3993SAndrew Thompson.\"
244e1c3993SAndrew Thompson.\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
254e1c3993SAndrew Thompson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
264e1c3993SAndrew Thompson.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
274e1c3993SAndrew Thompson.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
284e1c3993SAndrew Thompson.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
294e1c3993SAndrew Thompson.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
304e1c3993SAndrew Thompson.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
314e1c3993SAndrew Thompson.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
324e1c3993SAndrew Thompson.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
334e1c3993SAndrew Thompson.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
344e1c3993SAndrew Thompson.\" POSSIBILITY OF SUCH DAMAGE.
354e1c3993SAndrew Thompson.\"
363fdb40d1SZhenlei Huang.Dd April 10, 2023
374e1c3993SAndrew Thompson.Dt IF_BRIDGE 4
384e1c3993SAndrew Thompson.Os
394e1c3993SAndrew Thompson.Sh NAME
404e1c3993SAndrew Thompson.Nm if_bridge
414e1c3993SAndrew Thompson.Nd network bridge device
424e1c3993SAndrew Thompson.Sh SYNOPSIS
434e1c3993SAndrew ThompsonTo compile this driver into the kernel,
444e1c3993SAndrew Thompsonplace the following line in your
454e1c3993SAndrew Thompsonkernel configuration file:
464e1c3993SAndrew Thompson.Bd -ragged -offset indent
474e1c3993SAndrew Thompson.Cd "device if_bridge"
484e1c3993SAndrew Thompson.Ed
494e1c3993SAndrew Thompson.Pp
504e1c3993SAndrew ThompsonAlternatively, to load the driver as a
514e1c3993SAndrew Thompsonmodule at boot time, place the following lines in
524e1c3993SAndrew Thompson.Xr loader.conf 5 :
534e1c3993SAndrew Thompson.Bd -literal -offset indent
544e1c3993SAndrew Thompsonif_bridge_load="YES"
554e1c3993SAndrew Thompsonbridgestp_load="YES"
564e1c3993SAndrew Thompson.Ed
574e1c3993SAndrew Thompson.Sh DESCRIPTION
584e1c3993SAndrew ThompsonThe
594e1c3993SAndrew Thompson.Nm
604e1c3993SAndrew Thompsondriver creates a logical link between two or more IEEE 802 networks
614e1c3993SAndrew Thompsonthat use the same (or
624e1c3993SAndrew Thompson.Dq "similar enough" )
634e1c3993SAndrew Thompsonframing format.
644e1c3993SAndrew ThompsonFor example, it is possible to bridge Ethernet and 802.11 networks together,
654e1c3993SAndrew Thompsonbut it is not possible to bridge Ethernet and Token Ring together.
664e1c3993SAndrew Thompson.Pp
674e1c3993SAndrew ThompsonEach
684e1c3993SAndrew Thompson.Nm
694e1c3993SAndrew Thompsoninterface is created at runtime using interface cloning.
704e1c3993SAndrew ThompsonThis is
714e1c3993SAndrew Thompsonmost easily done with the
724e1c3993SAndrew Thompson.Xr ifconfig 8
734e1c3993SAndrew Thompson.Cm create
744e1c3993SAndrew Thompsoncommand or using the
754e1c3993SAndrew Thompson.Va cloned_interfaces
764e1c3993SAndrew Thompsonvariable in
774e1c3993SAndrew Thompson.Xr rc.conf 5 .
784e1c3993SAndrew Thompson.Pp
794e1c3993SAndrew ThompsonThe
804e1c3993SAndrew Thompson.Nm
814e1c3993SAndrew Thompsoninterface randomly chooses a link (MAC) address in the range reserved for
824e1c3993SAndrew Thompsonlocally administered addresses when it is created.
834e1c3993SAndrew ThompsonThis address is guaranteed to be unique
844e1c3993SAndrew Thompson.Em only
854e1c3993SAndrew Thompsonacross all
864e1c3993SAndrew Thompson.Nm
874e1c3993SAndrew Thompsoninterfaces on the local machine.
886777f10cSJens SchweikhardtThus you can theoretically have two bridges on different machines with
894e1c3993SAndrew Thompsonthe same link addresses.
904e1c3993SAndrew ThompsonThe address can be changed by assigning the desired link address using
914e1c3993SAndrew Thompson.Xr ifconfig 8 .
924e1c3993SAndrew Thompson.Pp
934e1c3993SAndrew ThompsonIf
944e1c3993SAndrew Thompson.Xr sysctl 8
954e1c3993SAndrew Thompsonnode
964e1c3993SAndrew Thompson.Va net.link.bridge.inherit_mac
978406182dSTom Marcoenhas a non-zero value, the newly created bridge will inherit the MAC
988406182dSTom Marcoenaddress from its first member instead of choosing a random link-level
998406182dSTom Marcoenaddress.
1008406182dSTom MarcoenThis will provide more predictable bridge MAC addresses without any
1018406182dSTom Marcoenadditional configuration, but currently this feature is known to break
1028406182dSTom Marcoensome L2 protocols, for example PPPoE that is provided by
1034e1c3993SAndrew Thompson.Xr ng_pppoe 4
1044e1c3993SAndrew Thompsonand
1054e1c3993SAndrew Thompson.Xr ppp 8 .
1068406182dSTom MarcoenCurrently this feature is considered as experimental and is turned off
1076777f10cSJens Schweikhardtby default.
1084e1c3993SAndrew Thompson.Pp
1094e1c3993SAndrew ThompsonA bridge can be used to provide several services, such as a simple
1108406182dSTom Marcoen802.11-to-Ethernet bridge for wireless hosts, or traffic isolation.
1114e1c3993SAndrew Thompson.Pp
11264237537SChristian BruefferA bridge works like a switch, forwarding traffic from one interface
1134e1c3993SAndrew Thompsonto another.
1144e1c3993SAndrew ThompsonMulticast and broadcast packets are always forwarded to all
1154e1c3993SAndrew Thompsoninterfaces that are part of the bridge.
1164e1c3993SAndrew ThompsonFor unicast traffic, the bridge learns which MAC addresses are associated
1174e1c3993SAndrew Thompsonwith which interfaces and will forward the traffic selectively.
1184e1c3993SAndrew Thompson.Pp
1193fdb40d1SZhenlei HuangBy default the bridge logs MAC address port flapping to
1203fdb40d1SZhenlei Huang.Xr syslog 3 .
1213fdb40d1SZhenlei HuangThis behavior can be disabled by setting the
1223fdb40d1SZhenlei Huang.Xr sysctl 8
1233fdb40d1SZhenlei Huangvariable
1243fdb40d1SZhenlei Huang.Va net.link.bridge.log_mac_flap
1253fdb40d1SZhenlei Huangto
1263fdb40d1SZhenlei Huang.Li 0 .
1273fdb40d1SZhenlei Huang.Pp
1284e1c3993SAndrew ThompsonAll the bridged member interfaces need to be up in order to pass network traffic.
1294e1c3993SAndrew ThompsonThese can be enabled using
1304e1c3993SAndrew Thompson.Xr ifconfig 8
1314e1c3993SAndrew Thompsonor
1324e1c3993SAndrew Thompson.Va ifconfig_ Ns Ao Ar interface Ac Ns Li ="up"
1334e1c3993SAndrew Thompsonin
1344e1c3993SAndrew Thompson.Xr rc.conf 5 .
1354e1c3993SAndrew Thompson.Pp
1364e1c3993SAndrew ThompsonThe MTU of the first member interface to be added is used as the bridge MTU.
137b4174079SKristof ProvostAll additional members will have their MTU changed to match.
138b4174079SKristof ProvostIf the MTU of a bridge is changed after its creation, the MTU of all member
139b4174079SKristof Provostinterfaces is also changed to match.
1404e1c3993SAndrew Thompson.Pp
1410c40a4acSAlexander MotinThe TOE, TSO, TXCSUM and TXCSUM6 capabilities on all interfaces added to the
1428406182dSTom Marcoenbridge are disabled if any of the interfaces do not support/enable them.
1430c40a4acSAlexander MotinThe LRO capability is always disabled.
1446777f10cSJens SchweikhardtAll the capabilities are restored when the interface is removed from the bridge.
1456777f10cSJens SchweikhardtChanging capabilities at run-time may cause NIC reinit and a link flap.
1464e1c3993SAndrew Thompson.Pp
1474e1c3993SAndrew ThompsonThe bridge supports
1484e1c3993SAndrew Thompson.Dq monitor mode ,
1494e1c3993SAndrew Thompsonwhere the packets are discarded after
1504e1c3993SAndrew Thompson.Xr bpf 4
1514e1c3993SAndrew Thompsonprocessing, and are not processed or forwarded further.
1524e1c3993SAndrew ThompsonThis can be used to multiplex the input of two or more interfaces into a single
1534e1c3993SAndrew Thompson.Xr bpf 4
1544e1c3993SAndrew Thompsonstream.
1554e1c3993SAndrew ThompsonThis is useful for reconstructing the traffic for network taps
1564e1c3993SAndrew Thompsonthat transmit the RX/TX signals out through two separate interfaces.
157a1726af1SHiroki Sato.Sh IPV6 SUPPORT
158a1726af1SHiroki Sato.Nm
159a1726af1SHiroki Satosupports the
160a1726af1SHiroki Sato.Li AF_INET6
161a1726af1SHiroki Satoaddress family on bridge interfaces.
162a1726af1SHiroki SatoThe following
163a1726af1SHiroki Sato.Xr rc.conf 5
164a1726af1SHiroki Satovariable configures an IPv6 link-local address on
165a1726af1SHiroki Sato.Li bridge0
166a1726af1SHiroki Satointerface:
167a1726af1SHiroki Sato.Bd -literal -offset indent
168a1726af1SHiroki Satoifconfig_bridge0_ipv6="up"
169a1726af1SHiroki Sato.Ed
170a1726af1SHiroki Sato.Pp
171a1726af1SHiroki Satoor in a more explicit manner:
172a1726af1SHiroki Sato.Bd -literal -offset indent
173a1726af1SHiroki Satoifconfig_bridge0_ipv6="inet6 auto_linklocal"
174a1726af1SHiroki Sato.Ed
175a1726af1SHiroki Sato.Pp
176a1726af1SHiroki SatoHowever, the
177a1726af1SHiroki Sato.Li AF_INET6
178a1726af1SHiroki Satoaddress family has a concept of scope zone.
1796777f10cSJens SchweikhardtBridging multiple interfaces changes the zone configuration because
180a1726af1SHiroki Satomultiple links are merged to each other and form a new single link
181a1726af1SHiroki Satowhile the member interfaces still work individually.
182a1726af1SHiroki SatoThis means each member interface still has a separate link-local scope
183a1726af1SHiroki Satozone and the
184a1726af1SHiroki Sato.Nm
185a1726af1SHiroki Satointerface has another single,
186a1726af1SHiroki Satoaggregated link-local scope zone at the same time.
187a1726af1SHiroki SatoThis situation is clearly against the description
188a1726af1SHiroki Sato.Qq zones of the same scope cannot overlap
189a1726af1SHiroki Satoin Section 5,
190a1726af1SHiroki SatoRFC 4007.
191a1726af1SHiroki SatoAlthough it works in most cases,
19228ba36c6SGuangyuan Yangit can cause some counterintuitive or undesirable behavior in some
1936777f10cSJens Schweikhardtedge cases when both, the
194a1726af1SHiroki Sato.Nm
1956777f10cSJens Schweikhardtinterface and one of the member interfaces, have an IPv6 address
196a1726af1SHiroki Satoand applications use both of them.
197a1726af1SHiroki Sato.Pp
198a1726af1SHiroki SatoTo prevent this situation,
199a1726af1SHiroki Sato.Nm
200ca86c84dSHiroki Satochecks whether a link-local scoped IPv6 address is configured on
201a1726af1SHiroki Satoa member interface to be added and the
202a1726af1SHiroki Sato.Nm
203a1726af1SHiroki Satointerface.
204a1726af1SHiroki SatoWhen the
205a1726af1SHiroki Sato.Nm
206a1726af1SHiroki Satointerface has IPv6 addresses,
207a1726af1SHiroki SatoIPv6 addresses on the member interface will be automatically removed
208a1726af1SHiroki Satobefore the interface is added.
209ca86c84dSHiroki Sato.Pp
21028ba36c6SGuangyuan YangThis behavior can be disabled by setting
211ca86c84dSHiroki Sato.Xr sysctl 8
212ca86c84dSHiroki Satovariable
213ca86c84dSHiroki Sato.Va net.link.bridge.allow_llz_overlap
214ca86c84dSHiroki Satoto
215ca86c84dSHiroki Sato.Li 1 .
216a1726af1SHiroki Sato.Pp
217a1726af1SHiroki SatoNote that
218a1726af1SHiroki Sato.Li ACCEPT_RTADV
219a1726af1SHiroki Satoand
220a1726af1SHiroki Sato.Li AUTO_LINKLOCAL
2216777f10cSJens Schweikhardtinterface flags are not enabled by default on
222a1726af1SHiroki Sato.Nm
2236777f10cSJens Schweikhardtinterfaces even when
224a1726af1SHiroki Sato.Va net.inet6.ip6.accept_rtadv
225a1726af1SHiroki Satoand/or
226a1726af1SHiroki Sato.Va net.inet6.ip6.auto_linklocal
227a1726af1SHiroki Satois set to
228a1726af1SHiroki Sato.Li 1 .
2294e1c3993SAndrew Thompson.Sh SPANNING TREE
2304e1c3993SAndrew ThompsonThe
2314e1c3993SAndrew Thompson.Nm
2324e1c3993SAndrew Thompsondriver implements the Rapid Spanning Tree Protocol (RSTP or 802.1w) with
2334e1c3993SAndrew Thompsonbackwards compatibility with the legacy Spanning Tree Protocol (STP).
2344e1c3993SAndrew ThompsonSpanning Tree is used to detect and remove loops in a network topology.
2354e1c3993SAndrew Thompson.Pp
2364e1c3993SAndrew ThompsonRSTP provides faster spanning tree convergence than legacy STP, the protocol
2374e1c3993SAndrew Thompsonwill exchange information with neighbouring switches to quickly transition to
2384e1c3993SAndrew Thompsonforwarding without creating loops.
2394e1c3993SAndrew Thompson.Pp
2404e1c3993SAndrew ThompsonThe code will default to RSTP mode but will downgrade any port connected to a
2414e1c3993SAndrew Thompsonlegacy STP network so is fully backward compatible.
2424e1c3993SAndrew ThompsonA bridge can be forced to operate in STP mode without rapid state transitions
2434e1c3993SAndrew Thompsonvia the
2444e1c3993SAndrew Thompson.Va proto
2454e1c3993SAndrew Thompsoncommand in
2464e1c3993SAndrew Thompson.Xr ifconfig 8 .
2474e1c3993SAndrew Thompson.Pp
2484e1c3993SAndrew ThompsonThe bridge can log STP port changes to
2494e1c3993SAndrew Thompson.Xr syslog 3
2506777f10cSJens Schweikhardtby setting the
2514e1c3993SAndrew Thompson.Va net.link.bridge.log_stp
2526777f10cSJens Schweikhardtnode using
2534e1c3993SAndrew Thompson.Xr sysctl 8 .
2544e1c3993SAndrew Thompson.Sh PACKET FILTERING
2554e1c3993SAndrew ThompsonPacket filtering can be used with any firewall package that hooks in via the
2564e1c3993SAndrew Thompson.Xr pfil 9
2574e1c3993SAndrew Thompsonframework.
2584e1c3993SAndrew ThompsonWhen filtering is enabled, bridged packets will pass through the filter
2594e1c3993SAndrew Thompsoninbound on the originating interface, on the bridge interface and outbound on
2604e1c3993SAndrew Thompsonthe appropriate interfaces.
2614e1c3993SAndrew ThompsonEither stage can be disabled.
26228ba36c6SGuangyuan YangThe filtering behavior can be controlled using
2634e1c3993SAndrew Thompson.Xr sysctl 8 :
2644e1c3993SAndrew Thompson.Bl -tag -width ".Va net.link.bridge.pfil_onlyip"
2654e1c3993SAndrew Thompson.It Va net.link.bridge.pfil_onlyip
2664e1c3993SAndrew ThompsonControls the handling of non-IP packets which are not passed to
2674e1c3993SAndrew Thompson.Xr pfil 9 .
2684e1c3993SAndrew ThompsonSet to
2694e1c3993SAndrew Thompson.Li 1
2704e1c3993SAndrew Thompsonto only allow IP packets to pass (subject to firewall rules), set to
2714e1c3993SAndrew Thompson.Li 0
2724e1c3993SAndrew Thompsonto unconditionally pass all non-IP Ethernet frames.
2734e1c3993SAndrew Thompson.It Va net.link.bridge.pfil_member
2744e1c3993SAndrew ThompsonSet to
2754e1c3993SAndrew Thompson.Li 1
2764e1c3993SAndrew Thompsonto enable filtering on the incoming and outgoing member interfaces, set
2774e1c3993SAndrew Thompsonto
2784e1c3993SAndrew Thompson.Li 0
2794e1c3993SAndrew Thompsonto disable it.
2804e1c3993SAndrew Thompson.It Va net.link.bridge.pfil_bridge
2814e1c3993SAndrew ThompsonSet to
2824e1c3993SAndrew Thompson.Li 1
2834e1c3993SAndrew Thompsonto enable filtering on the bridge interface, set
2844e1c3993SAndrew Thompsonto
2854e1c3993SAndrew Thompson.Li 0
2864e1c3993SAndrew Thompsonto disable it.
2874e1c3993SAndrew Thompson.It Va net.link.bridge.pfil_local_phys
2884e1c3993SAndrew ThompsonSet to
2894e1c3993SAndrew Thompson.Li 1
2904e1c3993SAndrew Thompsonto additionally filter on the physical interface for locally destined packets.
2914e1c3993SAndrew ThompsonSet to
2924e1c3993SAndrew Thompson.Li 0
2934e1c3993SAndrew Thompsonto disable this feature.
2944e1c3993SAndrew Thompson.It Va net.link.bridge.ipfw
2954e1c3993SAndrew ThompsonSet to
2964e1c3993SAndrew Thompson.Li 1
2974e1c3993SAndrew Thompsonto enable layer2 filtering with
2984e1c3993SAndrew Thompson.Xr ipfirewall 4 ,
2994e1c3993SAndrew Thompsonset to
3004e1c3993SAndrew Thompson.Li 0
3014e1c3993SAndrew Thompsonto disable it.
3024e1c3993SAndrew ThompsonThis needs to be enabled for
3034e1c3993SAndrew Thompson.Xr dummynet 4
3044e1c3993SAndrew Thompsonsupport.
3054e1c3993SAndrew ThompsonWhen
3064e1c3993SAndrew Thompson.Va ipfw
3074e1c3993SAndrew Thompsonis enabled,
3084e1c3993SAndrew Thompson.Va pfil_bridge
3094e1c3993SAndrew Thompsonand
3104e1c3993SAndrew Thompson.Va pfil_member
3114e1c3993SAndrew Thompsonwill be disabled so that IPFW
3124e1c3993SAndrew Thompsonis not run twice; these can be re-enabled if desired.
3134e1c3993SAndrew Thompson.It Va net.link.bridge.ipfw_arp
3144e1c3993SAndrew ThompsonSet to
3154e1c3993SAndrew Thompson.Li 1
3164e1c3993SAndrew Thompsonto enable layer2 ARP filtering with
3174e1c3993SAndrew Thompson.Xr ipfirewall 4 ,
3184e1c3993SAndrew Thompsonset to
3194e1c3993SAndrew Thompson.Li 0
3204e1c3993SAndrew Thompsonto disable it.
3214e1c3993SAndrew ThompsonRequires
3224e1c3993SAndrew Thompson.Va ipfw
3234e1c3993SAndrew Thompsonto be enabled.
3244e1c3993SAndrew Thompson.El
3254e1c3993SAndrew Thompson.Pp
3264e1c3993SAndrew ThompsonARP and REVARP packets are forwarded without being filtered and others
3274e1c3993SAndrew Thompsonthat are not IP nor IPv6 packets are not forwarded when
3284e1c3993SAndrew Thompson.Va pfil_onlyip
3294e1c3993SAndrew Thompsonis enabled.
3304e1c3993SAndrew ThompsonIPFW can filter Ethernet types using
3314e1c3993SAndrew Thompson.Cm mac-type
3324e1c3993SAndrew Thompsonso all packets are passed to
3334e1c3993SAndrew Thompsonthe filter for processing.
3344e1c3993SAndrew Thompson.Pp
3354e1c3993SAndrew ThompsonThe packets originating from the bridging host will be seen by
3364e1c3993SAndrew Thompsonthe filter on the interface that is looked up in the routing
3374e1c3993SAndrew Thompsontable.
3384e1c3993SAndrew Thompson.Pp
3394e1c3993SAndrew ThompsonThe packets destined to the bridging host will be seen by the filter
3404e1c3993SAndrew Thompsonon the interface with the MAC address equal to the packet's destination
3414e1c3993SAndrew ThompsonMAC.
3424e1c3993SAndrew ThompsonThere are situations when some of the bridge members are sharing
3434e1c3993SAndrew Thompsonthe same MAC address (for example the
3444e1c3993SAndrew Thompson.Xr vlan 4
345b06cfd40SJoel Dahlinterfaces: they are currently sharing the
3464e1c3993SAndrew ThompsonMAC address of the parent physical interface).
3474e1c3993SAndrew ThompsonIt is not possible to distinguish between these interfaces using
3484e1c3993SAndrew Thompsontheir MAC address, excluding the case when the packet's destination
3494e1c3993SAndrew ThompsonMAC address is equal to the MAC address of the interface on which
3504e1c3993SAndrew Thompsonthe packet was entered to the system.
3514e1c3993SAndrew ThompsonIn this case the filter will see the incoming packet on this
3524e1c3993SAndrew Thompsoninterface.
3534e1c3993SAndrew ThompsonIn all other cases the interface seen by the packet filter is chosen
3544e1c3993SAndrew Thompsonfrom the list of bridge members with the same MAC address and the
3554e1c3993SAndrew Thompsonresult strongly depends on the member addition sequence and the
3564e1c3993SAndrew Thompsonactual implementation of
3574e1c3993SAndrew Thompson.Nm .
3584e1c3993SAndrew ThompsonIt is not recommended to rely on the order chosen by the current
3594e1c3993SAndrew Thompson.Nm
3606777f10cSJens Schweikhardtimplementation since it may change in the future.
3614e1c3993SAndrew Thompson.Pp
3624e1c3993SAndrew ThompsonThe previous paragraph is best illustrated with the following
3634e1c3993SAndrew Thompsonpictures.
3644e1c3993SAndrew ThompsonLet
3654e1c3993SAndrew Thompson.Bl -bullet
3664e1c3993SAndrew Thompson.It
3674e1c3993SAndrew Thompsonthe MAC address of the incoming packet's destination is
3684e1c3993SAndrew Thompson.Nm nn:nn:nn:nn:nn:nn ,
3694e1c3993SAndrew Thompson.It
3704e1c3993SAndrew Thompsonthe interface on which packet entered the system is
3714e1c3993SAndrew Thompson.Nm ifX ,
3724e1c3993SAndrew Thompson.It
3734e1c3993SAndrew Thompson.Nm ifX
3744e1c3993SAndrew ThompsonMAC address is
3754e1c3993SAndrew Thompson.Nm xx:xx:xx:xx:xx:xx ,
3764e1c3993SAndrew Thompson.It
3774e1c3993SAndrew Thompsonthere are possibly other bridge members with the same MAC address
3784e1c3993SAndrew Thompson.Nm xx:xx:xx:xx:xx:xx ,
3794e1c3993SAndrew Thompson.It
3804e1c3993SAndrew Thompsonthe bridge has more than one interface that are sharing the
3814e1c3993SAndrew Thompsonsame MAC address
3824e1c3993SAndrew Thompson.Nm yy:yy:yy:yy:yy:yy ;
3834e1c3993SAndrew Thompsonwe will call them
3844e1c3993SAndrew Thompson.Nm vlanY1 ,
3854e1c3993SAndrew Thompson.Nm vlanY2 ,
3864e1c3993SAndrew Thompsonetc.
3874e1c3993SAndrew Thompson.El
3884e1c3993SAndrew Thompson.Pp
3896777f10cSJens SchweikhardtIf the MAC address
3904e1c3993SAndrew Thompson.Nm nn:nn:nn:nn:nn:nn
3916777f10cSJens Schweikhardtis equal to
3924e1c3993SAndrew Thompson.Nm xx:xx:xx:xx:xx:xx
3936777f10cSJens Schweikhardtthe filter will see the packet on interface
3944e1c3993SAndrew Thompson.Nm ifX
3954e1c3993SAndrew Thompsonno matter if there are any other bridge members carrying the same
3964e1c3993SAndrew ThompsonMAC address.
3974e1c3993SAndrew ThompsonBut if the MAC address
3984e1c3993SAndrew Thompson.Nm nn:nn:nn:nn:nn:nn
3996777f10cSJens Schweikhardtis equal to
4004e1c3993SAndrew Thompson.Nm yy:yy:yy:yy:yy:yy
4014e1c3993SAndrew Thompsonthen the interface that will be seen by the filter is one of the
4024e1c3993SAndrew Thompson.Nm vlanYn .
4034e1c3993SAndrew ThompsonIt is not possible to predict the name of the actual interface
4044e1c3993SAndrew Thompsonwithout the knowledge of the system state and the
4054e1c3993SAndrew Thompson.Nm
4064e1c3993SAndrew Thompsonimplementation details.
4074e1c3993SAndrew Thompson.Pp
4084e1c3993SAndrew ThompsonThis problem arises for any bridge members that are sharing the same
4094e1c3993SAndrew ThompsonMAC address, not only to the
4104e1c3993SAndrew Thompson.Xr vlan 4
4116777f10cSJens Schweikhardtones: they were taken just as an example of such a situation.
4126777f10cSJens SchweikhardtSo if one wants to filter the locally destined packets based on
4134e1c3993SAndrew Thompsontheir interface name, one should be aware of this implication.
4144e1c3993SAndrew ThompsonThe described situation will appear at least on the filtering bridges
4154e1c3993SAndrew Thompsonthat are doing IP-forwarding; in some of such cases it is better
4164e1c3993SAndrew Thompsonto assign the IP address only to the
4174e1c3993SAndrew Thompson.Nm
4184e1c3993SAndrew Thompsoninterface and not to the bridge members.
4194e1c3993SAndrew ThompsonEnabling
4204e1c3993SAndrew Thompson.Va net.link.bridge.pfil_local_phys
4214e1c3993SAndrew Thompsonwill let you do the additional filtering on the physical interface.
422*d862b165SMark Johnston.Sh NETMAP
423*d862b165SMark Johnston.Xr netmap 4
424*d862b165SMark Johnstonapplications may open a bridge interface in emulated mode.
425*d862b165SMark JohnstonThe netmap application will receive all packets which arrive from member
426*d862b165SMark Johnstoninterfaces.
427*d862b165SMark JohnstonIn particular, packets which would otherwise be forwarded to another
428*d862b165SMark Johnstonmember interface will be received by the netmap application.
429*d862b165SMark Johnston.Pp
430*d862b165SMark JohnstonWhen the
431*d862b165SMark Johnston.Xr netmap 4
432*d862b165SMark Johnstonapplication transmits a packet to the host stack via the bridge interface,
433*d862b165SMark Johnston.Nm
434*d862b165SMark Johnstonreceive it and attempts to determine its
435*d862b165SMark Johnston.Ql source
436*d862b165SMark Johnstoninterface by looking up the source MAC address in the interface's learning
437*d862b165SMark Johnstontables.
438*d862b165SMark JohnstonPackets for which no matching source interface is found are dropped and the
439*d862b165SMark Johnstoninput error counter is incremented.
440*d862b165SMark JohnstonIf a matching source interface is found,
441*d862b165SMark Johnston.Nm
442*d862b165SMark Johnstontreats the packet as though it was received from the corresponding interface
443*d862b165SMark Johnstonand handles it normally without passing the packet back to
444*d862b165SMark Johnston.Xr netmap 4 .
4454e1c3993SAndrew Thompson.Sh EXAMPLES
4464e1c3993SAndrew ThompsonThe following when placed in the file
4474e1c3993SAndrew Thompson.Pa /etc/rc.conf
4484e1c3993SAndrew Thompsonwill cause a bridge called
4494e1c3993SAndrew Thompson.Dq Li bridge0
4504e1c3993SAndrew Thompsonto be created, and will add the interfaces
4514e1c3993SAndrew Thompson.Dq Li wlan0
4524e1c3993SAndrew Thompsonand
4534e1c3993SAndrew Thompson.Dq Li fxp0
4544e1c3993SAndrew Thompsonto the bridge, and then enable packet forwarding.
4554e1c3993SAndrew ThompsonSuch a configuration could be used to implement a simple
4564e1c3993SAndrew Thompson802.11-to-Ethernet bridge (assuming the 802.11 interface is
4574e1c3993SAndrew Thompsonin ad-hoc mode).
4584e1c3993SAndrew Thompson.Bd -literal -offset indent
4594e1c3993SAndrew Thompsoncloned_interfaces="bridge0"
4604e1c3993SAndrew Thompsonifconfig_bridge0="addm wlan0 addm fxp0 up"
4614e1c3993SAndrew Thompson.Ed
4624e1c3993SAndrew Thompson.Pp
463df81f977SDevin TeskeFor the bridge to forward packets,
464df81f977SDevin Teskeall member interfaces and the bridge need to be up.
4654e1c3993SAndrew ThompsonThe above example would also require:
4664e1c3993SAndrew Thompson.Bd -literal -offset indent
4674e1c3993SAndrew Thompsoncreate_args_wlan0="wlanmode hostap"
4684e1c3993SAndrew Thompsonifconfig_wlan0="up ssid my_ap mode 11g"
4694e1c3993SAndrew Thompsonifconfig_fxp0="up"
4704e1c3993SAndrew Thompson.Ed
4714e1c3993SAndrew Thompson.Pp
4724e1c3993SAndrew ThompsonConsider a system with two 4-port Ethernet boards.
4734e1c3993SAndrew ThompsonThe following will cause a bridge consisting of all 8 ports with Rapid Spanning
4744e1c3993SAndrew ThompsonTree enabled to be created:
4754e1c3993SAndrew Thompson.Bd -literal -offset indent
4764e1c3993SAndrew Thompsonifconfig bridge0 create
4774e1c3993SAndrew Thompsonifconfig bridge0 \e
4784e1c3993SAndrew Thompson    addm fxp0 stp fxp0 \e
4794e1c3993SAndrew Thompson    addm fxp1 stp fxp1 \e
4804e1c3993SAndrew Thompson    addm fxp2 stp fxp2 \e
4814e1c3993SAndrew Thompson    addm fxp3 stp fxp3 \e
4824e1c3993SAndrew Thompson    addm fxp4 stp fxp4 \e
4834e1c3993SAndrew Thompson    addm fxp5 stp fxp5 \e
4844e1c3993SAndrew Thompson    addm fxp6 stp fxp6 \e
4854e1c3993SAndrew Thompson    addm fxp7 stp fxp7 \e
4864e1c3993SAndrew Thompson    up
4874e1c3993SAndrew Thompson.Ed
4884e1c3993SAndrew Thompson.Pp
4894e1c3993SAndrew ThompsonThe bridge can be used as a regular host interface at the same time as bridging
4904e1c3993SAndrew Thompsonbetween its member ports.
4914e1c3993SAndrew ThompsonIn this example, the bridge connects em0 and em1, and will receive its IP
4924e1c3993SAndrew Thompsonaddress through DHCP:
4934e1c3993SAndrew Thompson.Bd -literal -offset indent
4944e1c3993SAndrew Thompsoncloned_interfaces="bridge0"
4954e1c3993SAndrew Thompsonifconfig_bridge0="addm em0 addm em1 DHCP"
4964e1c3993SAndrew Thompsonifconfig_em0="up"
4974e1c3993SAndrew Thompsonifconfig_em1="up"
4984e1c3993SAndrew Thompson.Ed
4994e1c3993SAndrew Thompson.Pp
5004e1c3993SAndrew ThompsonThe bridge can tunnel Ethernet across an IP internet using the EtherIP
5014e1c3993SAndrew Thompsonprotocol.
5024e1c3993SAndrew ThompsonThis can be combined with
5034e1c3993SAndrew Thompson.Xr ipsec 4
5044e1c3993SAndrew Thompsonto provide an encrypted connection.
5054e1c3993SAndrew ThompsonCreate a
5064e1c3993SAndrew Thompson.Xr gif 4
5074e1c3993SAndrew Thompsoninterface and set the local and remote IP addresses for the
5084e1c3993SAndrew Thompsontunnel, these are reversed on the remote bridge.
5094e1c3993SAndrew Thompson.Bd -literal -offset indent
5104e1c3993SAndrew Thompsonifconfig gif0 create
5114e1c3993SAndrew Thompsonifconfig gif0 tunnel 1.2.3.4 5.6.7.8 up
5124e1c3993SAndrew Thompsonifconfig bridge0 create
5134e1c3993SAndrew Thompsonifconfig bridge0 addm fxp0 addm gif0 up
5144e1c3993SAndrew Thompson.Ed
5154e1c3993SAndrew Thompson.Sh SEE ALSO
5164e1c3993SAndrew Thompson.Xr gif 4 ,
5174e1c3993SAndrew Thompson.Xr ipf 4 ,
5184e1c3993SAndrew Thompson.Xr ipfw 4 ,
519*d862b165SMark Johnston.Xr netmap 4 ,
5204e1c3993SAndrew Thompson.Xr pf 4 ,
5214e1c3993SAndrew Thompson.Xr ifconfig 8
5224e1c3993SAndrew Thompson.Sh HISTORY
5234e1c3993SAndrew ThompsonThe
5244e1c3993SAndrew Thompson.Nm
5254e1c3993SAndrew Thompsondriver first appeared in
5264e1c3993SAndrew Thompson.Fx 6.0 .
5274e1c3993SAndrew Thompson.Sh AUTHORS
5284e1c3993SAndrew Thompson.An -nosplit
5294e1c3993SAndrew ThompsonThe
5304e1c3993SAndrew Thompson.Nm bridge
5314e1c3993SAndrew Thompsondriver was originally written by
5326c899950SBaptiste Daroussin.An Jason L. Wright Aq Mt jason@thought.net
5334e1c3993SAndrew Thompsonas part of an undergraduate independent study at the University of
5344e1c3993SAndrew ThompsonNorth Carolina at Greensboro.
5354e1c3993SAndrew Thompson.Pp
5364e1c3993SAndrew ThompsonThis version of the
5374e1c3993SAndrew Thompson.Nm
5384e1c3993SAndrew Thompsondriver has been heavily modified from the original version by
5396c899950SBaptiste Daroussin.An Jason R. Thorpe Aq Mt thorpej@wasabisystems.com .
5404e1c3993SAndrew Thompson.Pp
5414e1c3993SAndrew ThompsonRapid Spanning Tree Protocol (RSTP) support was added by
5426c899950SBaptiste Daroussin.An Andrew Thompson Aq Mt thompsa@FreeBSD.org .
5434e1c3993SAndrew Thompson.Sh BUGS
5444e1c3993SAndrew ThompsonThe
5454e1c3993SAndrew Thompson.Nm
5464e1c3993SAndrew Thompsondriver currently supports only Ethernet and Ethernet-like (e.g., 802.11)
547b4174079SKristof Provostnetwork devices, which can be configured with the same MTU size as the bridge
548b4174079SKristof Provostdevice.
549