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 February 19, 2006 38.Dt NG_ONE2MANY 4 39.Os 40.Sh NAME 41.Nm ng_one2many 42.Nd packet multiplexing netgraph node type 43.Sh SYNOPSIS 44.In sys/types.h 45.In netgraph/ng_one2many.h 46.Sh DESCRIPTION 47The 48.Nm one2many 49provides a simple mechanism for routing packets over several links 50in a one-to-many (and in the reverse direction, many-to-one) fashion. 51There is a single hook named 52.Dv one , 53and multiple hooks named 54.Dv many0 , 55.Dv many1 , 56etc. 57Packets received on any of the 58.Dv many 59hooks are forwarded out the 60.Dv one 61hook. 62Packets received on the 63.Dv one 64hook are forwarded out one or more of the 65.Dv many 66hooks; which hook(s) is determined by the node's configured 67transmit algorithm. 68Packets are not altered in any way. 69.Pp 70Each of the connected many links may be considered to be up or down. 71Packets are never delivered out a many hook that is down. 72How a link is determined to be up or down depends on the node's 73configured link failure detection algorithm. 74.Pp 75Before an interface or link can be plumbed into a group, its status 76must be marked as being 77.Dq up . 78This is normally setup during the initial boot stages by 79.Xr rc.conf 5 . 80It is also possible to change an interface's status to 81.Dq up 82by using the 83.Xr ifconfig 8 84utility. 85.Sh TRANSMIT ALGORITHMS 86.Bl -tag -width foo 87.It Dv NG_ONE2MANY_XMIT_ROUNDROBIN 88Packets are delivered out the many hooks in sequential order. 89Each packet goes out on a different 90.Dv many 91hook. 92.It Dv NG_ONE2MANY_XMIT_ALL 93Packets are delivered out all the 94.Dv many 95hooks. 96Each packet goes out each 97.Dv many 98hook. 99.El 100.Pp 101In the future other algorithms may be added as well. 102.Sh LINK FAILURE DETECTION 103The node distinguishes between active and failed links. 104Data is sent only to active links. 105The following link failure detection algorithms are available: 106.Bl -tag -width indent 107.It Dv NG_ONE2MANY_FAIL_MANUAL 108The node is explicitly told which of the links are up via the 109.Dv NGM_ONE2MANY_SET_CONFIG 110control message (see below). 111Newly connected links are down until configured otherwise. 112.It Dv NG_ONE2MANY_FAIL_NOTIFY 113The node listens to flow control message from 114.Va many 115hooks, and considers link failed if 116.Dv NGM_LINK_IS_DOWN 117is received. 118If the 119.Dv NGM_LINK_IS_UP 120message is received, node considers link active. 121.El 122.Pp 123In the future other algorithms may be added as well. 124.Pp 125When all links are considered failed, node sends the 126.Dv NGM_LINK_IS_DOWN 127message towards the 128.Va one 129hook. 130When at least one link comes up, node sends the 131.Dv NGM_LINK_IS_UP 132message towards the 133.Va one 134hook. 135.Sh HOOKS 136This node type supports up to 137.Dv NG_ONE2MANY_MAX_LINKS 138hooks named 139.Dv many0 , 140.Dv many1 , 141etc., 142plus a single hook named 143.Dv one . 144.Sh CONTROL MESSAGES 145This node type supports the generic control messages, plus the 146following: 147.Bl -tag -width foo 148.It Dv NGM_ONE2MANY_SET_CONFIG 149Sets the node configuration using a 150.Dv "struct ng_one2many_link_config" 151as the control message argument: 152.Bd -literal 153/* Node configuration structure */ 154struct ng_one2many_config { 155 u_int32_t xmitAlg; /* how to distribute packets */ 156 u_int32_t failAlg; /* how to detect link failure */ 157 u_char enabledLinks[NG_ONE2MANY_MAX_LINKS]; 158}; 159.Ed 160.Pp 161Currently, the valid settings for the 162.Dv xmitAlg 163field are 164.Dv NG_ONE2MANY_XMIT_ROUNDROBIN 165(default) or 166.Dv NG_ONE2MANY_XMIT_ALL . 167The valid settings for 168.Dv failAlg 169are 170.Dv NG_ONE2MANY_FAIL_MANUAL 171(default) or 172.Dv NG_ONE2MANY_FAIL_NOTIFY . 173.It Dv NGM_ONE2MANY_GET_CONFIG 174Returns the current node configuration in a 175.Dv "struct ng_one2many_link_config" . 176.It Dv NGM_ONE2MANY_GET_STATS 177This command takes a 32 bit link number as an argument and 178returns a 179.Dv "struct ng_one2many_link_stats" 180containing statistics for the corresponding 181.Dv many 182link, which may or may not be currently connected: 183.Bd -literal 184/* Statistics structure (one for each link) */ 185struct ng_one2many_link_stats { 186 u_int64_t recvOctets; /* total octets rec'd on link */ 187 u_int64_t recvPackets; /* total pkts rec'd on link */ 188 u_int64_t xmitOctets; /* total octets xmit'd on link */ 189 u_int64_t xmitPackets; /* total pkts xmit'd on link */ 190}; 191.Ed 192.Pp 193To access statistics for the 194.Dv one 195link, use the link number 196.Dv -1 . 197.It Dv NGM_ONE2MANY_CLR_STATS 198This command takes a 32 bit link number as an argument and 199clears the statistics for that link. 200.It Dv NGM_ONE2MANY_GETCLR_STATS 201Same as 202.Dv NGM_ONE2MANY_GET_STATS , 203but also atomically clears the statistics for the link as well. 204.El 205.Sh SHUTDOWN 206This node shuts down upon receipt of a 207.Dv NGM_SHUTDOWN 208control message, or when all hooks have been disconnected. 209.Sh EXAMPLES 210The following commands will set up Ethernet interfaces 211.Dv fxp0 212to deliver packets alternating over the physical interfaces 213corresponding to networking interfaces 214.Dv fxp0 215through 216.Dv fxp3 : 217.Bd -literal 218 # Plumb nodes together 219 220 ngctl mkpeer fxp0: one2many upper one 221 ngctl connect fxp0: fxp0:upper lower many0 222 ngctl connect fxp1: fxp0:upper lower many1 223 ngctl connect fxp2: fxp0:upper lower many2 224 ngctl connect fxp3: fxp0:upper lower many3 225 226 # Allow fxp1 through fxp3 to xmit/recv fxp0 frames 227 228 ngctl msg fxp1: setpromisc 1 229 ngctl msg fxp2: setpromisc 1 230 ngctl msg fxp3: setpromisc 1 231 ngctl msg fxp1: setautosrc 0 232 ngctl msg fxp2: setautosrc 0 233 ngctl msg fxp3: setautosrc 0 234 235 # Configure all four links as up 236 237 ngctl msg fxp0:upper \\ 238 setconfig "{ xmitAlg=1 failAlg=1 enabledLinks=[ 1 1 1 1 ] }" 239 240 # Bring up interface 241 242 ifconfig fxp0 192.168.1.1 netmask 0xfffffffc 243.Ed 244.Pp 245With a similar setup on a peer machine (using the address 246192.168.1.2), a point-to-point 247Ethernet connection with four times normal bandwidth is 248achieved. 249.Sh SEE ALSO 250.Xr netgraph 4 , 251.Xr ng_bridge 4 , 252.Xr ng_ether 4 , 253.Xr ng_hub 4 , 254.Xr ifconfig 8 , 255.Xr ngctl 8 256.Sh HISTORY 257The 258.Nm 259node type was implemented in 260.Fx 4.2 . 261.Sh AUTHORS 262.An -nosplit 263The 264.Nm one2many 265netgraph node (with round-robin algorithm) was written by 266.An Archie Cobbs 267.Aq archie@FreeBSD.org . 268The all algorithm was added by 269.An Rogier R. Mulhuijzen 270.Aq drwilco@drwilco.net . 271.Sh BUGS 272More transmit and link failure algorithms should be supported. 273A good candidate is Cisco's Etherchannel. 274