1c604c876SGleb Smirnoff.\" Copyright (c) 2005 Gleb Smirnoff 2c604c876SGleb Smirnoff.\" All rights reserved. 3c604c876SGleb Smirnoff.\" 4c604c876SGleb Smirnoff.\" Redistribution and use in source and binary forms, with or without 5c604c876SGleb Smirnoff.\" modification, are permitted provided that the following conditions 6c604c876SGleb Smirnoff.\" are met: 7c604c876SGleb Smirnoff.\" 1. Redistributions of source code must retain the above copyright 8c604c876SGleb Smirnoff.\" notice, this list of conditions and the following disclaimer. 9c604c876SGleb Smirnoff.\" 2. Redistributions in binary form must reproduce the above copyright 10c604c876SGleb Smirnoff.\" notice, this list of conditions and the following disclaimer in the 11c604c876SGleb Smirnoff.\" documentation and/or other materials provided with the distribution. 12c604c876SGleb Smirnoff.\" 13c604c876SGleb Smirnoff.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14c604c876SGleb Smirnoff.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15c604c876SGleb Smirnoff.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16c604c876SGleb Smirnoff.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17c604c876SGleb Smirnoff.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18c604c876SGleb Smirnoff.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19c604c876SGleb Smirnoff.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20c604c876SGleb Smirnoff.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21c604c876SGleb Smirnoff.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22c604c876SGleb Smirnoff.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23c604c876SGleb Smirnoff.\" SUCH DAMAGE. 24c604c876SGleb Smirnoff.\" 25c604c876SGleb Smirnoff.Dd June 9, 2005 26c604c876SGleb Smirnoff.Dt NG_TCPMSS 4 27c604c876SGleb Smirnoff.Os 28c604c876SGleb Smirnoff.Sh NAME 29c604c876SGleb Smirnoff.Nm ng_tcpmss 30a4be0b3cSRuslan Ermilov.Nd "netgraph node to adjust TCP MSS option" 31c604c876SGleb Smirnoff.Sh SYNOPSIS 32a4be0b3cSRuslan Ermilov.In netgraph.h 33c604c876SGleb Smirnoff.In netgraph/ng_tcpmss.h 34c604c876SGleb Smirnoff.Sh DESCRIPTION 35c604c876SGleb SmirnoffThe 36c604c876SGleb Smirnoff.Nm tcpmss 37c604c876SGleb Smirnoffnode type is designed to alter the Maximum Segment Size option 38c604c876SGleb Smirnoffof TCP packets. 39c604c876SGleb SmirnoffThis node accepts an arbitrary number of hooks. 40c604c876SGleb SmirnoffInitially a new hook is considered unconfigured. 41a4be0b3cSRuslan ErmilovThe 42c604c876SGleb Smirnoff.Dv NG_TCPMSS_CONFIG 43a4be0b3cSRuslan Ermilovcontrol message is used to configure a hook. 44c604c876SGleb Smirnoff.Sh CONTROL MESSAGES 45c604c876SGleb SmirnoffThis node type supports the generic control messages, plus the following. 46c60bda17SJoel Dahl.Bl -tag -width foo 47c60bda17SJoel Dahl.It Dv NGM_TCPMSS_CONFIG Pq Ic config 48c604c876SGleb SmirnoffThis control message configures node to do given MSS adjusting on 49a4be0b3cSRuslan Ermilova particular hook. 50c604c876SGleb SmirnoffIt requires the 51c604c876SGleb Smirnoff.Vt "struct ng_tcpmss_config" 52a4be0b3cSRuslan Ermilovto be supplied as an argument: 53c604c876SGleb Smirnoff.Bd -literal 54c604c876SGleb Smirnoffstruct ng_tcpmss_config { 55c604c876SGleb Smirnoff char inHook[NG_HOOKSIZ]; 56c604c876SGleb Smirnoff char outHook[NG_HOOKSIZ]; 57c604c876SGleb Smirnoff uint16_t maxMSS; 58c604c876SGleb Smirnoff} 59c604c876SGleb Smirnoff.Ed 60c604c876SGleb Smirnoff.Pp 61c604c876SGleb SmirnoffThis means: packets received on 62a4be0b3cSRuslan Ermilov.Va inHook 63c604c876SGleb Smirnoffwould be checked for TCP MSS option and the latter would be 64c604c876SGleb Smirnoffreduced down to 65a4be0b3cSRuslan Ermilov.Va maxMSS 66c604c876SGleb Smirnoffif it exceeds 67a4be0b3cSRuslan Ermilov.Va maxMSS . 68a4be0b3cSRuslan ErmilovAfter that, packets would be sent to hook 69a4be0b3cSRuslan Ermilov.Va outHook . 70c60bda17SJoel Dahl.It Dv NGM_TCPMSS_GET_STATS Pq Ic getstats 71a4be0b3cSRuslan ErmilovThis control message obtains statistics for a given hook. 72c604c876SGleb SmirnoffThe statistics are returned in 73c604c876SGleb Smirnoff.Vt "struct ng_tcpmss_hookstat" : 74c604c876SGleb Smirnoff.Bd -literal 75c604c876SGleb Smirnoffstruct ng_tcpmss_hookstat { 76c604c876SGleb Smirnoff uint64_t Octets; /* total bytes */ 77c604c876SGleb Smirnoff uint64_t Packets; /* total packets */ 78c604c876SGleb Smirnoff uint16_t maxMSS; /* maximum MSS */ 79c604c876SGleb Smirnoff uint64_t SYNPkts; /* TCP SYN packets */ 80c604c876SGleb Smirnoff uint64_t FixedPkts; /* changed packets */ 81c604c876SGleb Smirnoff}; 82c604c876SGleb Smirnoff.Ed 83c60bda17SJoel Dahl.It Dv NGM_TCPMSS_CLR_STATS Pq Ic clrstats 84a4be0b3cSRuslan ErmilovThis control message clears statistics for a given hook. 85c60bda17SJoel Dahl.It Dv NGM_TCPMSS_GETCLR_STATS Pq Ic getclrstats 86a4be0b3cSRuslan ErmilovThis control message obtains and clears statistics for a given hook. 87c604c876SGleb Smirnoff.El 88c604c876SGleb Smirnoff.Sh EXAMPLES 89a4be0b3cSRuslan ErmilovIn the following example, packets are injected into the 90a4be0b3cSRuslan Ermilov.Nm tcpmss 91a4be0b3cSRuslan Ermilovnode using the 92c604c876SGleb Smirnoff.Xr ng_ipfw 4 93c604c876SGleb Smirnoffnode. 94c604c876SGleb Smirnoff.Bd -literal -offset indent 95c604c876SGleb Smirnoff# Create tcpmss node and connect it to ng_ipfw node 96c604c876SGleb Smirnoffngctl mkpeer ipfw: tcpmss 100 qqq 97c604c876SGleb Smirnoff 98c604c876SGleb Smirnoff# Adjust MSS to 1452 99c604c876SGleb Smirnoffngctl msg ipfw:100 config '{ inHook="qqq" outHook="qqq" maxMSS=1452 }' 100c604c876SGleb Smirnoff 101c604c876SGleb Smirnoff# Divert traffic into tcpmss node 102c604c876SGleb Smirnoffipfw add 300 netgraph 100 tcp from any to any tcpflags syn out via fxp0 103c604c876SGleb Smirnoff 104c604c876SGleb Smirnoff# Let packets continue with ipfw after being hacked 105c604c876SGleb Smirnoffsysctl net.inet.ip.fw.one_pass=0 106c604c876SGleb Smirnoff.Ed 107c604c876SGleb Smirnoff.Sh SHUTDOWN 108c604c876SGleb SmirnoffThis node shuts down upon receipt of an 109c604c876SGleb Smirnoff.Dv NGM_SHUTDOWN 110c604c876SGleb Smirnoffcontrol message, or when all hooks have been disconnected. 111c604c876SGleb Smirnoff.Sh SEE ALSO 112c604c876SGleb Smirnoff.Xr netgraph 4 , 113c604c876SGleb Smirnoff.Xr ng_ipfw 4 114c604c876SGleb Smirnoff.Sh HISTORY 115c604c876SGleb SmirnoffThe 116c604c876SGleb Smirnoff.Nm 117c604c876SGleb Smirnoffnode type was implemented in 118c604c876SGleb Smirnoff.Fx 6.0 . 119c604c876SGleb Smirnoff.Sh AUTHORS 120*6c899950SBaptiste Daroussin.An Alexey Popov Aq Mt lollypop@flexuser.ru 121*6c899950SBaptiste Daroussin.An Gleb Smirnoff Aq Mt glebius@FreeBSD.org 122c604c876SGleb Smirnoff.Sh BUGS 123a4be0b3cSRuslan ErmilovWhen running on SMP, system statistics may be broken. 124