NG_CHECKSUM(4)

NAME
ng_checksum - reconstructing IP checksums node type

SYNOPSIS
#include <netgraph/ng_checksum.h>

DESCRIPTION
The checksum node can calculate, or prepare for calculation in hardware, IPv4 header, TCP and UDP checksums.

HOOKS
This node type has two hooks:

in  Packets received on this hook are processed according to settings specified in config and then forwarded to the out hook, if it exists and is connected. Otherwise they are reflected back to the in hook.

out Packets received on this hook are forwarded to the in hook without any changes.

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

NGM_CHECKSUM_SETDLT (setdlt)
    Sets the data link type on the in hook. Currently, supported types are DLT_RAW (raw IP datagrams) and DLT_EN10MB (Ethernet). DLT_ definitions can be found in the <net/bpf.h> header. Currently used values are DLT_EN10MB = 1 and DLT_RAW = 12.

NGM_CHECKSUM_GETDLT (getdlt)
    This control message obtains the data link type on the in hook.

NGM_CHECKSUM_SETCONFIG (setconfig)
    Sets the node configuration. The following struct ng_checksum_config must 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 a struct ng_checksum_config.

NGM_CHECKSUM_GET_STATS (getstats)
    Returns node statistics as a struct ng_checksum_stats.

NGM_CHECKSUM_CLR_STATS (clrstats)
    Clear the node statistics.

NGM_CHECKSUM_GETCLR_STATS (getclrstats)
    This command is identical to NGM_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.

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.

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.

AUTHORS
Dmitry Vagin <daemon.hammer@ya.ru>.