1 .\" Copyright (c) 2015 Dmitry Vagin <daemon.hammer@ya.ru>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .Nd reconstructing IP checksums node type
34 .In netgraph/ng_checksum.h
38 node can calculate, or prepare for calculation in hardware,
39 IPv4 header, TCP and UDP checksums.
41 This node type has two hooks:
42 .Bl -tag -width ".Va out"
44 Packets received on this hook are processed according to settings specified
45 in config and then forwarded to the
47 hook, if it exists and is connected. Otherwise they are reflected back to the
51 Packets received on this hook are forwarded to the
53 hook without any changes.
56 This node type supports the generic control messages, plus the following:
58 .It Dv NGM_CHECKSUM_SETDLT Pq Ic setdlt
59 Sets the data link type on the
61 hook. Currently, supported types are
63 (raw IP datagrams) and
65 (Ethernet). DLT_ definitions can be found in the
67 header. Currently used values are
72 .It Dv NGM_CHECKSUM_GETDLT Pq Ic getdlt
73 This control message obtains the data link type on the
76 .It Dv NGM_CHECKSUM_SETCONFIG Pq Ic setconfig
77 Sets the node configuration. The following
78 .Vt "struct ng_checksum_config"
79 must be supplied as an argument:
80 .Bd -literal -offset 4n
81 struct ng_checksum_config {
83 uint64_t csum_offload;
89 can be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6
90 (other values are ignored) for instructing the node to calculate the corresponding checksum.
94 value can be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6
95 (other values are ignored) for instructing the node what checksums should be requested from the hardware.
97 The node also takes into account any combination of
98 CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6 already
100 .It Dv NGM_CHECKSUM_GETCONFIG Pq Ic getconfig
101 This control message obtains the current node configuration returned as a
102 .Vt "struct ng_checksum_config" .
103 .It Dv NGM_CHECKSUM_GET_STATS Pq Ic getstats
104 Returns node statistics as a
105 .Vt "struct ng_checksum_stats" .
106 .It Dv NGM_CHECKSUM_CLR_STATS Pq Ic clrstats
107 Clear the node statistics.
108 .It Dv NGM_CHECKSUM_GETCLR_STATS Pq Ic getclrstats
109 This command is identical to
110 .Dv NGM_CHECKSUM_GET_STATS ,
111 except that the statistics are also atomically cleared.
114 This node shuts down upon receipt of a
116 control message, or when all hooks have been disconnected.
120 .Bd -literal -offset 4n
121 /usr/sbin/ngctl -f- <<-SEQ
122 msg checksum-1: setdlt 1
123 msg checksum-1: setconfig { csum_flags=0 csum_offload=6 }
127 Set the data link type to
129 (Ethernet), do not set additional checksum flags
130 and request that the hardware calculate CSUM_IP_UDP|CSUM_IP_TCP.
138 node type was implemented in
140 and first submitted in
143 .An "Dmitry Vagin" Aq daemon.hammer@ya.ru .