NG_ETHER(4)
โจ NAME โจ
ng_ether โ the Ethernet netgraph node type ๐ฆ (this page is ng_ether(4), the Kernel Interfaces Manual situation ๐
)
๐ธ SYNOPSIS ๐ธ
#include <netgraph/ng_ether.h>
๐ DESCRIPTION ๐
okay so bestie, the ether netgraph node type is literally the little matchmaker that lets Ethernet interfaces hang out with the netgraph(4) networking subsystem ๐ซถ. The way that works is: once the ng_ether module gets loaded into the kernel, a node is automatically created for each and every Ethernet interface in the system โ no cap, you don't have to ask. And each node will attempt to name itself with the same name as the interface it's attached to. iconic behavior honestly ๐
Three hooks are supported: lower, upper, and orphans. The hook name divert may be used as an alias for lower, and it's provided for backward compatibility โ in reality, the two names represent the same hook, they're not different things, periodt.
The lower hook is a connection to the raw Ethernet device. When it's connected, all incoming packets get forwarded to this hook instead of being passed to the kernel for upper layer processing. Writing to this hook results in a raw Ethernet frame being transmitted by the device ๐ค. Normal outgoing packets are not affected by lower being connected.
The upper hook is a connection to the upper protocol layers. When it's connected, all outgoing packets get forwarded to this hook instead of being transmitted by the device. Writing to this hook results in a raw Ethernet frame being received by the kernel just as if it had come in over the wire ๐โจ. Normal incoming packets are not affected by upper being connected.
The orphans hook is equivalent to lower, except that only unrecognized packets (the ones that would otherwise be discarded ๐ญ) are written to the hook, while other normal incoming traffic is unaffected. Unrecognized packets written to upper will be forwarded back out to orphans if it's connected. cute little recycling moment โป๏ธ
In all cases, frames are raw Ethernet frames with the standard 14 byte Ethernet header (but no checksum).
When no hooks are connected, upper and lower are in effect connected together, so packets flow normally upwards and downwards ๐. Default vibe = normal.
๐ HOOKS ๐
This node type supports the following hooks:
lowerโ connection to the lower device link layer.upperโ connection to the upper protocol layers.orphansโ likelower, but only receives unrecognized packets.
๐ CONTROL MESSAGES ๐
This node type supports the generic control messages, plus the following:
NGM_ETHER_GET_IFNAME(getifname) โ returns the name of the associated interface as a NUL-terminated ASCII string. Normally this is the same as the name of the node ๐ฏโ๏ธNGM_ETHER_GET_IFINDEX(getifindex) โ returns the global index of the associated interface as a 32 bit integer.NGM_ETHER_GET_ENADDR(getenaddr) โ returns the device's unique six byte Ethernet address ๐ฎ.NGM_ETHER_SET_ENADDR(setenaddr) โ sets the device's unique six byte Ethernet address. This control message is equivalent to using theSIOCSIFLLADDRioctl(2) system call.NGM_ETHER_SET_PROMISC(setpromisc) โ enable or disable promiscuous mode ๐. This message includes a single 32 bit integer flag that enables or disables promiscuous mode on the interface. Any non-zero value enables promiscuous mode.NGM_ETHER_GET_PROMISC(getpromisc) โ get the current value of the node's promiscuous flag. The returned value is always either one or zero. Note that this flag reflects the node's own promiscuous setting and does not necessarily reflect the promiscuous state of the actual interface, which can be affected by other means (e.g., bpf(4)). so like, don't be fooled bestie ๐NGM_ETHER_SET_AUTOSRC(setautosrc) โ sets the automatic source address override flag. This message includes a single 32 bit integer flag that causes all outgoing packets to have their source Ethernet address field overwritten with the device's unique Ethernet address. If this flag is set to zero, the source address in outgoing packets is not modified. The default setting for this flag is disabled.NGM_ETHER_GET_AUTOSRC(getautosrc) โ get the current value of the node's source address override flag. The returned value is always either one or zero.NGM_ETHER_ADD_MULTI(addmulti) โ join Ethernet multicast group ๐ซ. This control message is equivalent to using theSIOCADDMULTIioctl(2) system call.NGM_ETHER_DEL_MULTI(delmulti) โ leave Ethernet multicast group ๐ช. This control message is equivalent to using theSIOCDELMULTIioctl(2) system call.NGM_ETHER_DETACH(detach) โ detach from underlying Ethernet interface and shut down node ๐.
๐ฆ SHUTDOWN ๐ฆ
Upon receipt of the NGM_SHUTDOWN control message, all hooks are disconnected, promiscuous mode is disabled, but the node is not removed. The node can be shut down only using the NGM_ETHER_DETACH control message. And if the interface itself is detached (e.g., because of PC Card removal), the node disappears as well ๐ซฅ.
๐ฅ EXAMPLES ๐ฅ
This command dumps all unrecognized packets received by the โfxp0โ interface to standard output, decoded in hex and ASCII:
nghook -a fxp0: orphans
This command sends the contents of sample.pkt out the interface โfxp0โ:
cat sample.pkt | nghook fxp0: orphans
These commands insert an ng_tee(4) node between the lower and upper protocol layers, which can be used for tracing packet flow, statistics, etc.:
ngctl mkpeer fxp0: tee lower right
ngctl connect fxp0: lower upper left
๐ SEE ALSO ๐
arp(4), netgraph(4), netintro(4), ifconfig(8), ngctl(8), nghook(8)
๐ AUTHORS ๐
Julian Elischer <julian@FreeBSD.org> Archie Cobbs <archie@FreeBSD.org>
๐ BUGS ๐
The automatic KLD module loading mechanism that works for most other Netgraph node types does not work for the ether node type, because ether nodes are not created on demand โ instead, they are created when Ethernet interfaces are attached or when the KLD is first loaded ๐ญ. Therefore, if the KLD is not statically compiled into the kernel, it is necessary to load the KLD manually in order to bring the ether nodes into existence. no auto-magic for you, bestie, you gotta do it yourself ๐
okay that's the whole page, mwah ๐ this one came from the Debian edition, dated June 23, 2011, and yeah the footer says NG_ETHER(4) โ stay hydrated, go read your man pages, ily ๐ซถโจ
๐ฆ 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