5a31465d50
PR: 206186 Submitted by: Dmitry Vagin <daemon.hammer@ya.ru> MFC after: 1 month
142 lines
4.4 KiB
Groff
142 lines
4.4 KiB
Groff
.\" Copyright (c) 2015 Dmitry Vagin <daemon.hammer@ya.ru>
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
.\" SUCH DAMAGE.
|
|
.\"
|
|
.\" $FreeBSD$
|
|
.\"
|
|
.Dd October 29, 2015
|
|
.Dt NG_CHECKSUM 4
|
|
.Os
|
|
.Sh NAME
|
|
.Nm ng_checksum
|
|
.Nd IP checksum node type
|
|
.Sh SYNOPSIS
|
|
.In netgraph/ng_checksum.h
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Nm checksum
|
|
node can calculate and prepare for calculation in hardware
|
|
IPv4 header, TCP, UDP checksum.
|
|
.Sh HOOKS
|
|
This node type has two hooks:
|
|
.Bl -tag -width ".Va out"
|
|
.It Va in
|
|
Packets received on this hook are processed according to settings specified
|
|
in config and then forwarded to
|
|
.Ar out
|
|
hook, if it exists and connected. Otherwise they are reflected back to the
|
|
.Ar in
|
|
hook.
|
|
.It Va out
|
|
Packets received on this hook are forwarded to
|
|
.Ar in
|
|
hook without any changes.
|
|
.El
|
|
.Sh CONTROL MESSAGES
|
|
This node type supports the generic control messages, plus the following:
|
|
.Bl -tag -width foo
|
|
.It Dv NGM_CHECKSUM_SETDLT Pq Ic setdlt
|
|
Sets data link type on the
|
|
.Va in
|
|
hook. Currently, supported types are
|
|
.Cm DLT_RAW
|
|
(raw IP datagrams) and
|
|
.Cm DLT_EN10MB
|
|
(Ethernet). DLT_ definitions can be found in
|
|
.In net/bpf.h
|
|
header. Currently used values are
|
|
.Cm DLT_EN10MB
|
|
= 1 and
|
|
.Cm DLT_RAW
|
|
= 12.
|
|
.It Dv NGM_CHECKSUM_GETDLT Pq Ic getdlt
|
|
This control message obtains data link type on the
|
|
.Va in
|
|
hook.
|
|
.It Dv NGM_CHECKSUM_SETCONFIG Pq Ic setconfig
|
|
Sets node configuration. The following
|
|
.Vt "struct ng_checksum_config"
|
|
must be supplied as an argument:
|
|
.Bd -literal -offset 4n
|
|
struct ng_checksum_config {
|
|
uint64_t csum_flags;
|
|
uint64_t csum_offload;
|
|
};
|
|
.Ed
|
|
.Pp
|
|
The
|
|
.Va csum_flags
|
|
can be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6
|
|
(other values are ignored) for instructing node need calculate the corresponding checksum.
|
|
.Pp
|
|
The
|
|
.Va csum_offload
|
|
can be set to any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6
|
|
(other values are ignored) for instructing node what checksum can calculate in hardware.
|
|
.Pp
|
|
Also processed any combination of CSUM_IP, CSUM_TCP, CSUM_UDP, CSUM_TCP_IPV6 and CSUM_UDP_IPV6 sets before on mbuf.
|
|
.It Dv NGM_CHECKSUM_GETCONFIG Pq Ic getconfig
|
|
This control message obtains current node configuration,
|
|
returned as
|
|
.Vt "struct ng_checksum_config" .
|
|
.It Dv NGM_CHECKSUM_GET_STATS Pq Ic getstats
|
|
Returns node statistics as a
|
|
.Vt "struct ng_checksum_stats" .
|
|
.It Dv NGM_CHECKSUM_CLR_STATS Pq Ic clrstats
|
|
Clear node statistics.
|
|
.It Dv NGM_CHECKSUM_GETCLR_STATS Pq Ic getclrstats
|
|
This command is identical to
|
|
.Dv NGM_CHECKSUM_GET_STATS ,
|
|
except that the statistics are also atomically cleared.
|
|
.El
|
|
.Sh SHUTDOWN
|
|
This node shuts down upon receipt of a
|
|
.Dv NGM_SHUTDOWN
|
|
control message, or when all hooks have been disconnected.
|
|
.Sh EXAMPLES
|
|
.Xr ngctl 8
|
|
script:
|
|
.Bd -literal -offset 4n
|
|
/usr/sbin/ngctl -f- <<-SEQ
|
|
msg checksum-1: "setdlt 1"
|
|
ngctl msg checksum-1: "setconfig { csum_flags=0 csum_offload=6 }"
|
|
.Ed
|
|
.Pp
|
|
Set data link type to
|
|
.Cm DLT_EN10MB
|
|
(Ethernet), not set additional checksum flags, set hardware
|
|
can calculate CSUM_IP_UDP|CSUM_IP_TCP.
|
|
.Sh SEE ALSO
|
|
.Xr netgraph 4 ,
|
|
.Xr ng_patch 4 ,
|
|
.Xr ngctl 8
|
|
.Sh HISTORY
|
|
The
|
|
.Nm
|
|
node type was implemented in
|
|
.Fx 10.2
|
|
and first submitted in
|
|
.Fx 12.0 .
|
|
.Sh AUTHORS
|
|
.An "Dmitry Vagin" Aq daemon.hammer@ya.ru .
|