NG_ETF(4)
π NG_ETF(4) β the Ethertype Filtering Netgraph Node Type π
okay bestie, gather round, because today we're talking about ng_etf β a netgraph node type that does ethertype filtering. it's giving bouncer-at-the-club energy but for Ethernet frames, and honestly? obsessed. π
β¨ SYNOPSIS β¨
#include <netgraph.h>
#include <netgraph/ng_etf.h>
like, that's it. two includes. iconic. π
πΈ DESCRIPTION πΈ
so the etf node type does two things and does them well: it multiplexes and it filters data between hooks. what's it filtering on? the ethertype found in an Ethernet header, which it presumes lives in the first 14 bytes of the data. no cap. π¦
here's the tea on incoming frames:
- incoming Ethernet frames get accepted on the
downstreamhook - if the ethertype matches a value the node has been configured to filter β the packet is forwarded out the hook that was identified back when that value was configured β¨
- if it doesn't match a configured value β off it goes to the
nomatchhook - if the
nomatchhook isn't connected β the packet is dropped. bye. π
now, the plot twist: packets going the other way (towards the downstream hook) also get examined and filtered. so if a packet has an ethertype matching one of the values configured into the node, it must have arrived in on the hook for which that value was configured β otherwise it gets discarded. rude but necessary.
and ethertypes that aren't among the configured values? those must have arrived via the nomatch hook. it's a whole vibe check for packets. π₯
π«Ά HOOKS π«Ά
this node type supports the following hooks, bestie:
downstreamβ typically this hook would be connected to ang_ether(4)node, using thelowerhook.nomatchβ typically this hook would also be connected to ang_ether(4)type node, this time using theupperhook.β¨any legal nameβ©β any other hook name will be accepted, and it can be used as the match target of an ethertype. typically this hook would be attached to a protocol handling node that requires and generates packets with a particular set of ethertypes. main character hook, honestly. π
π CONTROL MESSAGES π
this node type supports the generic control messages, plus these little darlings:
NGM_ETF_GET_STATUS(getstatus) β this command returns astruct ng_etfstatcontaining node statistics for packet counts. numbers! we love numbers. πNGM_ETF_SET_FILTER(setfilter) β sets the a new ethertype filter into the node and specifies the hook to and from which packets of that type should use. the hook and ethertype are specified in a structure of typestruct ng_etffilter:
struct ng_etffilter {
char matchhook[NG_HOOKSIZ]; /* hook name */
uint16_t ethertype; /* this ethertype to this hook */
};
π EXAMPLES π
using ngctl(8) it's possible to set a filter in place from the command line, like so:
#!/bin/sh
ETHER_IF=fxp0
MATCH1=0x834
MATCH2=0x835
cat <<DONE >/tmp/xwert
# Make a new ethertype filter and attach to the Ethernet lower hook.
# first remove left over bits from last time.
shutdown ${ETHER_IF}:lower
mkpeer ${ETHER_IF}: etf lower downstream
# Give it a name to easily refer to it.
name ${ETHER_IF}:lower etf
# Connect the nomatch hook to the upper part of the same interface.
# All unmatched packets will act as if the filter is not present.
connect ${ETHER_IF}: etf: upper nomatch
DONE
ngctl -f /tmp/xwert
# something to set a hook to catch packets and show them.
echo "Unrecognised packets:"
nghook -a etf: newproto &
# Filter two random ethertypes to that hook.
ngctl 'msg etf: setfilter { matchhook="newproto" ethertype=${MATCH1} }
ngctl 'msg etf: setfilter { matchhook="newproto" ethertype=${MATCH2} }
(yes, those last two lines are exactly as written β we're keeping it verbatim, bestie. π)
π SHUTDOWN π
this node shuts down upon receipt of a NGM_SHUTDOWN control message, or when all hooks have been disconnected. so if you ghost every single hook, the node ghosts itself. poetic. π
β SEE ALSO β
π¦ HISTORY π¦
the ng_etf node type was implemented in FreeBSD 5.0. vintage but make it fashion. β¨
π AUTHORS π
Julian Elischer <julian@FreeBSD.org>
and that's the whole page, bestie!! this cutie came to you from the Debian edition, dated November 13, 2012 β shoutout to the NG_ETF(4) kernel interfaces manual for being the blueprint. now go filter some ethertypes, you absolute legend. ππ¦π
πΈ
π¦ 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) 2001, FreeBSD Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms