xref: /freebsd/share/man/man4/ng_checksum.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
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.Dd October 29, 2015
265a31465dSJulian Elischer.Dt NG_CHECKSUM 4
275a31465dSJulian Elischer.Os
285a31465dSJulian Elischer.Sh NAME
295a31465dSJulian Elischer.Nm ng_checksum
304e0973dfSJulian Elischer.Nd reconstructing IP checksums node type
315a31465dSJulian Elischer.Sh SYNOPSIS
325a31465dSJulian Elischer.In netgraph/ng_checksum.h
335a31465dSJulian Elischer.Sh DESCRIPTION
345a31465dSJulian ElischerThe
355a31465dSJulian Elischer.Nm checksum
364e0973dfSJulian Elischernode can calculate, or prepare for calculation in hardware,
374e0973dfSJulian ElischerIPv4 header, TCP and UDP checksums.
385a31465dSJulian Elischer.Sh HOOKS
395a31465dSJulian ElischerThis node type has two hooks:
405a31465dSJulian Elischer.Bl -tag -width ".Va out"
415a31465dSJulian Elischer.It Va in
425a31465dSJulian ElischerPackets received on this hook are processed according to settings specified
434e0973dfSJulian Elischerin config and then forwarded to the
445a31465dSJulian Elischer.Ar out
45*812b0903SGordon Berglinghook, if it exists and is connected.
46*812b0903SGordon BerglingOtherwise they are reflected back to the
475a31465dSJulian Elischer.Ar in
485a31465dSJulian Elischerhook.
495a31465dSJulian Elischer.It Va out
504e0973dfSJulian ElischerPackets received on this hook are forwarded to the
515a31465dSJulian Elischer.Ar in
525a31465dSJulian Elischerhook without any changes.
535a31465dSJulian Elischer.El
545a31465dSJulian Elischer.Sh CONTROL MESSAGES
555a31465dSJulian ElischerThis node type supports the generic control messages, plus the following:
565a31465dSJulian Elischer.Bl -tag -width foo
575a31465dSJulian Elischer.It Dv NGM_CHECKSUM_SETDLT Pq Ic setdlt
584e0973dfSJulian ElischerSets the data link type on the
595a31465dSJulian Elischer.Va in
60*812b0903SGordon Berglinghook.
61*812b0903SGordon BerglingCurrently, supported types are
625a31465dSJulian Elischer.Cm DLT_RAW
635a31465dSJulian Elischer(raw IP datagrams) and
645a31465dSJulian Elischer.Cm DLT_EN10MB
654e0973dfSJulian Elischer(Ethernet). DLT_ definitions can be found in the
665a31465dSJulian Elischer.In net/bpf.h
67*812b0903SGordon Berglingheader.
68*812b0903SGordon BerglingCurrently used values are
695a31465dSJulian Elischer.Cm DLT_EN10MB
705a31465dSJulian Elischer= 1 and
715a31465dSJulian Elischer.Cm DLT_RAW
725a31465dSJulian Elischer= 12.
735a31465dSJulian Elischer.It Dv NGM_CHECKSUM_GETDLT Pq Ic getdlt
744e0973dfSJulian ElischerThis control message obtains the data link type on the
755a31465dSJulian Elischer.Va in
765a31465dSJulian Elischerhook.
775a31465dSJulian Elischer.It Dv NGM_CHECKSUM_SETCONFIG Pq Ic setconfig
78*812b0903SGordon BerglingSets the node configuration.
79*812b0903SGordon BerglingThe following
805a31465dSJulian Elischer.Vt "struct ng_checksum_config"
815a31465dSJulian Elischermust be supplied as an argument:
825a31465dSJulian Elischer.Bd -literal -offset 4n
835a31465dSJulian Elischerstruct ng_checksum_config {
845a31465dSJulian Elischer	uint64_t	csum_flags;
855a31465dSJulian Elischer	uint64_t	csum_offload;
865a31465dSJulian Elischer};
875a31465dSJulian Elischer.Ed
885a31465dSJulian Elischer.Pp
895a31465dSJulian ElischerThe
905a31465dSJulian Elischer.Va csum_flags
915a31465dSJulian Elischercan be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6
924e0973dfSJulian Elischer(other values are ignored) for instructing the node to calculate the corresponding checksum.
935a31465dSJulian Elischer.Pp
945a31465dSJulian ElischerThe
955a31465dSJulian Elischer.Va csum_offload
964e0973dfSJulian Elischervalue can be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6
974e0973dfSJulian Elischer(other values are ignored) for instructing the node what checksums should be requested from the hardware.
985a31465dSJulian Elischer.Pp
994e0973dfSJulian ElischerThe node also takes into account any combination of
1004e0973dfSJulian ElischerCSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6 already
1014e0973dfSJulian Elischerflagged on the mbuf.
1025a31465dSJulian Elischer.It Dv NGM_CHECKSUM_GETCONFIG Pq Ic getconfig
1034e0973dfSJulian ElischerThis control message obtains the current node configuration returned as a
1045a31465dSJulian Elischer.Vt "struct ng_checksum_config" .
1055a31465dSJulian Elischer.It Dv NGM_CHECKSUM_GET_STATS Pq Ic getstats
1065a31465dSJulian ElischerReturns node statistics as a
1075a31465dSJulian Elischer.Vt "struct ng_checksum_stats" .
1085a31465dSJulian Elischer.It Dv NGM_CHECKSUM_CLR_STATS Pq Ic clrstats
1094e0973dfSJulian ElischerClear the node statistics.
1105a31465dSJulian Elischer.It Dv NGM_CHECKSUM_GETCLR_STATS Pq Ic getclrstats
1115a31465dSJulian ElischerThis command is identical to
1125a31465dSJulian Elischer.Dv NGM_CHECKSUM_GET_STATS ,
1135a31465dSJulian Elischerexcept that the statistics are also atomically cleared.
1145a31465dSJulian Elischer.El
1155a31465dSJulian Elischer.Sh SHUTDOWN
1165a31465dSJulian ElischerThis node shuts down upon receipt of a
1175a31465dSJulian Elischer.Dv NGM_SHUTDOWN
1185a31465dSJulian Elischercontrol message, or when all hooks have been disconnected.
1195a31465dSJulian Elischer.Sh EXAMPLES
1205a31465dSJulian Elischer.Xr ngctl 8
1215a31465dSJulian Elischerscript:
1225a31465dSJulian Elischer.Bd -literal -offset 4n
1235a31465dSJulian Elischer/usr/sbin/ngctl -f- <<-SEQ
1244e0973dfSJulian Elischer	msg checksum-1: setdlt 1
1254e0973dfSJulian Elischer	msg checksum-1: setconfig { csum_flags=0 csum_offload=6 }
1264e0973dfSJulian ElischerSEQ
1275a31465dSJulian Elischer.Ed
1285a31465dSJulian Elischer.Pp
1294e0973dfSJulian ElischerSet the data link type to
1305a31465dSJulian Elischer.Cm DLT_EN10MB
1314e0973dfSJulian Elischer(Ethernet), do not set additional checksum flags
1324e0973dfSJulian Elischerand request that the hardware calculate CSUM_IP_UDP|CSUM_IP_TCP.
1335a31465dSJulian Elischer.Sh SEE ALSO
1345a31465dSJulian Elischer.Xr netgraph 4 ,
1355a31465dSJulian Elischer.Xr ng_patch 4 ,
1365a31465dSJulian Elischer.Xr ngctl 8
1375a31465dSJulian Elischer.Sh HISTORY
1385a31465dSJulian ElischerThe
1395a31465dSJulian Elischer.Nm
1405a31465dSJulian Elischernode type was implemented in
1415a31465dSJulian Elischer.Fx 10.2
1425a31465dSJulian Elischerand first submitted in
1435a31465dSJulian Elischer.Fx 12.0 .
1445a31465dSJulian Elischer.Sh AUTHORS
1455a31465dSJulian Elischer.An "Dmitry Vagin" Aq daemon.hammer@ya.ru .
146