NG_VLAN(4)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… 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_VLAN frame that shows up on the downstream hook 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 the nomatch hook instead. not me just yeeting it to nomatch πŸ™ˆ
  • real talk though: if the nomatch hook 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 nomatch hook is passed unmodified to the downstream hook. untouched, iconic, no glow-up needed 🫢
  • An Ethernet frame received on any of the β€œvlan” hooks gets tagged accordingly and sent out the downstream hook. 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 a ng_ether(4) node, using the lower hook. that's the classic setup πŸ¦‹
  • nomatch β€” typically this hook would also be connected to a ng_ether(4) type node, but using the upper hook 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 a ng_eiface(4) type node using the ether hook. 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 as addfilter) β€” associates a hook with the tag. match made in heaven, periodt πŸ’
  • NGM_VLAN_DEL_FILTER (also known as delfilter) β€” disassociates a hook from the tag. it's giving breakup era 😭
  • NGM_VLAN_GET_TABLE (also known as gettable) β€” 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