NG_VJC(4)

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

🌸 NG_VJC(4) 🌸

omg hi bestie πŸ’– welcome to NG_VJC(4), straight out of the Kernel Interfaces Manual. This is the whole vibe for ng_vjc β€” the netgraph node type that does Van Jacobson compression. It's giving β€œtiny TCP header, big slay” energy, and we're gonna go through every single detail together, no skips, no cap. 🫢

✨ NAME ✨

ng_vjc β€” Van Jacobson compression netgraph node type πŸ’…

πŸŽ€ SYNOPSIS πŸŽ€

#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <net/slcompress.h>
#include <netgraph/ng_vjc.h>

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so the vjc node type performs Van Jacobson compression, which is used over PPP, SLIP, and other point-to-point IP connections to compress TCP packet headers. Literally iconic behavior. ✨

The ip hook represents the uncompressed side of the node, while the vjcomp, vjuncomp, and vjip hooks represent the compressed side of the node. Packets received on the ip will be compressed or passed through as appropriate. Packets received on the other three hooks will be uncompressed as appropriate. This node also supports β€œalways pass through” mode in either direction. Very flexible, very main character. πŸ’…

Van Jacobson compression only applies to TCP packets. Only β€œnormal” (i.e., common case) TCP packets are actually compressed. These are output on the vjcomp hook. Other TCP packets are run through the state machine but not compressed; these appear on the vjuncomp hook. Other non-TCP IP packets are forwarded unchanged to vjip. Like, the whole friend group gets handled differently, but everybody gets routed. 🫢

When connecting to a ng_ppp(4) node, the ip, vjuncomp, vjcomp, and vjip hooks should be connected to the ng_ppp(4) node's vjc_ip, vjc_vjcomp, vjc_vjuncomp, and vjc_ip hooks, respectively. Yep, that's exactly what the page says β€” copy it, don't β€œfix” it, periodt. πŸ’€

🧚 HOOKS 🧚

This node type supports the following hooks:

  • ip β€” Upstream (uncompressed) IP packets. The chill uncompressed side. 🌈
  • vjcomp β€” Downstream compressed TCP packets. The compressed besties go here. πŸ”₯
  • vjuncomp β€” Downstream uncompressed TCP packets. They went through the state machine but did not get compressed. πŸŽ€
  • vjip β€” Downstream uncompressed IP packets. Non-TCP IP packets land here unchanged. πŸ’œ

πŸ‘‘ CONTROL MESSAGES πŸ‘‘

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

⭐ NGM_VJC_SET_CONFIG (setconfig) ⭐

This command resets the compression state and configures it according to the supplied struct ngm_vjc_config argument. This structure contains the following fields:

struct ngm_vjc_config {
  u_char   enableComp;    /* Enable compression */
  u_char   enableDecomp;  /* Enable decompression */
  u_char   maxChannel;    /* Number of outgoing channels - 1 */
  u_char   compressCID;   /* OK to compress outgoing CID's */
};

When enableComp is set to zero, all packets received on the ip hook are forwarded unchanged out the vjip hook. Similarly, when enableDecomp is set to zero, all packets received on the vjip hook are forwarded unchanged out the ip hook, and packets are not accepted on the vjcomp and vjuncomp hooks. When a node is first created, both compression and decompression are disabled and the node is therefore operating in bi-directional β€œpass through” mode. Very β€œnew node, no drama” of it. 🌸

When enabling compression, maxChannel should be set to the number of outgoing compression channels minus one, and is a value between 3 and 15, inclusive. The compressCID field indicates whether it is OK to compress the CID header field for outgoing compressed TCP packets. This value should be zero unless either (a) it is not possible for an outgoing frame to be lost, or (b) lost frames can be reliably detected and immediately reported to the peer's decompression engine (see NGM_VJC_RECV_ERROR below). So like, do not casually set this to one, bestie. Read the caveat. 😭

⭐ NGM_VJC_GET_STATE (getstate) ⭐

This command returns the node's current state described by the struct slcompress structure, which is defined in <net/slcompress.h>. Fetching the state, iconic. ✨

⭐ NGM_VJC_CLR_STATS (clrstats) ⭐

Clears the node statistics counters. Statistics are also cleared whenever the enableComp or enableDecomp fields are changed from zero to one by a NGM_VJC_SET_CONFIG control message. Clean slate energy. 🧼

⭐ NGM_VJC_RECV_ERROR (recverror) ⭐

When the peer has CID header field compression enabled, this message must be sent to the local vjc node immediately after detecting that a received frame has been lost, due to a bad checksum or for any other reason. Failing to do this can result in corrupted TCP stream data. That's a big yikes, so yeah β€” send it. 🚨

πŸ’€ SHUTDOWN πŸ’€

This node shuts down upon receipt of a NGM_SHUTDOWN control message, or when all hooks have been disconnected. Bye bestie, the hooks are empty, the node is out. πŸ‘‹

🌈 SEE ALSO 🌈

πŸŽ€ HISTORY πŸŽ€

The ng_vjc node type was implemented in FreeBSD 4.0. Vintage but make it slay. πŸ¦‹

πŸ’– AUTHORS πŸ’–

Archie Cobbs <archie@FreeBSD.org> β€” we love a credited icon. πŸ‘‘

🚨 BUGS 🚨

Okay so important caveat time, bestie. As the initialization routine in the kernel implementation of Van Jacobson compression initializes both compression and decompression at once, this node does not allow compression and decompression to be enabled in separate operations. In order to enable one when the other is already enabled, first both must be disabled, then both enabled. This of course resets the node state. This restriction may be lifted in a later version. So yeah, it's a package deal, unfortunately. 😭

When built as a loadable kernel module, this module includes the file net/slcompress.c. Although loading the module should fail if net/slcompress.c already exists in the kernel, currently it does not, and the duplicate copies of the file do not interfere. However, this may change in the future. So like, it works right now, but do not get too comfortable. πŸ’€


mwah πŸ’‹ this page is from Debian, dated January 19, 1999, and it's the NG_VJC(4) manual page β€” bye bestie! πŸ’œ

πŸ“¦ where this page comes from