1aebf2d1dSArchie Cobbs.\" Copyright (c) 2000 Whistle Communications, Inc. 2aebf2d1dSArchie Cobbs.\" All rights reserved. 3aebf2d1dSArchie Cobbs.\" 4aebf2d1dSArchie Cobbs.\" Subject to the following obligations and disclaimer of warranty, use and 5aebf2d1dSArchie Cobbs.\" redistribution of this software, in source or object code forms, with or 6aebf2d1dSArchie Cobbs.\" without modifications are expressly permitted by Whistle Communications; 7aebf2d1dSArchie Cobbs.\" provided, however, that: 8aebf2d1dSArchie Cobbs.\" 1. Any and all reproductions of the source or object code must include the 9aebf2d1dSArchie Cobbs.\" copyright notice above and the following disclaimer of warranties; and 10aebf2d1dSArchie Cobbs.\" 2. No rights are granted, in any manner or form, to use Whistle 11aebf2d1dSArchie Cobbs.\" Communications, Inc. trademarks, including the mark "WHISTLE 12aebf2d1dSArchie Cobbs.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as 13aebf2d1dSArchie Cobbs.\" such appears in the above copyright notice or in the software. 14aebf2d1dSArchie Cobbs.\" 15aebf2d1dSArchie Cobbs.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND 16aebf2d1dSArchie Cobbs.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO 17aebf2d1dSArchie Cobbs.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, 18aebf2d1dSArchie Cobbs.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF 19aebf2d1dSArchie Cobbs.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 20aebf2d1dSArchie Cobbs.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY 21aebf2d1dSArchie Cobbs.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS 22aebf2d1dSArchie Cobbs.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. 23aebf2d1dSArchie Cobbs.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES 24aebf2d1dSArchie Cobbs.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 25aebf2d1dSArchie Cobbs.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 26aebf2d1dSArchie Cobbs.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 27aebf2d1dSArchie Cobbs.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 28aebf2d1dSArchie Cobbs.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29aebf2d1dSArchie Cobbs.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30aebf2d1dSArchie Cobbs.\" THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 31aebf2d1dSArchie Cobbs.\" OF SUCH DAMAGE. 32aebf2d1dSArchie Cobbs.\" 33aebf2d1dSArchie Cobbs.\" Author: Archie Cobbs <archie@freebsd.org> 34aebf2d1dSArchie Cobbs.\" 35aebf2d1dSArchie Cobbs.\" $FreeBSD$ 36aebf2d1dSArchie Cobbs.\" 37aebf2d1dSArchie Cobbs.Dd August 31, 2000 38aebf2d1dSArchie Cobbs.Dt NG_BRIDGE 4 39aebf2d1dSArchie Cobbs.Os FreeBSD 40aebf2d1dSArchie Cobbs.Sh NAME 41aebf2d1dSArchie Cobbs.Nm ng_bridge 42aebf2d1dSArchie Cobbs.Nd Ethernet bridging netgraph node type 43aebf2d1dSArchie Cobbs.Sh SYNOPSIS 44aebf2d1dSArchie Cobbs.Fd #include <netgraph/ng_bridge.h> 45aebf2d1dSArchie Cobbs.Sh DESCRIPTION 46aebf2d1dSArchie CobbsThe 47aebf2d1dSArchie Cobbs.Nm bridge 48aebf2d1dSArchie Cobbsnode type performs Ethernet bridging over one or more links. 49aebf2d1dSArchie CobbsEach link (represented by a connected hook) is used to transmit 50aebf2d1dSArchie Cobbsand receive raw Ethernet frames. 51aebf2d1dSArchie CobbsAs packets are received, the node learns which link each 52aebf2d1dSArchie Cobbshost resides on. 53aebf2d1dSArchie CobbsPackets unicast to a known host are directed out the appropriate 54aebf2d1dSArchie Cobbslink only, and other links are spared the traffic. 55aebf2d1dSArchie CobbsThis behavior is in contrast to a hub, which always forwards 56aebf2d1dSArchie Cobbsevery received packet to every other link. 57aebf2d1dSArchie Cobbs.Sh LOOP DETECTION 58aebf2d1dSArchie CobbsThe 59aebf2d1dSArchie Cobbs.Nm bridge 60aebf2d1dSArchie Cobbsnode incorporates a simple loop detection algorithm. 61aebf2d1dSArchie CobbsA loop is when two ports are connected to the same physical medium. 62aebf2d1dSArchie CobbsLoops are important to avoid because of packet storms, which severely 63aebf2d1dSArchie Cobbsdegrade performance. 64aebf2d1dSArchie CobbsA packet storm results when the same packet is sent and received 65aebf2d1dSArchie Cobbsover and over again. 66aebf2d1dSArchie CobbsIf a host is detected on link A, and is then detected on link B 67aebf2d1dSArchie Cobbswithin a certain time period after first being detected on link A, 68aebf2d1dSArchie Cobbsthen link B is considered to be a looped back link. 69aebf2d1dSArchie CobbsThe time period is called the minimum stable time. 70aebf2d1dSArchie Cobbs.Pp 71aebf2d1dSArchie CobbsA looped back link will be temporarily muted, i.e., all traffic 72aebf2d1dSArchie Cobbsreceived on that link is ignored. 73aebf2d1dSArchie Cobbs.Sh IPFW PROCESSING 74aebf2d1dSArchie CobbsProcessing of IP packets via the 75aebf2d1dSArchie Cobbs.Xr ipfirewall 4 76aebf2d1dSArchie Cobbsmechanism on a per-link basis is not yet implemented. 77aebf2d1dSArchie Cobbs.Sh HOOKS 78aebf2d1dSArchie CobbsThis node type supports up to 79aebf2d1dSArchie Cobbs.Dv NG_BRIDGE_MAX_LINKS 80aebf2d1dSArchie Cobbshooks. 81aebf2d1dSArchie CobbsEach connected hook represents a bridged link. 82aebf2d1dSArchie CobbsThe hooks are named 83aebf2d1dSArchie Cobbs.Dv link0 , 84aebf2d1dSArchie Cobbs.Dv link1 , 85aebf2d1dSArchie Cobbsetc. 86aebf2d1dSArchie CobbsTypically these hooks are connected to the 87aebf2d1dSArchie Cobbs.Dv lower 88aebf2d1dSArchie Cobbshooks of one or more 89aebf2d1dSArchie Cobbs.Xr ng_ether 90aebf2d1dSArchie Cobbsnodes. 91aebf2d1dSArchie CobbsTo connect the host machine to a bridged network, simply connect the 92aebf2d1dSArchie Cobbs.Dv upper 93aebf2d1dSArchie Cobbshook of an 94aebf2d1dSArchie Cobbs.Xr ng_ether 95aebf2d1dSArchie Cobbsnode to the bridge node. 96aebf2d1dSArchie Cobbs.Sh CONTROL MESSAGES 97aebf2d1dSArchie CobbsThis node type supports the generic control messages, plus the 98aebf2d1dSArchie Cobbsfollowing: 99aebf2d1dSArchie Cobbs.Bl -tag -width foo 100aebf2d1dSArchie Cobbs.It Dv NGM_BRIDGE_SET_CONFIG 101aebf2d1dSArchie CobbsSet the node configuration. 102aebf2d1dSArchie CobbsThis command takes a 103aebf2d1dSArchie Cobbs.Dv "struct ng_bridge_config" 104aebf2d1dSArchie Cobbsas an argument: 105aebf2d1dSArchie Cobbs.Bd -literal -offset 0 106aebf2d1dSArchie Cobbs/* Node configuration structure */ 107aebf2d1dSArchie Cobbsstruct ng_bridge_config { 108aebf2d1dSArchie Cobbs u_char ipfw[NG_BRIDGE_MAX_LINKS]; /* enable ipfw */ 109aebf2d1dSArchie Cobbs u_char debugLevel; /* debug level */ 110aebf2d1dSArchie Cobbs u_int32_t loopTimeout; /* link loopback mute time */ 111aebf2d1dSArchie Cobbs u_int32_t maxStaleness; /* max host age before nuking */ 112aebf2d1dSArchie Cobbs u_int32_t minStableAge; /* min time for a stable host */ 113aebf2d1dSArchie Cobbs}; 114aebf2d1dSArchie Cobbs.Ed 115aebf2d1dSArchie Cobbs.Pp 116aebf2d1dSArchie CobbsThe 117aebf2d1dSArchie Cobbs.Dv ipfw 118aebf2d1dSArchie Cobbsarray enables 119aebf2d1dSArchie Cobbs.Xr ipfirewall 4 120aebf2d1dSArchie Cobbsprocessing of IP packets received on the corresponding links. 121aebf2d1dSArchie CobbsThe 122aebf2d1dSArchie Cobbs.Dv debugLevel 123aebf2d1dSArchie Cobbsfield sets the debug level on the node. 124aebf2d1dSArchie CobbsAt level of 2 or greater, detected loops are logged. 125aebf2d1dSArchie CobbsThe default level is 1. 126aebf2d1dSArchie Cobbs.Pp 127aebf2d1dSArchie CobbsThe 128aebf2d1dSArchie Cobbs.Dv loopTimeout 129aebf2d1dSArchie Cobbsdetermines how long (in seconds) a looped link is muted. 130aebf2d1dSArchie CobbsThe default is 60 seconds. 131aebf2d1dSArchie CobbsThe 132aebf2d1dSArchie Cobbs.Dv maxStaleness 133aebf2d1dSArchie Cobbsparameter determines how long a period of inactivity before 134aebf2d1dSArchie Cobbsa host's entry is forgotten. 135aebf2d1dSArchie CobbsThe default is 15 minutes. 136aebf2d1dSArchie CobbsThe 137aebf2d1dSArchie Cobbs.Dv minStableAge 138aebf2d1dSArchie Cobbsdetermines how quickly a host must jump from one link to another 139aebf2d1dSArchie Cobbsbefore we declare a loopback condition. 140aebf2d1dSArchie CobbsThe default is one second. 141aebf2d1dSArchie Cobbs.Pp 142aebf2d1dSArchie Cobbs.It Dv NGM_BRIDGE_GET_CONFIG 143aebf2d1dSArchie CobbsReturns the current configuration as a 144aebf2d1dSArchie Cobbs.Dv "struct ng_bridge_config" . 145aebf2d1dSArchie Cobbs.It Dv NGM_BRIDGE_RESET 146aebf2d1dSArchie CobbsCauses the node to forget all hosts and unmute all links. 147aebf2d1dSArchie CobbsThe node configuration is not changed. 148aebf2d1dSArchie Cobbs.It Dv NGM_BRIDGE_GET_STATS 149aebf2d1dSArchie CobbsThis command takes a four byte link number as an argument and 150aebf2d1dSArchie Cobbsreturns a 151aebf2d1dSArchie Cobbs.Dv "struct ng_bridge_link_stats" 152aebf2d1dSArchie Cobbscontaining statistics for the corresponding link, which must be 153aebf2d1dSArchie Cobbscurrently connected: 154aebf2d1dSArchie Cobbs.Bd -literal -offset 0 155aebf2d1dSArchie Cobbs/* Statistics structure (one for each link) */ 156aebf2d1dSArchie Cobbsstruct ng_bridge_link_stats { 157aebf2d1dSArchie Cobbs u_int64_t recvOctets; /* total octets rec'd on link */ 158aebf2d1dSArchie Cobbs u_int64_t recvPackets; /* total pkts rec'd on link */ 159aebf2d1dSArchie Cobbs u_int64_t recvMulticasts; /* multicast pkts rec'd on link */ 160aebf2d1dSArchie Cobbs u_int64_t recvBroadcasts; /* broadcast pkts rec'd on link */ 161aebf2d1dSArchie Cobbs u_int64_t recvUnknown; /* pkts rec'd with unknown dest addr */ 162aebf2d1dSArchie Cobbs u_int64_t recvRunts; /* pkts rec'd less than 14 bytes */ 163aebf2d1dSArchie Cobbs u_int64_t recvInvalid; /* pkts rec'd with bogus source addr */ 164aebf2d1dSArchie Cobbs u_int64_t xmitOctets; /* total octets xmit'd on link */ 165aebf2d1dSArchie Cobbs u_int64_t xmitPackets; /* total pkts xmit'd on link */ 166aebf2d1dSArchie Cobbs u_int64_t xmitMulticasts; /* multicast pkts xmit'd on link */ 167aebf2d1dSArchie Cobbs u_int64_t xmitBroadcasts; /* broadcast pkts xmit'd on link */ 168aebf2d1dSArchie Cobbs u_int64_t loopDrops; /* pkts dropped due to loopback */ 169aebf2d1dSArchie Cobbs u_int64_t loopDetects; /* number of loop detections */ 170aebf2d1dSArchie Cobbs u_int64_t memoryFailures; /* times couldn't get mem or mbuf */ 171aebf2d1dSArchie Cobbs}; 172aebf2d1dSArchie Cobbs.Ed 173aebf2d1dSArchie Cobbs.It Dv NGM_BRIDGE_CLR_STATS 174aebf2d1dSArchie CobbsThis command takes a four byte link number as an argument and 175aebf2d1dSArchie Cobbsclears the statistics for that link. 176aebf2d1dSArchie Cobbs.It Dv NGM_BRIDGE_GETCLR_STATS 177aebf2d1dSArchie CobbsSame as 178aebf2d1dSArchie Cobbs.Dv NGM_BRIDGE_GET_STATS , 179aebf2d1dSArchie Cobbsbut also atomically clears the statistics as well. 180aebf2d1dSArchie Cobbs.It Dv NGM_BRIDGE_GET_TABLE 181aebf2d1dSArchie CobbsReturns the current host mapping table used to direct packets, in a 182aebf2d1dSArchie Cobbs.Dv "struct ng_bridge_host_ary" . 183aebf2d1dSArchie Cobbs.El 184aebf2d1dSArchie Cobbs.Sh SHUTDOWN 185aebf2d1dSArchie CobbsThis node shuts down upon receipt of a 186aebf2d1dSArchie Cobbs.Dv NGM_SHUTDOWN 187aebf2d1dSArchie Cobbscontrol message, or when all hooks have been disconnected. 188aebf2d1dSArchie Cobbs.Sh SEE ALSO 189aebf2d1dSArchie Cobbs.Xr bridge 4 , 190aebf2d1dSArchie Cobbs.Xr netgraph 4 , 191aebf2d1dSArchie Cobbs.Xr ng_ether 4 , 192aebf2d1dSArchie Cobbs.Xr ngctl 8 193aebf2d1dSArchie Cobbs.Sh HISTORY 194aebf2d1dSArchie CobbsThe 195aebf2d1dSArchie Cobbs.Nm 196aebf2d1dSArchie Cobbsnode type was implemented in 197aebf2d1dSArchie Cobbs.Fx 4.2 . 198aebf2d1dSArchie Cobbs.Sh AUTHORS 199aebf2d1dSArchie Cobbs.An Archie Cobbs Aq archie@freebsd.org 200