2005-06-05 02:59:26 +00:00
|
|
|
.\" $NetBSD: bridge.4,v 1.5 2004/01/31 20:14:11 jdc Exp $
|
|
|
|
.\"
|
|
|
|
.\" Copyright 2001 Wasabi Systems, Inc.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed for the NetBSD Project by
|
|
|
|
.\" Wasabi Systems, Inc.
|
|
|
|
.\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
|
|
|
.\" or promote products derived from this software without specific prior
|
|
|
|
.\" written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
|
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
2005-06-16 18:46:17 +00:00
|
|
|
.\"
|
2023-04-10 10:07:04 +00:00
|
|
|
.Dd April 10, 2023
|
2005-06-05 02:59:26 +00:00
|
|
|
.Dt IF_BRIDGE 4
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm if_bridge
|
|
|
|
.Nd network bridge device
|
|
|
|
.Sh SYNOPSIS
|
2006-08-13 18:44:18 +00:00
|
|
|
To compile this driver into the kernel,
|
|
|
|
place the following line in your
|
|
|
|
kernel configuration file:
|
|
|
|
.Bd -ragged -offset indent
|
2005-06-16 18:46:17 +00:00
|
|
|
.Cd "device if_bridge"
|
2006-08-13 18:44:18 +00:00
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
Alternatively, to load the driver as a
|
|
|
|
module at boot time, place the following lines in
|
|
|
|
.Xr loader.conf 5 :
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
if_bridge_load="YES"
|
|
|
|
bridgestp_load="YES"
|
|
|
|
.Ed
|
2005-06-05 02:59:26 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
driver creates a logical link between two or more IEEE 802 networks
|
|
|
|
that use the same (or
|
2005-06-16 18:46:17 +00:00
|
|
|
.Dq "similar enough" )
|
2005-06-05 02:59:26 +00:00
|
|
|
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.
|
|
|
|
.Pp
|
|
|
|
Each
|
|
|
|
.Nm
|
|
|
|
interface is created at runtime using interface cloning.
|
|
|
|
This is
|
|
|
|
most easily done with the
|
|
|
|
.Xr ifconfig 8
|
|
|
|
.Cm create
|
|
|
|
command or using the
|
|
|
|
.Va cloned_interfaces
|
|
|
|
variable in
|
|
|
|
.Xr rc.conf 5 .
|
|
|
|
.Pp
|
2006-10-08 19:41:05 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
interface randomly chooses a link (MAC) address in the range reserved for
|
2006-10-21 18:04:20 +00:00
|
|
|
locally administered addresses when it is created.
|
2007-04-02 22:04:21 +00:00
|
|
|
This address is guaranteed to be unique
|
|
|
|
.Em only
|
|
|
|
across all
|
|
|
|
.Nm
|
|
|
|
interfaces on the local machine.
|
2019-10-05 09:59:00 +00:00
|
|
|
Thus you can theoretically have two bridges on different machines with
|
2007-04-02 22:04:21 +00:00
|
|
|
the same link addresses.
|
2006-10-08 19:41:05 +00:00
|
|
|
The address can be changed by assigning the desired link address using
|
|
|
|
.Xr ifconfig 8 .
|
|
|
|
.Pp
|
2008-09-08 03:28:26 +00:00
|
|
|
If
|
|
|
|
.Xr sysctl 8
|
|
|
|
node
|
|
|
|
.Va net.link.bridge.inherit_mac
|
2021-11-17 17:47:33 +00:00
|
|
|
has a non-zero value, the newly created bridge will inherit the MAC
|
|
|
|
address from its first member instead of choosing a random link-level
|
|
|
|
address.
|
|
|
|
This will provide more predictable bridge MAC addresses without any
|
|
|
|
additional configuration, but currently this feature is known to break
|
|
|
|
some L2 protocols, for example PPPoE that is provided by
|
2008-09-08 03:28:26 +00:00
|
|
|
.Xr ng_pppoe 4
|
|
|
|
and
|
|
|
|
.Xr ppp 8 .
|
2021-11-17 17:47:33 +00:00
|
|
|
Currently this feature is considered as experimental and is turned off
|
2019-10-05 09:59:00 +00:00
|
|
|
by default.
|
2008-09-08 03:28:26 +00:00
|
|
|
.Pp
|
2005-06-05 02:59:26 +00:00
|
|
|
A bridge can be used to provide several services, such as a simple
|
2021-11-17 17:47:33 +00:00
|
|
|
802.11-to-Ethernet bridge for wireless hosts, or traffic isolation.
|
2005-06-05 02:59:26 +00:00
|
|
|
.Pp
|
2010-01-09 09:30:09 +00:00
|
|
|
A bridge works like a switch, forwarding traffic from one interface
|
2005-06-05 02:59:26 +00:00
|
|
|
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.
|
|
|
|
.Pp
|
2023-04-10 10:07:04 +00:00
|
|
|
By default the bridge logs MAC address port flapping to
|
|
|
|
.Xr syslog 3 .
|
|
|
|
This behavior can be disabled by setting the
|
|
|
|
.Xr sysctl 8
|
|
|
|
variable
|
|
|
|
.Va net.link.bridge.log_mac_flap
|
|
|
|
to
|
|
|
|
.Li 0 .
|
|
|
|
.Pp
|
2006-04-28 22:37:16 +00:00
|
|
|
All the bridged member interfaces need to be up in order to pass network traffic.
|
|
|
|
These can be enabled using
|
2006-09-18 15:24:20 +00:00
|
|
|
.Xr ifconfig 8
|
2006-04-28 11:48:53 +00:00
|
|
|
or
|
2006-09-18 15:24:20 +00:00
|
|
|
.Va ifconfig_ Ns Ao Ar interface Ac Ns Li ="up"
|
2006-04-28 11:48:53 +00:00
|
|
|
in
|
|
|
|
.Xr rc.conf 5 .
|
|
|
|
.Pp
|
2006-04-28 22:37:16 +00:00
|
|
|
The MTU of the first member interface to be added is used as the bridge MTU.
|
2022-09-15 06:26:49 +00:00
|
|
|
All additional members will have their MTU changed to match.
|
|
|
|
If the MTU of a bridge is changed after its creation, the MTU of all member
|
|
|
|
interfaces is also changed to match.
|
2006-04-28 11:48:53 +00:00
|
|
|
.Pp
|
2017-10-16 12:32:57 +00:00
|
|
|
The TOE, TSO, TXCSUM and TXCSUM6 capabilities on all interfaces added to the
|
2021-11-17 17:47:33 +00:00
|
|
|
bridge are disabled if any of the interfaces do not support/enable them.
|
2017-10-16 12:32:57 +00:00
|
|
|
The LRO capability is always disabled.
|
2019-10-05 09:59:00 +00:00
|
|
|
All the capabilities are restored when the interface is removed from the bridge.
|
|
|
|
Changing capabilities at run-time may cause NIC reinit and a link flap.
|
2006-04-28 11:48:53 +00:00
|
|
|
.Pp
|
2006-04-28 22:37:16 +00:00
|
|
|
The bridge supports
|
|
|
|
.Dq monitor mode ,
|
|
|
|
where the packets are discarded after
|
2006-04-28 11:48:53 +00:00
|
|
|
.Xr bpf 4
|
2006-04-28 22:37:16 +00:00
|
|
|
processing, and are not processed or forwarded further.
|
2006-04-28 11:48:53 +00:00
|
|
|
This can be used to multiplex the input of two or more interfaces into a single
|
2006-04-28 22:37:16 +00:00
|
|
|
.Xr bpf 4
|
|
|
|
stream.
|
2006-04-28 11:48:53 +00:00
|
|
|
This is useful for reconstructing the traffic for network taps
|
|
|
|
that transmit the RX/TX signals out through two separate interfaces.
|
2013-07-09 07:55:47 +00:00
|
|
|
.Sh IPV6 SUPPORT
|
|
|
|
.Nm
|
|
|
|
supports the
|
|
|
|
.Li AF_INET6
|
|
|
|
address family on bridge interfaces.
|
|
|
|
The following
|
|
|
|
.Xr rc.conf 5
|
|
|
|
variable configures an IPv6 link-local address on
|
|
|
|
.Li bridge0
|
2013-07-09 12:25:44 +00:00
|
|
|
interface:
|
2013-07-09 07:55:47 +00:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
ifconfig_bridge0_ipv6="up"
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
or in a more explicit manner:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
ifconfig_bridge0_ipv6="inet6 auto_linklocal"
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
However, the
|
|
|
|
.Li AF_INET6
|
|
|
|
address family has a concept of scope zone.
|
2019-10-05 09:59:00 +00:00
|
|
|
Bridging multiple interfaces changes the zone configuration because
|
2013-07-09 07:55:47 +00:00
|
|
|
multiple links are merged to each other and form a new single link
|
|
|
|
while the member interfaces still work individually.
|
|
|
|
This means each member interface still has a separate link-local scope
|
|
|
|
zone and the
|
|
|
|
.Nm
|
|
|
|
interface has another single,
|
|
|
|
aggregated link-local scope zone at the same time.
|
|
|
|
This situation is clearly against the description
|
|
|
|
.Qq zones of the same scope cannot overlap
|
|
|
|
in Section 5,
|
|
|
|
RFC 4007.
|
|
|
|
Although it works in most cases,
|
2021-11-22 02:41:49 +00:00
|
|
|
it can cause some counterintuitive or undesirable behavior in some
|
2019-10-05 09:59:00 +00:00
|
|
|
edge cases when both, the
|
2013-07-09 07:55:47 +00:00
|
|
|
.Nm
|
2019-10-05 09:59:00 +00:00
|
|
|
interface and one of the member interfaces, have an IPv6 address
|
2013-07-09 07:55:47 +00:00
|
|
|
and applications use both of them.
|
|
|
|
.Pp
|
|
|
|
To prevent this situation,
|
|
|
|
.Nm
|
2013-07-31 16:26:41 +00:00
|
|
|
checks whether a link-local scoped IPv6 address is configured on
|
2013-07-09 12:25:44 +00:00
|
|
|
a member interface to be added and the
|
2013-07-09 07:55:47 +00:00
|
|
|
.Nm
|
|
|
|
interface.
|
|
|
|
When the
|
|
|
|
.Nm
|
|
|
|
interface has IPv6 addresses,
|
|
|
|
IPv6 addresses on the member interface will be automatically removed
|
|
|
|
before the interface is added.
|
2013-07-31 16:26:41 +00:00
|
|
|
.Pp
|
2021-11-22 02:41:49 +00:00
|
|
|
This behavior can be disabled by setting
|
2013-07-31 16:26:41 +00:00
|
|
|
.Xr sysctl 8
|
|
|
|
variable
|
|
|
|
.Va net.link.bridge.allow_llz_overlap
|
|
|
|
to
|
|
|
|
.Li 1 .
|
2013-07-09 07:55:47 +00:00
|
|
|
.Pp
|
|
|
|
Note that
|
|
|
|
.Li ACCEPT_RTADV
|
|
|
|
and
|
|
|
|
.Li AUTO_LINKLOCAL
|
2019-10-05 09:59:00 +00:00
|
|
|
interface flags are not enabled by default on
|
2013-07-09 07:55:47 +00:00
|
|
|
.Nm
|
2019-10-05 09:59:00 +00:00
|
|
|
interfaces even when
|
2013-07-09 07:55:47 +00:00
|
|
|
.Va net.inet6.ip6.accept_rtadv
|
|
|
|
and/or
|
|
|
|
.Va net.inet6.ip6.auto_linklocal
|
|
|
|
is set to
|
|
|
|
.Li 1 .
|
2007-01-20 02:39:34 +00:00
|
|
|
.Sh SPANNING TREE
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
driver implements the Rapid Spanning Tree Protocol (RSTP or 802.1w) with
|
|
|
|
backwards compatibility with the legacy Spanning Tree Protocol (STP).
|
|
|
|
Spanning Tree is used to detect and remove loops in a network topology.
|
|
|
|
.Pp
|
|
|
|
RSTP provides faster spanning tree convergence than legacy STP, the protocol
|
|
|
|
will exchange information with neighbouring switches to quickly transition to
|
|
|
|
forwarding without creating loops.
|
|
|
|
.Pp
|
|
|
|
The code will default to RSTP mode but will downgrade any port connected to a
|
|
|
|
legacy STP network so is fully backward compatible.
|
|
|
|
A bridge can be forced to operate in STP mode without rapid state transitions
|
|
|
|
via the
|
|
|
|
.Va proto
|
|
|
|
command in
|
|
|
|
.Xr ifconfig 8 .
|
|
|
|
.Pp
|
|
|
|
The bridge can log STP port changes to
|
|
|
|
.Xr syslog 3
|
2019-10-05 09:59:00 +00:00
|
|
|
by setting the
|
2007-01-20 02:39:34 +00:00
|
|
|
.Va net.link.bridge.log_stp
|
2019-10-05 09:59:00 +00:00
|
|
|
node using
|
2007-01-20 02:39:34 +00:00
|
|
|
.Xr sysctl 8 .
|
2006-04-28 11:48:53 +00:00
|
|
|
.Sh PACKET FILTERING
|
2005-09-06 22:38:40 +00:00
|
|
|
Packet filtering can be used with any firewall package that hooks in via the
|
|
|
|
.Xr pfil 9
|
|
|
|
framework.
|
2005-06-05 02:59:26 +00:00
|
|
|
When filtering is enabled, bridged packets will pass through the filter
|
|
|
|
inbound on the originating interface, on the bridge interface and outbound on
|
2005-06-07 21:20:18 +00:00
|
|
|
the appropriate interfaces.
|
2006-04-28 22:37:16 +00:00
|
|
|
Either stage can be disabled.
|
2021-11-22 02:41:49 +00:00
|
|
|
The filtering behavior can be controlled using
|
2005-06-05 02:59:26 +00:00
|
|
|
.Xr sysctl 8 :
|
2005-12-29 09:39:15 +00:00
|
|
|
.Bl -tag -width ".Va net.link.bridge.pfil_onlyip"
|
|
|
|
.It Va net.link.bridge.pfil_onlyip
|
2006-04-28 11:48:53 +00:00
|
|
|
Controls the handling of non-IP packets which are not passed to
|
|
|
|
.Xr pfil 9 .
|
2005-12-29 09:39:15 +00:00
|
|
|
Set to
|
|
|
|
.Li 1
|
2006-04-28 11:48:53 +00:00
|
|
|
to only allow IP packets to pass (subject to firewall rules), set to
|
2005-12-29 09:39:15 +00:00
|
|
|
.Li 0
|
|
|
|
to unconditionally pass all non-IP Ethernet frames.
|
2005-06-05 02:59:26 +00:00
|
|
|
.It Va net.link.bridge.pfil_member
|
|
|
|
Set to
|
|
|
|
.Li 1
|
2005-06-16 18:46:17 +00:00
|
|
|
to enable filtering on the incoming and outgoing member interfaces, set
|
|
|
|
to
|
2005-06-05 02:59:26 +00:00
|
|
|
.Li 0
|
|
|
|
to disable it.
|
|
|
|
.It Va net.link.bridge.pfil_bridge
|
|
|
|
Set to
|
|
|
|
.Li 1
|
2005-06-16 18:46:17 +00:00
|
|
|
to enable filtering on the bridge interface, set
|
|
|
|
to
|
2005-06-05 02:59:26 +00:00
|
|
|
.Li 0
|
|
|
|
to disable it.
|
2007-09-16 21:09:15 +00:00
|
|
|
.It Va net.link.bridge.pfil_local_phys
|
|
|
|
Set to
|
|
|
|
.Li 1
|
|
|
|
to additionally filter on the physical interface for locally destined packets.
|
|
|
|
Set to
|
|
|
|
.Li 0
|
|
|
|
to disable this feature.
|
2005-06-07 21:20:18 +00:00
|
|
|
.It Va net.link.bridge.ipfw
|
|
|
|
Set to
|
|
|
|
.Li 1
|
2005-06-16 18:46:17 +00:00
|
|
|
to enable layer2 filtering with
|
|
|
|
.Xr ipfirewall 4 ,
|
|
|
|
set to
|
2005-06-07 21:20:18 +00:00
|
|
|
.Li 0
|
|
|
|
to disable it.
|
2005-06-10 01:25:22 +00:00
|
|
|
This needs to be enabled for
|
|
|
|
.Xr dummynet 4
|
|
|
|
support.
|
2005-06-16 18:46:17 +00:00
|
|
|
When
|
|
|
|
.Va ipfw
|
|
|
|
is enabled,
|
|
|
|
.Va pfil_bridge
|
|
|
|
and
|
|
|
|
.Va pfil_member
|
|
|
|
will be disabled so that IPFW
|
|
|
|
is not run twice; these can be re-enabled if desired.
|
2006-10-24 08:47:39 +00:00
|
|
|
.It Va net.link.bridge.ipfw_arp
|
|
|
|
Set to
|
|
|
|
.Li 1
|
|
|
|
to enable layer2 ARP filtering with
|
|
|
|
.Xr ipfirewall 4 ,
|
|
|
|
set to
|
|
|
|
.Li 0
|
|
|
|
to disable it.
|
|
|
|
Requires
|
|
|
|
.Va ipfw
|
|
|
|
to be enabled.
|
2005-06-05 02:59:26 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
ARP and REVARP packets are forwarded without being filtered and others
|
2005-06-16 18:46:17 +00:00
|
|
|
that are not IP nor IPv6 packets are not forwarded when
|
2006-04-29 01:19:08 +00:00
|
|
|
.Va pfil_onlyip
|
|
|
|
is enabled.
|
2005-06-16 18:46:17 +00:00
|
|
|
IPFW can filter Ethernet types using
|
|
|
|
.Cm mac-type
|
|
|
|
so all packets are passed to
|
2005-06-07 21:20:18 +00:00
|
|
|
the filter for processing.
|
2005-06-05 02:59:26 +00:00
|
|
|
.Pp
|
2007-04-02 22:04:21 +00:00
|
|
|
The packets originating from the bridging host will be seen by
|
|
|
|
the filter on the interface that is looked up in the routing
|
|
|
|
table.
|
|
|
|
.Pp
|
|
|
|
The packets destined to the bridging host will be seen by the filter
|
|
|
|
on the interface with the MAC address equal to the packet's destination
|
|
|
|
MAC.
|
|
|
|
There are situations when some of the bridge members are sharing
|
|
|
|
the same MAC address (for example the
|
2007-04-03 14:36:18 +00:00
|
|
|
.Xr vlan 4
|
2010-07-31 12:14:28 +00:00
|
|
|
interfaces: they are currently sharing the
|
2007-04-02 22:04:21 +00:00
|
|
|
MAC address of the parent physical interface).
|
|
|
|
It is not possible to distinguish between these interfaces using
|
|
|
|
their MAC address, excluding the case when the packet's destination
|
|
|
|
MAC address is equal to the MAC address of the interface on which
|
|
|
|
the packet was entered to the system.
|
|
|
|
In this case the filter will see the incoming packet on this
|
|
|
|
interface.
|
|
|
|
In all other cases the interface seen by the packet filter is chosen
|
|
|
|
from the list of bridge members with the same MAC address and the
|
|
|
|
result strongly depends on the member addition sequence and the
|
|
|
|
actual implementation of
|
|
|
|
.Nm .
|
|
|
|
It is not recommended to rely on the order chosen by the current
|
|
|
|
.Nm
|
2019-10-05 09:59:00 +00:00
|
|
|
implementation since it may change in the future.
|
2007-04-02 22:04:21 +00:00
|
|
|
.Pp
|
|
|
|
The previous paragraph is best illustrated with the following
|
|
|
|
pictures.
|
|
|
|
Let
|
|
|
|
.Bl -bullet
|
|
|
|
.It
|
|
|
|
the MAC address of the incoming packet's destination is
|
|
|
|
.Nm nn:nn:nn:nn:nn:nn ,
|
|
|
|
.It
|
|
|
|
the interface on which packet entered the system is
|
|
|
|
.Nm ifX ,
|
|
|
|
.It
|
|
|
|
.Nm ifX
|
|
|
|
MAC address is
|
|
|
|
.Nm xx:xx:xx:xx:xx:xx ,
|
|
|
|
.It
|
|
|
|
there are possibly other bridge members with the same MAC address
|
|
|
|
.Nm xx:xx:xx:xx:xx:xx ,
|
|
|
|
.It
|
|
|
|
the bridge has more than one interface that are sharing the
|
|
|
|
same MAC address
|
|
|
|
.Nm yy:yy:yy:yy:yy:yy ;
|
|
|
|
we will call them
|
|
|
|
.Nm vlanY1 ,
|
|
|
|
.Nm vlanY2 ,
|
|
|
|
etc.
|
|
|
|
.El
|
|
|
|
.Pp
|
2019-10-05 09:59:00 +00:00
|
|
|
If the MAC address
|
2007-04-02 22:04:21 +00:00
|
|
|
.Nm nn:nn:nn:nn:nn:nn
|
2019-10-05 09:59:00 +00:00
|
|
|
is equal to
|
2007-04-02 22:04:21 +00:00
|
|
|
.Nm xx:xx:xx:xx:xx:xx
|
2019-10-05 09:59:00 +00:00
|
|
|
the filter will see the packet on interface
|
2007-04-02 22:04:21 +00:00
|
|
|
.Nm ifX
|
|
|
|
no matter if there are any other bridge members carrying the same
|
|
|
|
MAC address.
|
|
|
|
But if the MAC address
|
|
|
|
.Nm nn:nn:nn:nn:nn:nn
|
2019-10-05 09:59:00 +00:00
|
|
|
is equal to
|
2007-04-02 22:04:21 +00:00
|
|
|
.Nm yy:yy:yy:yy:yy:yy
|
|
|
|
then the interface that will be seen by the filter is one of the
|
|
|
|
.Nm vlanYn .
|
|
|
|
It is not possible to predict the name of the actual interface
|
|
|
|
without the knowledge of the system state and the
|
|
|
|
.Nm
|
|
|
|
implementation details.
|
|
|
|
.Pp
|
|
|
|
This problem arises for any bridge members that are sharing the same
|
|
|
|
MAC address, not only to the
|
2007-04-03 14:36:18 +00:00
|
|
|
.Xr vlan 4
|
2019-10-05 09:59:00 +00:00
|
|
|
ones: they were taken just as an example of such a situation.
|
|
|
|
So if one wants to filter the locally destined packets based on
|
2007-04-02 22:04:21 +00:00
|
|
|
their interface name, one should be aware of this implication.
|
|
|
|
The described situation will appear at least on the filtering bridges
|
|
|
|
that are doing IP-forwarding; in some of such cases it is better
|
|
|
|
to assign the IP address only to the
|
|
|
|
.Nm
|
|
|
|
interface and not to the bridge members.
|
2007-09-16 21:09:15 +00:00
|
|
|
Enabling
|
|
|
|
.Va net.link.bridge.pfil_local_phys
|
|
|
|
will let you do the additional filtering on the physical interface.
|
bridge: Add support for emulated netmap mode
if_bridge receives packets via a special interface, if_bridge_input,
rather than by if_input. Thus, netmap's usual hooking of ifnet routines
does not work as expected. Instead, modify bridge_input() to pass
packets directly to netmap when it is enabled. This applies to both
locally delivered packets and forwarded packets.
When a netmap application transmits a packet by writing it to the host
TX ring, the mbuf chain is passed to if_input, which ordinarily points
to ether_input(). However, when transmitting via if_bridge,
bridge_input() needs to see the packet again in order to decide whether
to deliver or forward. Thus, introduce a new protocol flag,
M_BRIDGE_INJECT, which 1) causes the packet to be passed to
bridge_input() again after Ethernet processing, and 2) avoids passing
the packet back to netmap. The source MAC address of the packet is used
to determine the original "receiving" interface.
Reviewed by: vmaffione
MFC after: 2 months
Sponsored by: Zenarmor
Sponsored by: OPNsense
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38066
2023-04-10 15:18:25 +00:00
|
|
|
.Sh NETMAP
|
|
|
|
.Xr netmap 4
|
|
|
|
applications may open a bridge interface in emulated mode.
|
|
|
|
The netmap application will receive all packets which arrive from member
|
|
|
|
interfaces.
|
|
|
|
In particular, packets which would otherwise be forwarded to another
|
|
|
|
member interface will be received by the netmap application.
|
|
|
|
.Pp
|
|
|
|
When the
|
|
|
|
.Xr netmap 4
|
|
|
|
application transmits a packet to the host stack via the bridge interface,
|
|
|
|
.Nm
|
|
|
|
receive it and attempts to determine its
|
|
|
|
.Ql source
|
|
|
|
interface by looking up the source MAC address in the interface's learning
|
|
|
|
tables.
|
|
|
|
Packets for which no matching source interface is found are dropped and the
|
|
|
|
input error counter is incremented.
|
|
|
|
If a matching source interface is found,
|
|
|
|
.Nm
|
|
|
|
treats the packet as though it was received from the corresponding interface
|
|
|
|
and handles it normally without passing the packet back to
|
|
|
|
.Xr netmap 4 .
|
2005-06-05 02:59:26 +00:00
|
|
|
.Sh EXAMPLES
|
2005-06-16 18:46:17 +00:00
|
|
|
The following when placed in the file
|
2005-06-05 02:59:26 +00:00
|
|
|
.Pa /etc/rc.conf
|
2005-06-16 18:46:17 +00:00
|
|
|
will cause a bridge called
|
|
|
|
.Dq Li bridge0
|
2005-06-05 02:59:26 +00:00
|
|
|
to be created, and will add the interfaces
|
2009-05-07 14:34:49 +00:00
|
|
|
.Dq Li wlan0
|
2005-06-05 02:59:26 +00:00
|
|
|
and
|
2005-06-16 18:46:17 +00:00
|
|
|
.Dq Li fxp0
|
2005-06-05 02:59:26 +00:00
|
|
|
to the bridge, and then enable packet forwarding.
|
|
|
|
Such a configuration could be used to implement a simple
|
|
|
|
802.11-to-Ethernet bridge (assuming the 802.11 interface is
|
|
|
|
in ad-hoc mode).
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
cloned_interfaces="bridge0"
|
2009-05-07 14:34:49 +00:00
|
|
|
ifconfig_bridge0="addm wlan0 addm fxp0 up"
|
2006-04-28 11:48:53 +00:00
|
|
|
.Ed
|
|
|
|
.Pp
|
2016-02-07 13:33:18 +00:00
|
|
|
For the bridge to forward packets,
|
|
|
|
all member interfaces and the bridge need to be up.
|
2006-04-28 11:48:53 +00:00
|
|
|
The above example would also require:
|
|
|
|
.Bd -literal -offset indent
|
2009-05-07 16:31:50 +00:00
|
|
|
create_args_wlan0="wlanmode hostap"
|
|
|
|
ifconfig_wlan0="up ssid my_ap mode 11g"
|
2006-04-28 11:48:53 +00:00
|
|
|
ifconfig_fxp0="up"
|
2005-06-05 02:59:26 +00:00
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
Consider a system with two 4-port Ethernet boards.
|
2007-01-20 02:39:34 +00:00
|
|
|
The following will cause a bridge consisting of all 8 ports with Rapid Spanning
|
|
|
|
Tree enabled to be created:
|
2005-06-05 02:59:26 +00:00
|
|
|
.Bd -literal -offset indent
|
2005-06-27 10:58:22 +00:00
|
|
|
ifconfig bridge0 create
|
2005-06-05 02:59:26 +00:00
|
|
|
ifconfig bridge0 \e
|
|
|
|
addm fxp0 stp fxp0 \e
|
|
|
|
addm fxp1 stp fxp1 \e
|
|
|
|
addm fxp2 stp fxp2 \e
|
|
|
|
addm fxp3 stp fxp3 \e
|
|
|
|
addm fxp4 stp fxp4 \e
|
|
|
|
addm fxp5 stp fxp5 \e
|
|
|
|
addm fxp6 stp fxp6 \e
|
|
|
|
addm fxp7 stp fxp7 \e
|
|
|
|
up
|
|
|
|
.Ed
|
2005-12-21 21:29:45 +00:00
|
|
|
.Pp
|
2006-10-08 19:41:05 +00:00
|
|
|
The bridge can be used as a regular host interface at the same time as bridging
|
2006-10-11 18:26:04 +00:00
|
|
|
between its member ports.
|
|
|
|
In this example, the bridge connects em0 and em1, and will receive its IP
|
2006-10-08 19:41:05 +00:00
|
|
|
address through DHCP:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
cloned_interfaces="bridge0"
|
|
|
|
ifconfig_bridge0="addm em0 addm em1 DHCP"
|
|
|
|
ifconfig_em0="up"
|
|
|
|
ifconfig_em1="up"
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2005-12-21 21:29:45 +00:00
|
|
|
The bridge can tunnel Ethernet across an IP internet using the EtherIP
|
|
|
|
protocol.
|
|
|
|
This can be combined with
|
|
|
|
.Xr ipsec 4
|
|
|
|
to provide an encrypted connection.
|
|
|
|
Create a
|
|
|
|
.Xr gif 4
|
|
|
|
interface and set the local and remote IP addresses for the
|
|
|
|
tunnel, these are reversed on the remote bridge.
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
ifconfig gif0 create
|
|
|
|
ifconfig gif0 tunnel 1.2.3.4 5.6.7.8 up
|
|
|
|
ifconfig bridge0 create
|
|
|
|
ifconfig bridge0 addm fxp0 addm gif0 up
|
|
|
|
.Ed
|
2005-06-05 02:59:26 +00:00
|
|
|
.Sh SEE ALSO
|
2005-12-21 21:29:45 +00:00
|
|
|
.Xr gif 4 ,
|
2005-09-06 22:38:40 +00:00
|
|
|
.Xr ipf 4 ,
|
2005-11-18 10:56:28 +00:00
|
|
|
.Xr ipfw 4 ,
|
bridge: Add support for emulated netmap mode
if_bridge receives packets via a special interface, if_bridge_input,
rather than by if_input. Thus, netmap's usual hooking of ifnet routines
does not work as expected. Instead, modify bridge_input() to pass
packets directly to netmap when it is enabled. This applies to both
locally delivered packets and forwarded packets.
When a netmap application transmits a packet by writing it to the host
TX ring, the mbuf chain is passed to if_input, which ordinarily points
to ether_input(). However, when transmitting via if_bridge,
bridge_input() needs to see the packet again in order to decide whether
to deliver or forward. Thus, introduce a new protocol flag,
M_BRIDGE_INJECT, which 1) causes the packet to be passed to
bridge_input() again after Ethernet processing, and 2) avoids passing
the packet back to netmap. The source MAC address of the packet is used
to determine the original "receiving" interface.
Reviewed by: vmaffione
MFC after: 2 months
Sponsored by: Zenarmor
Sponsored by: OPNsense
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38066
2023-04-10 15:18:25 +00:00
|
|
|
.Xr netmap 4 ,
|
2005-11-18 10:56:28 +00:00
|
|
|
.Xr pf 4 ,
|
|
|
|
.Xr ifconfig 8
|
2005-06-05 02:59:26 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
driver first appeared in
|
|
|
|
.Fx 6.0 .
|
|
|
|
.Sh AUTHORS
|
2006-05-20 10:19:53 +00:00
|
|
|
.An -nosplit
|
2005-06-05 02:59:26 +00:00
|
|
|
The
|
|
|
|
.Nm bridge
|
|
|
|
driver was originally written by
|
2014-06-26 21:46:14 +00:00
|
|
|
.An Jason L. Wright Aq Mt jason@thought.net
|
2005-06-05 02:59:26 +00:00
|
|
|
as part of an undergraduate independent study at the University of
|
|
|
|
North Carolina at Greensboro.
|
|
|
|
.Pp
|
|
|
|
This version of the
|
|
|
|
.Nm
|
|
|
|
driver has been heavily modified from the original version by
|
2014-06-26 21:46:14 +00:00
|
|
|
.An Jason R. Thorpe Aq Mt thorpej@wasabisystems.com .
|
2007-01-20 02:39:34 +00:00
|
|
|
.Pp
|
|
|
|
Rapid Spanning Tree Protocol (RSTP) support was added by
|
2014-06-26 21:46:14 +00:00
|
|
|
.An Andrew Thompson Aq Mt thompsa@FreeBSD.org .
|
2005-06-05 02:59:26 +00:00
|
|
|
.Sh BUGS
|
|
|
|
The
|
|
|
|
.Nm
|
2005-06-16 18:46:17 +00:00
|
|
|
driver currently supports only Ethernet and Ethernet-like (e.g., 802.11)
|
2022-09-15 06:26:49 +00:00
|
|
|
network devices, which can be configured with the same MTU size as the bridge
|
|
|
|
device.
|