NG_ONE2MANY(4)
π ng_one2many β packet multiplexing netgraph node type π
okay bestie, welcome to the ng_one2many page, straight out of the Kernel Interfaces Manual. sit down, grab a strawberry π, we're gonna talk about packet multiplexing and it's gonna be adorable.
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <netgraph/ng_one2many.h>
πΈ DESCRIPTION πΈ
so one2many is literally the chillest little mechanism for routing packets over several links, one-to-many style β and in the reverse direction, many-to-one, because it contains multitudes π. there's a single hook called one, and then a whole squad of hooks called many0, many1, etc.
the vibe check: packets that show up on any of the many hooks get forwarded out the one hook. packets that show up on the one hook get forwarded out one or more of the many hooks β and which hook(s) get the honor is decided by the node's configured transmit algorithm. and no cap: packets are not altered in any way. not a single byte touched. iconic behavior, honestly. π
each of the connected many links can be considered up or down. packets are never delivered out a many hook that's down. it's giving "no entry, we're closed" π«. how a link gets determined to be up or down depends on the node's configured link failure detection algorithm.
now, before an interface or link can be plumbed into a group, its status must be marked as being "up". this is normally set up during the initial boot stages by rc.conf(5). it's also possible to change an interface's status to "up" by using the ifconfig(8) utility. slay. π
π¦ TRANSMIT ALGORITHMS π¦
NG_ONE2MANY_XMIT_ROUNDROBINβ packets are delivered out themanyhooks in sequential order. each packet goes out on a differentmanyhook. taking turns, as one does. πNG_ONE2MANY_XMIT_ALLβ packets are delivered out all themanyhooks. each packet goes out eachmanyhook. it's giving "invite the whole group chat". πNG_ONE2MANY_XMIT_FAILOVERβ packets are delivered out the first activemanyhook. main character energy, one link at a time. β
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, just receipts. π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. so basically it's just listening to the gossip. π
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. it's keeping everyone posted, fr fr. π¬
π HOOKS π
this node type supports up to NG_ONE2MANY_MAX_LINKS hooks named many0, many1, etc., plus a single hook named one.
π 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 your friends, bestie. π«Ά
NGM_ONE2MANY_GET_CONFIG(getconfig) β returns the current node configuration in astruct ng_one2many_link_config. tell me everything, no gatekeeping. π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 the one link, use the link number -1. yes, negative one. it's quirky like that. π
NGM_ONE2MANY_CLR_STATS(clrstats) β this command takes a 32 bit link number as an argument and clears the statistics for that link. fresh start, we love a reset. β¨NGM_ONE2MANY_GETCLR_STATS(getclrstats) β same asNGM_ONE2MANY_GET_STATS, but also atomically clears the statistics for the link as well. grab and wipe in one flawless motion. π
π SHUTDOWN π
this node shuts down upon receipt of a NGM_SHUTDOWN control message, or when all hooks have been disconnected. bye bestie, it was real. π¦
β 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. four times!! ate and left no crumbs. π₯
π SEE ALSO π
netgraph(4), ng_bridge(4), ng_ether(4), ng_hub(4), ifconfig(8), ngctl(8)
π HISTORY π
the ng_one2many node type was implemented in FreeBSD 4.2. vintage, but make it fashion. π
π 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>. legends, both of them. π«Ά
π BUGS π
more transmit and link failure algorithms should be supported. a good candidate is Cisco's Etherchannel. noted, bestie, adding it to the list. π
and that's the whole page, babes β this one's from the Debian crew, dated November 13, 2012, and it lives in section 4 of the manual (kernel interfaces, if you were wondering). go forth and multiplex responsibly. mwah π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2000 Whistle Communications, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms