]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/ng_bridge.4
Remove "all rights reserved" from copyright for the file I own.
[FreeBSD/FreeBSD.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$
36 .\"
37 .Dd October 2, 2019
38 .Dt NG_BRIDGE 4
39 .Os
40 .Sh NAME
41 .Nm ng_bridge
42 .Nd Ethernet bridging netgraph node type
43 .Sh SYNOPSIS
44 .In sys/types.h
45 .In netgraph/ng_bridge.h
46 .Sh DESCRIPTION
47 The
48 .Nm bridge
49 node type performs Ethernet bridging over one or more links.
50 Each link (represented by a connected hook) is used to transmit
51 and receive raw Ethernet frames.
52 As packets are received, the node learns which link each
53 host resides on.
54 Packets unicast to a known host are directed out the appropriate
55 link only, and other links are spared the traffic.
56 This behavior is in contrast to a hub, which always forwards
57 every received packet to every other link.
58 .Sh LOOP DETECTION
59 The
60 .Nm bridge
61 node incorporates a simple loop detection algorithm.
62 A loop is when two ports are connected to the same physical medium.
63 Loops are important to avoid because of packet storms, which severely
64 degrade performance.
65 A packet storm results when the same packet is sent and received
66 over and over again.
67 If a host is detected on link A, and is then detected on link B
68 within a certain time period after first being detected on link A,
69 then link B is considered to be a looped back link.
70 The time period is called the minimum stable time.
71 .Pp
72 A looped back link will be temporarily muted, i.e., all traffic
73 received on that link is ignored.
74 .Sh IPFW PROCESSING
75 Processing of IP packets via the
76 .Xr ipfirewall 4
77 mechanism on a per-link basis is not yet implemented.
78 .Sh HOOKS
79 This node type supports an unlimited number of hooks.
80 Each connected hook represents a bridged link.
81 The hooks are named
82 .Dv link0 ,
83 .Dv link1 ,
84 etc.
85 Typically these hooks are connected to the
86 .Dv lower
87 hooks of one or more
88 .Xr ng_ether 4
89 nodes.
90 To connect the host machine to a bridged network, simply connect the
91 .Dv upper
92 hook of an
93 .Xr ng_ether 4
94 node to the bridge node.
95 .Sh CONTROL MESSAGES
96 This node type supports the generic control messages, plus the
97 following:
98 .Bl -tag -width foo
99 .It Dv NGM_BRIDGE_SET_CONFIG Pq Ic setconfig
100 Set the node configuration.
101 This command takes a
102 .Dv "struct ng_bridge_config"
103 as an argument:
104 .Bd -literal -offset 0n
105 /* Node configuration structure */
106 struct ng_bridge_config {
107   u_char      debugLevel;           /* debug level */
108   uint32_t    loopTimeout;          /* link loopback mute time */
109   uint32_t    maxStaleness;         /* max host age before nuking */
110   uint32_t    minStableAge;         /* min time for a stable host */
111 };
112 .Ed
113 .Pp
114 The
115 .Dv debugLevel
116 field sets the debug level on the node.
117 At level of 2 or greater, detected loops are logged.
118 The default level is 1.
119 .Pp
120 The
121 .Dv loopTimeout
122 determines how long (in seconds) a looped link is muted.
123 The default is 60 seconds.
124 The
125 .Dv maxStaleness
126 parameter determines how long a period of inactivity before
127 a host's entry is forgotten.
128 The default is 15 minutes.
129 The
130 .Dv minStableAge
131 determines how quickly a host must jump from one link to another
132 before we declare a loopback condition.
133 The default is one second.
134 .It Dv NGM_BRIDGE_GET_CONFIG Pq Ic getconfig
135 Returns the current configuration as a
136 .Dv "struct ng_bridge_config" .
137 .It Dv NGM_BRIDGE_RESET Pq Ic reset
138 Causes the node to forget all hosts and unmute all links.
139 The node configuration is not changed.
140 .It Dv NGM_BRIDGE_GET_STATS Pq Ic getstats
141 This command takes a four byte link number as an argument and
142 returns a
143 .Dv "struct ng_bridge_link_stats"
144 containing statistics for the corresponding link, which must be
145 currently connected:
146 .Bd -literal -offset 0n
147 /* Statistics structure (one for each link) */
148 struct ng_bridge_link_stats {
149   uint64_t   recvOctets;     /* total octets rec'd on link */
150   uint64_t   recvPackets;    /* total pkts rec'd on link */
151   uint64_t   recvMulticasts; /* multicast pkts rec'd on link */
152   uint64_t   recvBroadcasts; /* broadcast pkts rec'd on link */
153   uint64_t   recvUnknown;    /* pkts rec'd with unknown dest addr */
154   uint64_t   recvRunts;      /* pkts rec'd less than 14 bytes */
155   uint64_t   recvInvalid;    /* pkts rec'd with bogus source addr */
156   uint64_t   xmitOctets;     /* total octets xmit'd on link */
157   uint64_t   xmitPackets;    /* total pkts xmit'd on link */
158   uint64_t   xmitMulticasts; /* multicast pkts xmit'd on link */
159   uint64_t   xmitBroadcasts; /* broadcast pkts xmit'd on link */
160   uint64_t   loopDrops;      /* pkts dropped due to loopback */
161   uint64_t   loopDetects;    /* number of loop detections */
162   uint64_t   memoryFailures; /* times couldn't get mem or mbuf */
163 };
164 .Ed
165 .It Dv NGM_BRIDGE_CLR_STATS Pq Ic clrstats
166 This command takes a four byte link number as an argument and
167 clears the statistics for that link.
168 .It Dv NGM_BRIDGE_GETCLR_STATS Pq Ic getclrstats
169 Same as
170 .Dv NGM_BRIDGE_GET_STATS ,
171 but also atomically clears the statistics as well.
172 .It Dv NGM_BRIDGE_GET_TABLE Pq Ic gettable
173 Returns the current host mapping table used to direct packets, in a
174 .Dv "struct ng_bridge_host_ary" .
175 .It Dv NGM_BRIDGE_SET_PERSISTENT Pq Ic setpersistent
176 This command sets the persistent flag on the node, and takes no arguments.
177 .El
178 .Sh SHUTDOWN
179 This node shuts down upon receipt of a
180 .Dv NGM_SHUTDOWN
181 control message, or when all hooks have been disconnected.
182 Setting the persistent flag via a
183 .Dv NGM_BRIDGE_SET_PERSISTENT
184 control message disables automatic node shutdown when the last hook gets
185 disconnected.
186 .Sh FILES
187 .Bl -tag -width XXXXXXXX -compact
188 .It Pa /usr/share/examples/netgraph/ether.bridge
189 Example script showing how to set up a bridging network
190 .El
191 .Sh SEE ALSO
192 .Xr if_bridge 4 ,
193 .Xr netgraph 4 ,
194 .Xr ng_ether 4 ,
195 .Xr ng_hub 4 ,
196 .Xr ng_one2many 4 ,
197 .Xr ngctl 8
198 .Sh HISTORY
199 The
200 .Nm
201 node type was implemented in
202 .Fx 4.2 .
203 .Sh AUTHORS
204 .An Archie Cobbs Aq Mt archie@FreeBSD.org