NG_ONE2MANY(4)
π NG_ONE2MANY(4) β packet multiplexing netgraph node type β¨
Okay bestie, gather round, because this is the ng_one2many manual page and it's literally the icon of one-to-many packet routing. You're gonna slay this, no cap.
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <netgraph/ng_one2many.h>
πΈ DESCRIPTION πΈ
The one2many node type is giving simple mechanism for routing packets over several links in a one-to-many (and in the reverse direction, many-to-one) fashion. Periodt.
There's a single hook named one, and multiple hooks named many0, many1, etc. Packets received on any of the many hooks are forwarded out the one hook. Packets received on the one hook are forwarded out one or more of the many hooks β which hook(s) is determined by the node's configured transmit algorithm. Packets are not altered in any way. π
Each of the connected many links may be considered to be up or down. Packets are never delivered out a many hook that is down. How a link is determined to be up or down depends on the node's configured link failure detection algorithm.
Before an interface or link can be plumbed into a group, its status must be marked as being "up". This is normally setup during the initial boot stages byrc.conf(5). It's also possible to change an interface's status to "up" by using theifconfig(8)utility. π«Ά
π₯ TRANSMIT ALGORITHMS π₯
NG_ONE2MANY_XMIT_ROUNDROBINβ Packets are delivered out themanyhooks in sequential order. Each packet goes out on a differentmanyhook. Iconic behavior.NG_ONE2MANY_XMIT_ALLβ Packets are delivered out all themanyhooks. Each packet goes out eachmanyhook. It's giving "everyone gets a copy." πNG_ONE2MANY_XMIT_FAILOVERβ Packets are delivered out the first activemanyhook.
In the future other algorithms may be added as well. π
π¦ LINK FAILURE DETECTION π¦
The node distinguishes between active and failed links. Data is sent only to active links. The following link failure detection algorithms are available:
NG_ONE2MANY_FAIL_MANUALβ The node is explicitly told which of the links are up via theNGM_ONE2MANY_SET_CONFIGcontrol message (see below). Newly connected links are down until configured otherwise. No assumptions, bestie.NG_ONE2MANY_FAIL_NOTIFYβ The node listens to flow control message frommanyhooks, and considers link failed ifNGM_LINK_IS_DOWNis received. If theNGM_LINK_IS_UPmessage is received, node considers link active.
In the future other algorithms may be added as well. β¨
When all links are considered failed, node sends the NGM_LINK_IS_DOWN message towards the one hook. When at least one link comes up, node sends the NGM_LINK_IS_UP message towards the one hook. Vibe check passed.
π HOOKS π
This node type supports up to NG_ONE2MANY_MAX_LINKS hooks named many0, many1, etc., plus a single hook named one. That's the whole squad.
π CONTROL MESSAGES π
This node type supports the generic control messages, plus the following:
NGM_ONE2MANY_SET_CONFIG(setconfig) β Sets the node configuration using astruct ng_one2many_link_configas the control message argument:
/* Node configuration structure */
struct ng_one2many_config {
uint32_t xmitAlg; /* how to distribute packets */
uint32_t failAlg; /* how to detect link failure */
u_char enabledLinks[NG_ONE2MANY_MAX_LINKS];
};
Currently, the valid settings for the xmitAlg field are NG_ONE2MANY_XMIT_ROUNDROBIN (default) or NG_ONE2MANY_XMIT_ALL. The valid settings for failAlg are NG_ONE2MANY_FAIL_MANUAL (default) or NG_ONE2MANY_FAIL_NOTIFY. Defaults are cute like that.
NGM_ONE2MANY_GET_CONFIG(getconfig) β Returns the current node configuration in astruct ng_one2many_link_config.NGM_ONE2MANY_GET_STATS(getstats) β This command takes a 32 bit link number as an argument and returns astruct ng_one2many_link_statscontaining statistics for the correspondingmanylink, which may or may not be currently connected:
/* Statistics structure (one for each link) */
struct ng_one2many_link_stats {
uint64_t recvOctets; /* total octets rec'd on link */
uint64_t recvPackets; /* total pkts rec'd on link */
uint64_t xmitOctets; /* total octets xmit'd on link */
uint64_t xmitPackets; /* total pkts xmit'd on link */
uint64_t memoryFailures; /* times couldn't get mem or mbuf */
};
To access statistics for theonelink, use the link number-1. Yes, negative one. She's special.
NGM_ONE2MANY_CLR_STATS(clrstats) β This command takes a 32 bit link number as an argument and clears the statistics for that link. Poof, gone.NGM_ONE2MANY_GETCLR_STATS(getclrstats) β Same asNGM_ONE2MANY_GET_STATS, but also atomically clears the statistics for the link as well. Two birds, one control message.
π SHUTDOWN π
This node shuts down upon receipt of a NGM_SHUTDOWN control message, or when all hooks have been disconnected. Bye bestie. π
π EXAMPLES π
The following commands will set up Ethernet interfaces fxp0 to deliver packets alternating over the physical interfaces corresponding to networking interfaces fxp0 through fxp3:
# Plumb nodes together
ngctl mkpeer fxp0: one2many upper one
ngctl connect fxp0: fxp0:upper lower many0
ngctl connect fxp1: fxp0:upper lower many1
ngctl connect fxp2: fxp0:upper lower many2
ngctl connect fxp3: fxp0:upper lower many3
# Allow fxp1 through fxp3 to xmit/recv fxp0 frames
ngctl msg fxp1: setpromisc 1
ngctl msg fxp2: setpromisc 1
ngctl msg fxp3: setpromisc 1
ngctl msg fxp1: setautosrc 0
ngctl msg fxp2: setautosrc 0
ngctl msg fxp3: setautosrc 0
# Configure all four links as up
ngctl msg fxp0:upper \
setconfig "{ xmitAlg=1 failAlg=1 enabledLinks=[ 1 1 1 1 ] }"
# Bring up interface
ifconfig fxp0 192.168.1.1 netmask 0xfffffffc
With a similar setup on a peer machine (using the address 192.168.1.2), a point-to-point Ethernet connection with four times normal bandwidth is achieved. Literally main character bandwidth. π
π SEE ALSO π
π HISTORY π
The ng_one2many node type was implemented in FreeBSD 4.2. Oldie but goodie.
π«Ά AUTHORS π«Ά
The one2many netgraph node (with round-robin algorithm) was written by Archie Cobbs <archie@FreeBSD.org>. The all algorithm was added by Rogier R. Mulhuijzen <drwilco@drwilco.net>. Respect the OGs.
π BUGS π
More transmit and link failure algorithms should be supported. A good candidate is Cisco's Etherchannel. Noted, bestie. Noted.
This page was served up by Debian on November 13, 2012 β and yes, the vibe is still immaculate. Stay slaying, and don't forget to plumb your nodes responsibly. πβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2000 Whistle Communications, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms