xref: /freebsd/share/man/man4/ng_checksum.4 (revision 5a31465d50caddf43ed410e4b846c2c559fc259d)
1*5a31465dSJulian Elischer.\" Copyright (c) 2015 Dmitry Vagin <daemon.hammer@ya.ru>
2*5a31465dSJulian Elischer.\" All rights reserved.
3*5a31465dSJulian Elischer.\"
4*5a31465dSJulian Elischer.\" Redistribution and use in source and binary forms, with or without
5*5a31465dSJulian Elischer.\" modification, are permitted provided that the following conditions
6*5a31465dSJulian Elischer.\" are met:
7*5a31465dSJulian Elischer.\" 1. Redistributions of source code must retain the above copyright
8*5a31465dSJulian Elischer.\"    notice, this list of conditions and the following disclaimer.
9*5a31465dSJulian Elischer.\" 2. Redistributions in binary form must reproduce the above copyright
10*5a31465dSJulian Elischer.\"    notice, this list of conditions and the following disclaimer in the
11*5a31465dSJulian Elischer.\"    documentation and/or other materials provided with the distribution.
12*5a31465dSJulian Elischer.\"
13*5a31465dSJulian Elischer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14*5a31465dSJulian Elischer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15*5a31465dSJulian Elischer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16*5a31465dSJulian Elischer.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17*5a31465dSJulian Elischer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18*5a31465dSJulian Elischer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19*5a31465dSJulian Elischer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20*5a31465dSJulian Elischer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21*5a31465dSJulian Elischer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22*5a31465dSJulian Elischer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23*5a31465dSJulian Elischer.\" SUCH DAMAGE.
24*5a31465dSJulian Elischer.\"
25*5a31465dSJulian Elischer.\" $FreeBSD$
26*5a31465dSJulian Elischer.\"
27*5a31465dSJulian Elischer.Dd October 29, 2015
28*5a31465dSJulian Elischer.Dt NG_CHECKSUM 4
29*5a31465dSJulian Elischer.Os
30*5a31465dSJulian Elischer.Sh NAME
31*5a31465dSJulian Elischer.Nm ng_checksum
32*5a31465dSJulian Elischer.Nd IP checksum node type
33*5a31465dSJulian Elischer.Sh SYNOPSIS
34*5a31465dSJulian Elischer.In netgraph/ng_checksum.h
35*5a31465dSJulian Elischer.Sh DESCRIPTION
36*5a31465dSJulian ElischerThe
37*5a31465dSJulian Elischer.Nm checksum
38*5a31465dSJulian Elischernode can calculate and prepare for calculation in hardware
39*5a31465dSJulian ElischerIPv4 header, TCP, UDP checksum.
40*5a31465dSJulian Elischer.Sh HOOKS
41*5a31465dSJulian ElischerThis node type has two hooks:
42*5a31465dSJulian Elischer.Bl -tag -width ".Va out"
43*5a31465dSJulian Elischer.It Va in
44*5a31465dSJulian ElischerPackets received on this hook are processed according to settings specified
45*5a31465dSJulian Elischerin config and then forwarded to
46*5a31465dSJulian Elischer.Ar out
47*5a31465dSJulian Elischerhook, if it exists and connected. Otherwise they are reflected back to the
48*5a31465dSJulian Elischer.Ar in
49*5a31465dSJulian Elischerhook.
50*5a31465dSJulian Elischer.It Va out
51*5a31465dSJulian ElischerPackets received on this hook are forwarded to
52*5a31465dSJulian Elischer.Ar in
53*5a31465dSJulian Elischerhook without any changes.
54*5a31465dSJulian Elischer.El
55*5a31465dSJulian Elischer.Sh CONTROL MESSAGES
56*5a31465dSJulian ElischerThis node type supports the generic control messages, plus the following:
57*5a31465dSJulian Elischer.Bl -tag -width foo
58*5a31465dSJulian Elischer.It Dv NGM_CHECKSUM_SETDLT Pq Ic setdlt
59*5a31465dSJulian ElischerSets data link type on the
60*5a31465dSJulian Elischer.Va in
61*5a31465dSJulian Elischerhook. Currently, supported types are
62*5a31465dSJulian Elischer.Cm DLT_RAW
63*5a31465dSJulian Elischer(raw IP datagrams) and
64*5a31465dSJulian Elischer.Cm DLT_EN10MB
65*5a31465dSJulian Elischer(Ethernet). DLT_ definitions can be found in
66*5a31465dSJulian Elischer.In net/bpf.h
67*5a31465dSJulian Elischerheader. Currently used values are
68*5a31465dSJulian Elischer.Cm DLT_EN10MB
69*5a31465dSJulian Elischer= 1 and
70*5a31465dSJulian Elischer.Cm DLT_RAW
71*5a31465dSJulian Elischer= 12.
72*5a31465dSJulian Elischer.It Dv NGM_CHECKSUM_GETDLT Pq Ic getdlt
73*5a31465dSJulian ElischerThis control message obtains data link type on the
74*5a31465dSJulian Elischer.Va in
75*5a31465dSJulian Elischerhook.
76*5a31465dSJulian Elischer.It Dv NGM_CHECKSUM_SETCONFIG Pq Ic setconfig
77*5a31465dSJulian ElischerSets node configuration. The following
78*5a31465dSJulian Elischer.Vt "struct ng_checksum_config"
79*5a31465dSJulian Elischermust be supplied as an argument:
80*5a31465dSJulian Elischer.Bd -literal -offset 4n
81*5a31465dSJulian Elischerstruct ng_checksum_config {
82*5a31465dSJulian Elischer	uint64_t	csum_flags;
83*5a31465dSJulian Elischer	uint64_t	csum_offload;
84*5a31465dSJulian Elischer};
85*5a31465dSJulian Elischer.Ed
86*5a31465dSJulian Elischer.Pp
87*5a31465dSJulian ElischerThe
88*5a31465dSJulian Elischer.Va csum_flags
89*5a31465dSJulian Elischercan be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6
90*5a31465dSJulian Elischer(other values are ignored) for instructing node need calculate the corresponding checksum.
91*5a31465dSJulian Elischer.Pp
92*5a31465dSJulian ElischerThe
93*5a31465dSJulian Elischer.Va csum_offload
94*5a31465dSJulian Elischercan be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6
95*5a31465dSJulian Elischer(other values are ignored) for instructing node what checksum can calculate in hardware.
96*5a31465dSJulian Elischer.Pp
97*5a31465dSJulian ElischerAlso processed any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6 sets before on mbuf.
98*5a31465dSJulian Elischer.It Dv NGM_CHECKSUM_GETCONFIG Pq Ic getconfig
99*5a31465dSJulian ElischerThis control message obtains current node configuration,
100*5a31465dSJulian Elischerreturned as
101*5a31465dSJulian Elischer.Vt "struct ng_checksum_config" .
102*5a31465dSJulian Elischer.It Dv NGM_CHECKSUM_GET_STATS Pq Ic getstats
103*5a31465dSJulian ElischerReturns node statistics as a
104*5a31465dSJulian Elischer.Vt "struct ng_checksum_stats" .
105*5a31465dSJulian Elischer.It Dv NGM_CHECKSUM_CLR_STATS Pq Ic clrstats
106*5a31465dSJulian ElischerClear node statistics.
107*5a31465dSJulian Elischer.It Dv NGM_CHECKSUM_GETCLR_STATS Pq Ic getclrstats
108*5a31465dSJulian ElischerThis command is identical to
109*5a31465dSJulian Elischer.Dv NGM_CHECKSUM_GET_STATS ,
110*5a31465dSJulian Elischerexcept that the statistics are also atomically cleared.
111*5a31465dSJulian Elischer.El
112*5a31465dSJulian Elischer.Sh SHUTDOWN
113*5a31465dSJulian ElischerThis node shuts down upon receipt of a
114*5a31465dSJulian Elischer.Dv NGM_SHUTDOWN
115*5a31465dSJulian Elischercontrol message, or when all hooks have been disconnected.
116*5a31465dSJulian Elischer.Sh EXAMPLES
117*5a31465dSJulian Elischer.Xr ngctl 8
118*5a31465dSJulian Elischerscript:
119*5a31465dSJulian Elischer.Bd -literal -offset 4n
120*5a31465dSJulian Elischer/usr/sbin/ngctl -f- <<-SEQ
121*5a31465dSJulian Elischer	msg checksum-1: "setdlt 1"
122*5a31465dSJulian Elischer	ngctl msg checksum-1: "setconfig { csum_flags=0 csum_offload=6 }"
123*5a31465dSJulian Elischer.Ed
124*5a31465dSJulian Elischer.Pp
125*5a31465dSJulian ElischerSet data link type to
126*5a31465dSJulian Elischer.Cm DLT_EN10MB
127*5a31465dSJulian Elischer(Ethernet), not set additional checksum flags, set hardware
128*5a31465dSJulian Elischercan calculate CSUM_IP_UDP|CSUM_IP_TCP.
129*5a31465dSJulian Elischer.Sh SEE ALSO
130*5a31465dSJulian Elischer.Xr netgraph 4 ,
131*5a31465dSJulian Elischer.Xr ng_patch 4 ,
132*5a31465dSJulian Elischer.Xr ngctl 8
133*5a31465dSJulian Elischer.Sh HISTORY
134*5a31465dSJulian ElischerThe
135*5a31465dSJulian Elischer.Nm
136*5a31465dSJulian Elischernode type was implemented in
137*5a31465dSJulian Elischer.Fx 10.2
138*5a31465dSJulian Elischerand first submitted in
139*5a31465dSJulian Elischer.Fx 12.0 .
140*5a31465dSJulian Elischer.Sh AUTHORS
141*5a31465dSJulian Elischer.An "Dmitry Vagin" Aq daemon.hammer@ya.ru .
142