---
name: "ng_checksum"
section: "4"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/ng_checksum"
---

# ng\_checksum(4)

IPv4/TCP/UDP checksum reconstructing netgraph node

## NAME

**ng\_checksum** – IPv4/TCP/UDP checksum reconstructing netgraph node

## 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)](/ngctl/8.md) 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)](/netgraph/4.md), [ng\_patch(4)](/ng_patch/4.md), [ngctl(8)](/ngctl/8.md)

## 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*⟩.
