xref: /freebsd/share/man/man4/ng_checksum.4 (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1.\" Copyright (c) 2015 Dmitry Vagin <daemon.hammer@ya.ru>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
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.
12.\"
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
23.\" SUCH DAMAGE.
24.\"
25.Dd October 29, 2015
26.Dt NG_CHECKSUM 4
27.Os
28.Sh NAME
29.Nm ng_checksum
30.Nd reconstructing IP checksums node type
31.Sh SYNOPSIS
32.In netgraph/ng_checksum.h
33.Sh DESCRIPTION
34The
35.Nm checksum
36node can calculate, or prepare for calculation in hardware,
37IPv4 header, TCP and UDP checksums.
38.Sh HOOKS
39This node type has two hooks:
40.Bl -tag -width ".Va out"
41.It Va in
42Packets received on this hook are processed according to settings specified
43in config and then forwarded to the
44.Ar out
45hook, if it exists and is connected.
46Otherwise they are reflected back to the
47.Ar in
48hook.
49.It Va out
50Packets received on this hook are forwarded to the
51.Ar in
52hook without any changes.
53.El
54.Sh CONTROL MESSAGES
55This node type supports the generic control messages, plus the following:
56.Bl -tag -width foo
57.It Dv NGM_CHECKSUM_SETDLT Pq Ic setdlt
58Sets the data link type on the
59.Va in
60hook.
61Currently, supported types are
62.Cm DLT_RAW
63(raw IP datagrams) and
64.Cm DLT_EN10MB
65(Ethernet). DLT_ definitions can be found in the
66.In net/bpf.h
67header.
68Currently used values are
69.Cm DLT_EN10MB
70= 1 and
71.Cm DLT_RAW
72= 12.
73.It Dv NGM_CHECKSUM_GETDLT Pq Ic getdlt
74This control message obtains the data link type on the
75.Va in
76hook.
77.It Dv NGM_CHECKSUM_SETCONFIG Pq Ic setconfig
78Sets the node configuration.
79The following
80.Vt "struct ng_checksum_config"
81must be supplied as an argument:
82.Bd -literal -offset 4n
83struct ng_checksum_config {
84	uint64_t	csum_flags;
85	uint64_t	csum_offload;
86};
87.Ed
88.Pp
89The
90.Va csum_flags
91can be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6
92(other values are ignored) for instructing the node to calculate the corresponding checksum.
93.Pp
94The
95.Va csum_offload
96value can be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6
97(other values are ignored) for instructing the node what checksums should be requested from the hardware.
98.Pp
99The node also takes into account any combination of
100CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6 already
101flagged on the mbuf.
102.It Dv NGM_CHECKSUM_GETCONFIG Pq Ic getconfig
103This control message obtains the current node configuration returned as a
104.Vt "struct ng_checksum_config" .
105.It Dv NGM_CHECKSUM_GET_STATS Pq Ic getstats
106Returns node statistics as a
107.Vt "struct ng_checksum_stats" .
108.It Dv NGM_CHECKSUM_CLR_STATS Pq Ic clrstats
109Clear the node statistics.
110.It Dv NGM_CHECKSUM_GETCLR_STATS Pq Ic getclrstats
111This command is identical to
112.Dv NGM_CHECKSUM_GET_STATS ,
113except that the statistics are also atomically cleared.
114.El
115.Sh SHUTDOWN
116This node shuts down upon receipt of a
117.Dv NGM_SHUTDOWN
118control message, or when all hooks have been disconnected.
119.Sh EXAMPLES
120.Xr ngctl 8
121script:
122.Bd -literal -offset 4n
123/usr/sbin/ngctl -f- <<-SEQ
124	msg checksum-1: setdlt 1
125	msg checksum-1: setconfig { csum_flags=0 csum_offload=6 }
126SEQ
127.Ed
128.Pp
129Set the data link type to
130.Cm DLT_EN10MB
131(Ethernet), do not set additional checksum flags
132and request that the hardware calculate CSUM_IP_UDP|CSUM_IP_TCP.
133.Sh SEE ALSO
134.Xr netgraph 4 ,
135.Xr ng_patch 4 ,
136.Xr ngctl 8
137.Sh HISTORY
138The
139.Nm
140node type was implemented in
141.Fx 10.2
142and first submitted in
143.Fx 12.0 .
144.Sh AUTHORS
145.An "Dmitry Vagin" Aq daemon.hammer@ya.ru .
146