NG_TEE(4)

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

πŸ’… NG_TEE(4) β€” the netgraph "tee" node type, explained by your favorite kernel gremlin

okay so real quick β€” this is a page from the Kernel Interfaces Manual, and yes bestie we're diving into netgraph internals together 🫢 stay with me, it's actually so good.


✨ NAME ✨

ng_tee β€” the netgraph ``tee'' node type. it's giving "split the signal, keep both copies," and honestly? iconic πŸ’…


🌸 SYNOPSIS 🌸

#include <sys/types.h>
#include <netgraph/ng_tee.h>

that's it. two includes. she's low-maintenance, she's easy to love πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so the tea β˜• is this: the tee node type does basically the same job as the tee(1) command β€” except, you know, in the kernel. Tee nodes are useful for debugging or "snooping" on a connection between two netgraph nodes πŸ‘€ (no cap, that's literally what the manpage says, snooping is the word).

Tee nodes have four hooks: right, left, right2left, and left2right.

here's the vibe:

  • all data received on right gets sent unmodified to both left and right2left ✨
  • similarly, all data received on left gets sent unmodified to both right and left2right ✨

and the plot twist: Packets may also be received on right2left and left2right; if so, they are forwarded unchanged out hooks right and left, respectively πŸ”

she's a whole two-way mirror and she ate πŸ’€πŸ”₯


πŸŽ€ HOOKS πŸŽ€

This node type supports the following hooks:

  • right β€” The connection to the node on the right 🫱
  • left β€” The connection to the node on the left 🫲
  • right2left β€” Tap for right to left traffic 🎯
  • left2right β€” Tap for left to right traffic 🎯

like, the naming is soooo on the nose and honestly? we stan clarity πŸ’œ


⭐ CONTROL MESSAGES ⭐

This node type supports the generic control messages, plus the following:

  • NGM_TEE_GET_STATS (getstats) β€” Get statistics, returned as a struct ng_tee_stats πŸ“Š
  • NGM_TEE_CLR_STATS (clrstats) β€” Clear statistics 🧹

the little parenthesized names are the ngctl-friendly versions, iykyk 🌈


πŸ’€ SHUTDOWN πŸ’€

This node shuts down upon receipt of an NGM_SHUTDOWN control message, or when all hooks have been disconnected.

but here's the soft-launch detail you can't miss πŸ‘‘: If both right and left hooks are present, node removes itself from the chain gently, connecting right and left together.

no drama. no broken chain. she just... leaves the group chat and connects the two of you πŸ’– periodt.


🌈 SEE ALSO 🌈

go read all three, fr fr, they're the supporting cast and they deserve their flowers 🌸


🧚 HISTORY 🧚

The ng_tee node type was implemented in FreeBSD 4.0. a legend since day one, ngl πŸŽ€


πŸ’œ AUTHORS πŸ’œ

Julian Elischer <julian@FreeBSD.org> β€” shoutout to the main character who wrote this node, we're obsessed πŸ«ΆπŸ‘‘


and that's the page bestie!! this beauty shipped on Debian, dated May 28, 2004 β€” NG_TEE(4), that's the header up top and the footer down here, all accounted for πŸ’…βœ¨ mwah, go snoop some traffic responsibly πŸ”₯

πŸ“¦ where this page comes from