xref: /freebsd/share/man/man4/ng_checksum.4 (revision 4e0973df9c02d330e6cb825af91b3c98a09b89ba)
15a31465dSJulian Elischer.\" Copyright (c) 2015 Dmitry Vagin <daemon.hammer@ya.ru>
25a31465dSJulian Elischer.\" All rights reserved.
35a31465dSJulian Elischer.\"
45a31465dSJulian Elischer.\" Redistribution and use in source and binary forms, with or without
55a31465dSJulian Elischer.\" modification, are permitted provided that the following conditions
65a31465dSJulian Elischer.\" are met:
75a31465dSJulian Elischer.\" 1. Redistributions of source code must retain the above copyright
85a31465dSJulian Elischer.\"    notice, this list of conditions and the following disclaimer.
95a31465dSJulian Elischer.\" 2. Redistributions in binary form must reproduce the above copyright
105a31465dSJulian Elischer.\"    notice, this list of conditions and the following disclaimer in the
115a31465dSJulian Elischer.\"    documentation and/or other materials provided with the distribution.
125a31465dSJulian Elischer.\"
135a31465dSJulian Elischer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
145a31465dSJulian Elischer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
155a31465dSJulian Elischer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
165a31465dSJulian Elischer.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
175a31465dSJulian Elischer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
185a31465dSJulian Elischer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
195a31465dSJulian Elischer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
205a31465dSJulian Elischer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
215a31465dSJulian Elischer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
225a31465dSJulian Elischer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
235a31465dSJulian Elischer.\" SUCH DAMAGE.
245a31465dSJulian Elischer.\"
255a31465dSJulian Elischer.\" $FreeBSD$
265a31465dSJulian Elischer.\"
275a31465dSJulian Elischer.Dd October 29, 2015
285a31465dSJulian Elischer.Dt NG_CHECKSUM 4
295a31465dSJulian Elischer.Os
305a31465dSJulian Elischer.Sh NAME
315a31465dSJulian Elischer.Nm ng_checksum
32*4e0973dfSJulian Elischer.Nd reconstructing IP checksums node type
335a31465dSJulian Elischer.Sh SYNOPSIS
345a31465dSJulian Elischer.In netgraph/ng_checksum.h
355a31465dSJulian Elischer.Sh DESCRIPTION
365a31465dSJulian ElischerThe
375a31465dSJulian Elischer.Nm checksum
38*4e0973dfSJulian Elischernode can calculate, or prepare for calculation in hardware,
39*4e0973dfSJulian ElischerIPv4 header, TCP and UDP checksums.
405a31465dSJulian Elischer.Sh HOOKS
415a31465dSJulian ElischerThis node type has two hooks:
425a31465dSJulian Elischer.Bl -tag -width ".Va out"
435a31465dSJulian Elischer.It Va in
445a31465dSJulian ElischerPackets received on this hook are processed according to settings specified
45*4e0973dfSJulian Elischerin config and then forwarded to the
465a31465dSJulian Elischer.Ar out
47*4e0973dfSJulian Elischerhook, if it exists and is connected. Otherwise they are reflected back to the
485a31465dSJulian Elischer.Ar in
495a31465dSJulian Elischerhook.
505a31465dSJulian Elischer.It Va out
51*4e0973dfSJulian ElischerPackets received on this hook are forwarded to the
525a31465dSJulian Elischer.Ar in
535a31465dSJulian Elischerhook without any changes.
545a31465dSJulian Elischer.El
555a31465dSJulian Elischer.Sh CONTROL MESSAGES
565a31465dSJulian ElischerThis node type supports the generic control messages, plus the following:
575a31465dSJulian Elischer.Bl -tag -width foo
585a31465dSJulian Elischer.It Dv NGM_CHECKSUM_SETDLT Pq Ic setdlt
59*4e0973dfSJulian ElischerSets the data link type on the
605a31465dSJulian Elischer.Va in
615a31465dSJulian Elischerhook. Currently, supported types are
625a31465dSJulian Elischer.Cm DLT_RAW
635a31465dSJulian Elischer(raw IP datagrams) and
645a31465dSJulian Elischer.Cm DLT_EN10MB
65*4e0973dfSJulian Elischer(Ethernet). DLT_ definitions can be found in the
665a31465dSJulian Elischer.In net/bpf.h
675a31465dSJulian Elischerheader. Currently used values are
685a31465dSJulian Elischer.Cm DLT_EN10MB
695a31465dSJulian Elischer= 1 and
705a31465dSJulian Elischer.Cm DLT_RAW
715a31465dSJulian Elischer= 12.
725a31465dSJulian Elischer.It Dv NGM_CHECKSUM_GETDLT Pq Ic getdlt
73*4e0973dfSJulian ElischerThis control message obtains the data link type on the
745a31465dSJulian Elischer.Va in
755a31465dSJulian Elischerhook.
765a31465dSJulian Elischer.It Dv NGM_CHECKSUM_SETCONFIG Pq Ic setconfig
77*4e0973dfSJulian ElischerSets the node configuration. The following
785a31465dSJulian Elischer.Vt "struct ng_checksum_config"
795a31465dSJulian Elischermust be supplied as an argument:
805a31465dSJulian Elischer.Bd -literal -offset 4n
815a31465dSJulian Elischerstruct ng_checksum_config {
825a31465dSJulian Elischer	uint64_t	csum_flags;
835a31465dSJulian Elischer	uint64_t	csum_offload;
845a31465dSJulian Elischer};
855a31465dSJulian Elischer.Ed
865a31465dSJulian Elischer.Pp
875a31465dSJulian ElischerThe
885a31465dSJulian Elischer.Va csum_flags
895a31465dSJulian Elischercan be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6
90*4e0973dfSJulian Elischer(other values are ignored) for instructing the node to calculate the corresponding checksum.
915a31465dSJulian Elischer.Pp
925a31465dSJulian ElischerThe
935a31465dSJulian Elischer.Va csum_offload
94*4e0973dfSJulian Elischervalue can be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6
95*4e0973dfSJulian Elischer(other values are ignored) for instructing the node what checksums should be requested from the hardware.
965a31465dSJulian Elischer.Pp
97*4e0973dfSJulian ElischerThe node also takes into account any combination of
98*4e0973dfSJulian ElischerCSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6 already
99*4e0973dfSJulian Elischerflagged on the mbuf.
1005a31465dSJulian Elischer.It Dv NGM_CHECKSUM_GETCONFIG Pq Ic getconfig
101*4e0973dfSJulian ElischerThis control message obtains the current node configuration returned as a
1025a31465dSJulian Elischer.Vt "struct ng_checksum_config" .
1035a31465dSJulian Elischer.It Dv NGM_CHECKSUM_GET_STATS Pq Ic getstats
1045a31465dSJulian ElischerReturns node statistics as a
1055a31465dSJulian Elischer.Vt "struct ng_checksum_stats" .
1065a31465dSJulian Elischer.It Dv NGM_CHECKSUM_CLR_STATS Pq Ic clrstats
107*4e0973dfSJulian ElischerClear the node statistics.
1085a31465dSJulian Elischer.It Dv NGM_CHECKSUM_GETCLR_STATS Pq Ic getclrstats
1095a31465dSJulian ElischerThis command is identical to
1105a31465dSJulian Elischer.Dv NGM_CHECKSUM_GET_STATS ,
1115a31465dSJulian Elischerexcept that the statistics are also atomically cleared.
1125a31465dSJulian Elischer.El
1135a31465dSJulian Elischer.Sh SHUTDOWN
1145a31465dSJulian ElischerThis node shuts down upon receipt of a
1155a31465dSJulian Elischer.Dv NGM_SHUTDOWN
1165a31465dSJulian Elischercontrol message, or when all hooks have been disconnected.
1175a31465dSJulian Elischer.Sh EXAMPLES
1185a31465dSJulian Elischer.Xr ngctl 8
1195a31465dSJulian Elischerscript:
1205a31465dSJulian Elischer.Bd -literal -offset 4n
1215a31465dSJulian Elischer/usr/sbin/ngctl -f- <<-SEQ
122*4e0973dfSJulian Elischer	msg checksum-1: setdlt 1
123*4e0973dfSJulian Elischer	msg checksum-1: setconfig { csum_flags=0 csum_offload=6 }
124*4e0973dfSJulian ElischerSEQ
1255a31465dSJulian Elischer.Ed
1265a31465dSJulian Elischer.Pp
127*4e0973dfSJulian ElischerSet the data link type to
1285a31465dSJulian Elischer.Cm DLT_EN10MB
129*4e0973dfSJulian Elischer(Ethernet), do not set additional checksum flags
130*4e0973dfSJulian Elischerand request that the hardware calculate CSUM_IP_UDP|CSUM_IP_TCP.
1315a31465dSJulian Elischer.Sh SEE ALSO
1325a31465dSJulian Elischer.Xr netgraph 4 ,
1335a31465dSJulian Elischer.Xr ng_patch 4 ,
1345a31465dSJulian Elischer.Xr ngctl 8
1355a31465dSJulian Elischer.Sh HISTORY
1365a31465dSJulian ElischerThe
1375a31465dSJulian Elischer.Nm
1385a31465dSJulian Elischernode type was implemented in
1395a31465dSJulian Elischer.Fx 10.2
1405a31465dSJulian Elischerand first submitted in
1415a31465dSJulian Elischer.Fx 12.0 .
1425a31465dSJulian Elischer.Sh AUTHORS
1435a31465dSJulian Elischer.An "Dmitry Vagin" Aq daemon.hammer@ya.ru .
144