NG_VLAN(4)
π
NG_VLAN(4) β the ng_vlan manual, bestie edition π
okay so this is from the Kernel Interfaces Manual, section 4, and it's literally all about ng_vlan β the IEEE 802.1Q VLAN tagging netgraph node type. yes bestie, netgraph. we're doing this. sit down, grab a strawberry π, it's gonna slay.
β¨ NAME β¨
ng_vlan β the IEEE 802.1Q VLAN tagging netgraph node type π¦
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <netgraph.h>
#include <netgraph/ng_vlan.h>
like, just include these three and you're in, no cap π
β¨ DESCRIPTION β¨
The vlan node type multiplexes frames tagged according to the IEEE 802.1Q standard between different hooks. that's the whole vibe β it's a little traffic director for tagged frames π
Every node has two special hooks, downstream and nomatch, plus an arbitrary number of βvlanβ hooks, and each one of those is associated with a particular VLAN tag. so it's like the main character node with two besties and then a whole group chat of vlan hooks π
here's the tea on how frames flow:
- An
ETHERTYPE_VLANframe that shows up on thedownstreamhook with a tag the node has been configured to filter gets sent out the corresponding βvlanβ hook. slay, matched β¨ - If it does not match any of the configured tags, or it isn't of type
ETHERTYPE_VLAN, it gets sent out thenomatchhook instead. not me just yeeting it to nomatch π - real talk though: if the
nomatchhook is not connected, the packet is dropped. π gone. no forwarding, no rescue. keep that in mind.
and the other direction:
- An Ethernet frame received on the
nomatchhook is passed unmodified to thedownstreamhook. untouched, iconic, no glow-up needed π«Ά - An Ethernet frame received on any of the βvlanβ hooks gets tagged accordingly and sent out the
downstreamhook. now it's got a little tag, look at it go π
β¨ HOOKS β¨
This node type supports the following hooks:
downstreamβ typically this hook would be connected to ang_ether(4)node, using thelowerhook. that's the classic setup π¦nomatchβ typically this hook would also be connected to ang_ether(4)type node, but using theupperhook this time. see what they did there πβ¨any valid nameβ©β any other hook name will be accepted and should later be associated with a particular tag. typically this hook would be attached to ang_eiface(4)type node using theetherhook. name it whatever you want bestie, it's yours π
β¨ CONTROL MESSAGES β¨
This node type supports the generic control messages, plus the following. all three are giving very much "manage your filters" energy:
NGM_VLAN_ADD_FILTER(also known asaddfilter) β associates a hook with the tag. match made in heaven, periodt πNGM_VLAN_DEL_FILTER(also known asdelfilter) β disassociates a hook from the tag. it's giving breakup era πNGM_VLAN_GET_TABLE(also known asgettable) β returns a table of all hook/tag associations. the receipts, literally π§Ύ
β¨ EXAMPLES β¨ π
here's a whole little shell script, copy it exactly, don't @ me:
#!/bin/sh
ETHER_IF=rl0
ngctl -f- <<EOF
shutdown ${ETHER_IF}:
mkpeer ${ETHER_IF}: vlan lower downstream
name ${ETHER_IF}:lower vlan
connect ${ETHER_IF}: vlan: upper nomatch
EOF
ngctl mkpeer vlan: eiface vlan123 ether
ngctl msg vlan: addfilter '{ vlan=123 hook="vlan123" }'
look at that heredoc. the way that ngctl -f- <<EOF eats. π
β¨
β¨ SHUTDOWN β¨
This node shuts down upon receipt of a NGM_SHUTDOWN control message, or when all hooks have been disconnected. so either way, it knows when to leave the party π«Ά no dramatic exit needed.
β¨ SEE ALSO β¨
netgraph(4), ng_eiface(4), ng_ether(4), ngctl(8), nghook(8) β go read these too, iykyk π
β¨ HISTORY β¨
The ng_vlan node type appeared in FreeBSD 4.10. vintage, honestly π
β¨ AUTHORS β¨
Ruslan Ermilov <ru@FreeBSD.org> β thank you for your service, king π«‘πΈ
and that's the whole page bestie!! π this one came from Debian, dated March 1, 2004 β yes it's older than most of us, and it's still iconic. mwah ππβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2003 Ruslan Ermilov
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms