NG_ETF(4)
π NG_ETF(4) β ng_etf: Ethertype filtering netgraph node type Β· Kernel Interfaces Manual β¨
π NAME π
ng_etf β Ethertype filtering netgraph node type, bestie π¦
π¦ SYNOPSIS π¦
#include <netgraph.h>
#include <netgraph/ng_etf.h>
πΈ DESCRIPTION πΈ
okay so picture this: the etf node type is your little multiplexer + filter bestie for data between hooks, and it decides based on the ethertype it finds in an Ethernet header β and yes, it presumes that header lives in the first 14 bytes of the data. π
Incoming Ethernet frames get accepted on the downstream hook. If the ethertype matches a value the node has been configured to filter, the packet is forwarded out the hook that was identified when that value was configured. Slay. If it does not match any configured value, it gets passed to the nomatch hook. And if the nomatch hook isn't connected? Sorry bestie, the packet is dropped. π
Packets travelling the other way β towards the downstream hook β are also examined and filtered. If a packet has an ethertype that matches one of the values configured into the node, it must have arrived in on the hook that value was configured for, otherwise it will be discarded. Ethertypes with values other than those configured by the control messages must have arrived via the nomatch hook. Periodt. β¨
π HOOKS π
This node type supports these 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 using theupperhook.β¨any legal nameβ©β any other hook name will be accepted and 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. iykyk π
π CONTROL MESSAGES π
This node type supports the generic control messages, plus the following:
NGM_ETF_GET_STATUS(getstatus) β this command returns astruct ng_etfstatcontaining node statistics for packet counts. cute little counters, no cap πNGM_ETF_SET_FILTER(setfilter) β sets 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 is possible to set a filter in place from the command line as follows:
#!/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} }
π SHUTDOWN π
This node shuts down upon receipt of a NGM_SHUTDOWN control message, or when all hooks have been disconnected. bye bestie π
β SEE ALSO β
netgraph(4), ng_ether(4), ngctl(8), nghook(8)
π HISTORY π
The ng_etf node type was implemented in FreeBSD 5.0. iconic behavior, honestly π«Ά
π AUTHORS π
Julian Elischer β <julian@FreeBSD.org>
π Debian Β· November 13, 2012 Β· bye bestie, go slay those ethertypes π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2001, FreeBSD Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms