NG_TCPMSS(4)

🌸 NG_TCPMSS(4) β€” the girlies' guide to the netgraph TCP MSS node 🌸

okay so bestie, welcome to ng_tcpmss, straight out of the Kernel Interfaces Manual πŸ’– this is the page for the netgraph node that goes in and fiddles with the TCP MSS option, and honestly? it's giving surgeon but make it packets πŸ’…


✨ NAME ✨

ng_tcpmss β€” netgraph node to adjust TCP MSS option

like, that's literally her whole job. she adjusts the MSS option. icon behaviour πŸŽ€


✨ SYNOPSIS ✨

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

yes babe you gotta include both headers, no skipping 🫢


✨ DESCRIPTION ✨

so the tcpmss node type is designed to alter the Maximum Segment Size option of TCP packets. that's the whole vibe.

this node accepts an arbitrary number of hooks β€” no cap, she'll take as many as you throw at her πŸ’…

when a hook is brand new, it's considered unconfigured. it's just sitting there, no thoughts, head empty πŸ™ˆ. to actually make it do something you use the NG_TCPMSS_CONFIG control message, which configures a hook.


✨ CONTROL MESSAGES ✨

this node type supports all the generic control messages, plus these iconic ones ⬇️

  • NGM_TCPMSS_CONFIG (config) β€” this one configures the node to do the given MSS adjusting on a particular hook. it needs a struct ng_tcpmss_config handed over as its argument:
struct ng_tcpmss_config {
        char            inHook[NG_HOOKSIZ];
        char            outHook[NG_HOOKSIZ];
        uint16_t        maxMSS;
}

so what this means, fr fr: packets received on inHook get checked for the TCP MSS option, and that option gets reduced down to maxMSS if it exceeds maxMSS. after that lil glow-up, the packets get sent to the hook outHook. simple as πŸ¦‹

  • NGM_TCPMSS_GET_STATS (getstats) β€” grabs the statistics for a given hook. the stats come back in a 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 all those numbers bestie, she's tracking everything πŸ‘‘

  • NGM_TCPMSS_CLR_STATS (clrstats) β€” clears the statistics for a given hook. bye bye data 🧹
  • NGM_TCPMSS_GETCLR_STATS (getclrstats) β€” obtains and clears the statistics for a given hook. multitasking queen, she ate πŸ’…

✨ EXAMPLES ✨

okay so in this next example, packets get 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

first line makes the node and hooks it up, second one sets maxMSS to 1452, third one diverts the traffic in, fourth one lets the packets keep flowing through ipfw after they've been hacked. periodt 🌈


✨ SHUTDOWN ✨

this node shuts down when it receives an NGM_SHUTDOWN control message, or when all hooks have been disconnected. she simply ✨leaves✨ when there's nothing left to do 😭


✨ SEE ALSO ✨

go read those too, they're part of the family πŸ’œ


✨ HISTORY ✨

the ng_tcpmss node type was implemented in FreeBSD 6.0. vintage, but make it slay πŸ‘‘


✨ AUTHORS ✨

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

thank you kings, we appreciate you 🫢


✨ BUGS ✨

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

yeah that's the whole bug note. no further details, no workaround, just vibes and broken stats. be aware bestie 😭


and that's the page!! shoutout to the Debian crew for shipping this one, dated June 9, 2005 β€” so old school and yet still out here adjusting MSS like a legend. mwah πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from