NG_TCPMSS(4)

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

🌸 NG_TCPMSS(4) β€” the netgraph node that adjusts the TCP MSS option 🌸

okay bestie, so this is ng_tcpmss(4) from the Kernel Interfaces Manual and honestly it's giving "tiny node, huge main character energy." Let's get into it πŸ’…


✨ NAME ✨

ng_tcpmss β€” a netgraph node that adjusts the TCP MSS option. that's it, that's the whole job, and she does it slayfully πŸŽ€


✨ SYNOPSIS ✨

#include <netgraph.h>
#include <netgraph/ng_tcpmss.h>

like, include these two and you're in, iykyk πŸ¦‹


✨ DESCRIPTION ✨

So the tcpmss node type is literally designed to alter the Maximum Segment Size option of TCP packets. iconic behavior, no notes πŸ‘‘

This node accepts an arbitrary number of hooks β€” as many as you want, she's flexible like that.

Initially, a new hook is considered unconfigured. and like... a hook just vibing there unconfigured isn't doing anything, so to actually make it work you use the NG_TCPMSS_CONFIG control message to configure it. that's the vibe check the hook needs to pass πŸ’–


✨ CONTROL MESSAGES ✨

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

  • NGM_TCPMSS_CONFIG (config) β€” configures the node to do the given MSS adjusting on a particular hook. It requires the struct ng_tcpmss_config to be supplied as an argument:
struct ng_tcpmss_config {
        char            inHook[NG_HOOKSIZ];
        char            outHook[NG_HOOKSIZ];
        uint16_t        maxMSS;
}

what this means, bestie: packets received on inHook get checked for the TCP MSS option, and the latter gets reduced down to maxMSS if it exceeds maxMSS. After that, packets get sent to hook outHook. it's giving "in through the in-door, out through the out-door" πŸšͺ✨

  • NGM_TCPMSS_GET_STATS (getstats) β€” obtains statistics for a given hook. The statistics are returned in struct ng_tcpmss_hookstat:
struct ng_tcpmss_hookstat {
        uint64_t        Octets;         /* total bytes */
        uint64_t        Packets;        /* total packets */
        uint16_t        maxMSS;         /* maximum MSS */
        uint64_t        SYNPkts;        /* TCP SYN packets */
        uint64_t        FixedPkts;      /* changed packets */
};

look at those lil comments, they ate πŸ“

  • NGM_TCPMSS_CLR_STATS (clrstats) β€” clears statistics for a given hook. bye bye data πŸ‘‹
  • NGM_TCPMSS_GETCLR_STATS (getclrstats) β€” obtains and clears statistics for a given hook. she does both, she's efficient, we love a multitasker πŸ’…

✨ EXAMPLES ✨

okay so in the following example, packets are injected into the tcpmss node using the ng_ipfw(4) node. watch and learn 🧚

# Create tcpmss node and connect it to ng_ipfw node
ngctl mkpeer ipfw: tcpmss 100 qqq

# Adjust MSS to 1452
ngctl msg ipfw:100 config '{ inHook="qqq" outHook="qqq" maxMSS=1452 }'

# Divert traffic into tcpmss node
ipfw add 300 netgraph 100 tcp from any to any tcpflags syn out via fxp0

# Let packets continue with ipfw after being hacked
sysctl net.inet.ip.fw.one_pass=0

like literally just copy these, they're the blueprint πŸ”₯


✨ SHUTDOWN ✨

This node shuts down upon receipt of an NGM_SHUTDOWN control message, or when all hooks have been disconnected. two ways to exit the group chat, both valid 😭


✨ SEE ALSO ✨

netgraph(4), ng_ipfw(4) β€” go read these too, they're the supporting cast 🫢


✨ HISTORY ✨

The ng_tcpmss node type was implemented in FreeBSD 6.0. vintage, but make it iconic 🌈


✨ AUTHORS ✨

  • Alexey Popov <lollypop@flexuser.ru>
  • Gleb Smirnoff <glebius@FreeBSD.org>

credit where credit is due, we stan πŸ’œ


✨ BUGS ✨

When running on SMP, system statistics may be broken. πŸ’€

not me telling you this is a real thing that's in the manpage β€” if you're on SMP, the stats might be lying to you. stay safe out there πŸ™ˆ


⭐ and that's the whole page, bestie! this one's from the Debian build of the manual, dated June 9, 2005 β€” old enough to be your older cousin's age and still serving looks. mwah πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from