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