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