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 March 1, 2011 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.It Dv NG_ONE2MANY_XMIT_FAILOVER 100Packets are delivered out the first active 101.Dv many 102hook. 103.El 104.Pp 105In the future other algorithms may be added as well. 106.Sh LINK FAILURE DETECTION 107The node distinguishes between active and failed links. 108Data is sent only to active links. 109The following link failure detection algorithms are available: 110.Bl -tag -width indent 111.It Dv NG_ONE2MANY_FAIL_MANUAL 112The node is explicitly told which of the links are up via the 113.Dv NGM_ONE2MANY_SET_CONFIG 114control message (see below). 115Newly connected links are down until configured otherwise. 116.It Dv NG_ONE2MANY_FAIL_NOTIFY 117The node listens to flow control message from 118.Va many 119hooks, and considers link failed if 120.Dv NGM_LINK_IS_DOWN 121is received. 122If the 123.Dv NGM_LINK_IS_UP 124message is received, node considers link active. 125.El 126.Pp 127In the future other algorithms may be added as well. 128.Pp 129When all links are considered failed, node sends the 130.Dv NGM_LINK_IS_DOWN 131message towards the 132.Va one 133hook. 134When at least one link comes up, node sends the 135.Dv NGM_LINK_IS_UP 136message towards the 137.Va one 138hook. 139.Sh HOOKS 140This node type supports up to 141.Dv NG_ONE2MANY_MAX_LINKS 142hooks named 143.Dv many0 , 144.Dv many1 , 145etc., 146plus a single hook named 147.Dv one . 148.Sh CONTROL MESSAGES 149This node type supports the generic control messages, plus the 150following: 151.Bl -tag -width foo 152.It Dv NGM_ONE2MANY_SET_CONFIG 153Sets the node configuration using a 154.Dv "struct ng_one2many_link_config" 155as the control message argument: 156.Bd -literal 157/* Node configuration structure */ 158struct ng_one2many_config { 159 uint32_t xmitAlg; /* how to distribute packets */ 160 uint32_t failAlg; /* how to detect link failure */ 161 u_char enabledLinks[NG_ONE2MANY_MAX_LINKS]; 162}; 163.Ed 164.Pp 165Currently, the valid settings for the 166.Dv xmitAlg 167field are 168.Dv NG_ONE2MANY_XMIT_ROUNDROBIN 169(default) or 170.Dv NG_ONE2MANY_XMIT_ALL . 171The valid settings for 172.Dv failAlg 173are 174.Dv NG_ONE2MANY_FAIL_MANUAL 175(default) or 176.Dv NG_ONE2MANY_FAIL_NOTIFY . 177.It Dv NGM_ONE2MANY_GET_CONFIG 178Returns the current node configuration in a 179.Dv "struct ng_one2many_link_config" . 180.It Dv NGM_ONE2MANY_GET_STATS 181This command takes a 32 bit link number as an argument and 182returns a 183.Dv "struct ng_one2many_link_stats" 184containing statistics for the corresponding 185.Dv many 186link, which may or may not be currently connected: 187.Bd -literal 188/* Statistics structure (one for each link) */ 189struct ng_one2many_link_stats { 190 uint64_t recvOctets; /* total octets rec'd on link */ 191 uint64_t recvPackets; /* total pkts rec'd on link */ 192 uint64_t xmitOctets; /* total octets xmit'd on link */ 193 uint64_t xmitPackets; /* total pkts xmit'd on link */ 194}; 195.Ed 196.Pp 197To access statistics for the 198.Dv one 199link, use the link number 200.Dv -1 . 201.It Dv NGM_ONE2MANY_CLR_STATS 202This command takes a 32 bit link number as an argument and 203clears the statistics for that link. 204.It Dv NGM_ONE2MANY_GETCLR_STATS 205Same as 206.Dv NGM_ONE2MANY_GET_STATS , 207but also atomically clears the statistics for the link as well. 208.El 209.Sh SHUTDOWN 210This node shuts down upon receipt of a 211.Dv NGM_SHUTDOWN 212control message, or when all hooks have been disconnected. 213.Sh EXAMPLES 214The following commands will set up Ethernet interfaces 215.Dv fxp0 216to deliver packets alternating over the physical interfaces 217corresponding to networking interfaces 218.Dv fxp0 219through 220.Dv fxp3 : 221.Bd -literal 222 # Plumb nodes together 223 224 ngctl mkpeer fxp0: one2many upper one 225 ngctl connect fxp0: fxp0:upper lower many0 226 ngctl connect fxp1: fxp0:upper lower many1 227 ngctl connect fxp2: fxp0:upper lower many2 228 ngctl connect fxp3: fxp0:upper lower many3 229 230 # Allow fxp1 through fxp3 to xmit/recv fxp0 frames 231 232 ngctl msg fxp1: setpromisc 1 233 ngctl msg fxp2: setpromisc 1 234 ngctl msg fxp3: setpromisc 1 235 ngctl msg fxp1: setautosrc 0 236 ngctl msg fxp2: setautosrc 0 237 ngctl msg fxp3: setautosrc 0 238 239 # Configure all four links as up 240 241 ngctl msg fxp0:upper \\ 242 setconfig "{ xmitAlg=1 failAlg=1 enabledLinks=[ 1 1 1 1 ] }" 243 244 # Bring up interface 245 246 ifconfig fxp0 192.168.1.1 netmask 0xfffffffc 247.Ed 248.Pp 249With a similar setup on a peer machine (using the address 250192.168.1.2), a point-to-point 251Ethernet connection with four times normal bandwidth is 252achieved. 253.Sh SEE ALSO 254.Xr netgraph 4 , 255.Xr ng_bridge 4 , 256.Xr ng_ether 4 , 257.Xr ng_hub 4 , 258.Xr ifconfig 8 , 259.Xr ngctl 8 260.Sh HISTORY 261The 262.Nm 263node type was implemented in 264.Fx 4.2 . 265.Sh AUTHORS 266.An -nosplit 267The 268.Nm one2many 269netgraph node (with round-robin algorithm) was written by 270.An Archie Cobbs 271.Aq archie@FreeBSD.org . 272The all algorithm was added by 273.An Rogier R. Mulhuijzen 274.Aq drwilco@drwilco.net . 275.Sh BUGS 276More transmit and link failure algorithms should be supported. 277A good candidate is Cisco's Etherchannel. 278