NG_CHECKSUM(4)
π ng_checksum(4) π β from the Kernel Interfaces Manual, bestie β¨
okay so real talk: this is the manual page for the ng_checksum node type β the whole βreconstructing IP checksumsβ situation β and weβre gonna get you fluent in it, no cap π«Ά
πΈ NAME πΈ
ng_checksum β reconstructing IP checksums node type π
β¨ SYNOPSIS β¨
#include <netgraph/ng_checksum.h>
thatβs the include, bestie β put it in your code and youβre in business π
π¦ DESCRIPTION π¦
The checksum node can calculate, or prepare for calculation in hardware, IPv4 header, TCP and UDP checksums. literally its whole personality π
π HOOKS π
This node type has two hooks, and yes theyβre giving main character energy:
inβ Packets received on this hook are processed according to settings specified in config and then forwarded to theouthook, if it exists and is connected. Otherwise they are reflected back to theinhook. πoutβ Packets received on this hook are forwarded to theinhook without any changes. zero edits, just vibes β¨
π CONTROL MESSAGES π
This node type supports the generic control messages, plus the following iconic ones:
NGM_CHECKSUM_SETDLT(setdlt) β Sets the data link type on theinhook. Currently, supported types areDLT_RAW(raw IP datagrams) andDLT_EN10MB(Ethernet).DLT_definitions can be found in the<net/bpf.h>header. Currently used values areDLT_EN10MB = 1andDLT_RAW = 12. π¦NGM_CHECKSUM_GETDLT(getdlt) β This control message obtains the data link type on theinhook. πNGM_CHECKSUM_SETCONFIG(setconfig) β Sets the node configuration. The followingstruct ng_checksum_configmust be supplied as an argument:
struct ng_checksum_config {
uint64_t csum_flags;
uint64_t csum_offload;
};
The csum_flags can be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6 (other values are ignored) for instructing the node to calculate the corresponding checksum. π₯
The csum_offload value can be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6 (other values are ignored) for instructing the node what checksums should be requested from the hardware. π οΈ
The node also takes into account any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6 already flagged on the mbuf. π
NGM_CHECKSUM_GETCONFIG(getconfig) β This control message obtains the current node configuration returned as astruct ng_checksum_config. πNGM_CHECKSUM_GET_STATS(getstats) β Returns node statistics as astruct ng_checksum_stats. πNGM_CHECKSUM_CLR_STATS(clrstats) β Clear the node statistics. π§ΉNGM_CHECKSUM_GETCLR_STATS(getclrstats) β This command is identical toNGM_CHECKSUM_GET_STATS, except that the statistics are also atomically cleared. β‘
π SHUTDOWN π
This node shuts down upon receipt of a NGM_SHUTDOWN control message, or when all hooks have been disconnected. bye bestie πβ¨
π EXAMPLES π
ngctl(8) script:
/usr/sbin/ngctl -f- <<-SEQ
msg checksum-1: setdlt 1
msg checksum-1: setconfig { csum_flags=0 csum_offload=6 }
SEQ
Set the data link type to DLT_EN10MB (Ethernet), do not set additional checksum flags and request that the hardware calculate CSUM_IP_UDP|CSUM_IP_TCP. ate and left no crumbs π
π₯
π«Ά SEE ALSO π«Ά
netgraph(4), ng_patch(4), ngctl(8)
β HISTORY β
The ng_checksum node type was implemented in FreeBSD 10.2 and first submitted in FreeBSD 12.0. throwback icon behavior π
π AUTHORS π
Dmitry Vagin <daemon.hammer@ya.ru>. π
and thatβs the page, bestie β sourced from Debian, dated October 29, 2015, and yes itβs giving vintage but make it iconic ππ¦β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2015 Dmitry Vagin <daemon.hammer@ya.ru>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms