2001-10-30 07:28:17 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2001, FreeBSD Inc.
|
|
|
|
.\" 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 unmodified, 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.
|
|
|
|
.\"
|
2001-11-21 17:29:00 +00:00
|
|
|
.\" $FreeBSD$
|
2001-10-30 07:28:17 +00:00
|
|
|
.\"
|
2012-11-13 20:41:36 +00:00
|
|
|
.Dd November 13, 2012
|
2001-10-30 07:28:17 +00:00
|
|
|
.Dt NG_ETF 4
|
2001-11-21 17:29:00 +00:00
|
|
|
.Os
|
2001-10-30 07:28:17 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm ng_etf
|
|
|
|
.Nd Ethertype filtering netgraph node type
|
|
|
|
.Sh SYNOPSIS
|
2005-02-05 11:31:31 +00:00
|
|
|
.In netgraph.h
|
2001-11-21 17:29:00 +00:00
|
|
|
.In netgraph/ng_etf.h
|
2001-10-30 07:28:17 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm etf
|
|
|
|
node type multiplexes and filters data between hooks on the basis
|
2004-12-21 01:09:34 +00:00
|
|
|
of the ethertype found in an Ethernet header, presumed to be in the
|
2001-11-21 17:29:00 +00:00
|
|
|
first 14 bytes of the data.
|
|
|
|
Incoming Ethernet frames are accepted on the
|
2001-10-30 07:28:17 +00:00
|
|
|
.Em downstream
|
|
|
|
hook and if the ethertype matches a value which the node has been configured
|
|
|
|
to filter, the packet is forwarded out the hook which was identified
|
2001-11-21 17:29:00 +00:00
|
|
|
at the time that value was configured.
|
|
|
|
If it does not match a configured
|
|
|
|
value, it is passed to the
|
2001-10-30 07:28:17 +00:00
|
|
|
.Em nomatch
|
2001-11-21 17:29:00 +00:00
|
|
|
hook.
|
|
|
|
If the
|
2001-10-30 07:28:17 +00:00
|
|
|
.Em nomatch
|
|
|
|
hook is not connected, the packet is dropped.
|
|
|
|
.Pp
|
2001-11-21 17:29:00 +00:00
|
|
|
Packets travelling in the other direction (towards the
|
2001-10-30 07:28:17 +00:00
|
|
|
.Em downstream
|
|
|
|
hook) are also examined and filtered.
|
2001-11-21 17:29:00 +00:00
|
|
|
If a packet has an ethertype that matches one of the values configured
|
2001-10-30 07:28:17 +00:00
|
|
|
into the node, it must have arrived in on the hook for which that value
|
2001-11-21 17:29:00 +00:00
|
|
|
was configured, otherwise it will be discarded.
|
|
|
|
Ethertypes of values other
|
|
|
|
than those configured by the control messages must have arrived via the
|
2001-10-30 07:28:17 +00:00
|
|
|
.Em nomatch
|
|
|
|
hook.
|
|
|
|
.Sh HOOKS
|
|
|
|
This node type supports the following hooks:
|
2012-11-13 20:41:36 +00:00
|
|
|
.Bl -tag -width ".Aq Em any legal name"
|
2001-10-30 07:28:17 +00:00
|
|
|
.It Em downstream
|
|
|
|
Typically this hook would be connected to a
|
|
|
|
.Xr ng_ether 4
|
2001-11-21 17:29:00 +00:00
|
|
|
node, using the
|
2001-10-30 07:28:17 +00:00
|
|
|
.Em lower
|
|
|
|
hook.
|
|
|
|
.It Em nomatch
|
|
|
|
Typically this hook would also be connected to an
|
|
|
|
.Xr ng_ether 4
|
2001-11-21 17:29:00 +00:00
|
|
|
type node using the
|
2001-10-30 07:28:17 +00:00
|
|
|
.Em upper
|
|
|
|
hook.
|
2001-11-21 17:29:00 +00:00
|
|
|
.It Aq Em "any legal name"
|
2001-10-30 07:28:17 +00:00
|
|
|
Any other hook name will be accepted and can be used as the match target
|
2001-11-21 17:29:00 +00:00
|
|
|
of an ethertype.
|
|
|
|
Typically this hook would be attached to
|
2001-10-30 07:28:17 +00:00
|
|
|
a protocol handling node that requires and generates packets
|
|
|
|
with a particular set of ethertypes.
|
|
|
|
.El
|
|
|
|
.Sh CONTROL MESSAGES
|
|
|
|
This node type supports the generic control messages, plus the following:
|
2001-11-21 17:29:00 +00:00
|
|
|
.Bl -tag -width 4n
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Dv NGM_ETF_GET_STATUS Pq Ic getstatus
|
2001-10-30 07:28:17 +00:00
|
|
|
This command returns a
|
2001-11-21 17:29:00 +00:00
|
|
|
.Vt "struct ng_etfstat"
|
2001-10-30 07:28:17 +00:00
|
|
|
containing node statistics for packet counts.
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Dv NGM_ETF_SET_FILTER Pq Ic setfilter
|
2001-10-30 07:28:17 +00:00
|
|
|
Sets the a new ethertype filter into the node and specifies the hook to and
|
2001-11-21 17:29:00 +00:00
|
|
|
from which packets of that type should use.
|
|
|
|
The hook and ethertype
|
|
|
|
are specified in a structure of type
|
|
|
|
.Vt "struct ng_etffilter" :
|
2001-10-30 07:28:17 +00:00
|
|
|
.Bd -literal -offset 4n
|
|
|
|
struct ng_etffilter {
|
2012-11-13 20:41:36 +00:00
|
|
|
char matchhook[NG_HOOKSIZ]; /* hook name */
|
|
|
|
uint16_t ethertype; /* this ethertype to this hook */
|
2001-10-30 07:28:17 +00:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.El
|
|
|
|
.Sh EXAMPLES
|
2001-11-21 17:29:00 +00:00
|
|
|
Using
|
|
|
|
.Xr ngctl 8
|
|
|
|
it is possible to set a filter in place from the command line
|
2001-10-30 07:28:17 +00:00
|
|
|
as follows:
|
|
|
|
.Bd -literal -offset 4n
|
|
|
|
#!/bin/sh
|
2006-05-15 20:28:18 +00:00
|
|
|
ETHER_IF=fxp0
|
2001-10-30 07:28:17 +00:00
|
|
|
MATCH1=0x834
|
|
|
|
MATCH2=0x835
|
|
|
|
cat <<DONE >/tmp/xwert
|
2004-12-21 01:09:34 +00:00
|
|
|
# Make a new ethertype filter and attach to the Ethernet lower hook.
|
2001-10-30 07:28:17 +00:00
|
|
|
# first remove left over bits from last time.
|
2001-11-21 17:29:00 +00:00
|
|
|
shutdown ${ETHER_IF}:lower
|
2001-10-30 07:28:17 +00:00
|
|
|
mkpeer ${ETHER_IF}: etf lower downstream
|
|
|
|
# Give it a name to easily refer to it.
|
|
|
|
name ${ETHER_IF}:lower etf
|
|
|
|
# Connect the nomatch hook to the upper part of the same interface.
|
|
|
|
# All unmatched packets will act as if the filter is not present.
|
|
|
|
connect ${ETHER_IF}: etf: upper nomatch
|
|
|
|
DONE
|
|
|
|
ngctl -f /tmp/xwert
|
|
|
|
|
2002-04-09 21:34:33 +00:00
|
|
|
# something to set a hook to catch packets and show them.
|
2001-10-30 07:28:17 +00:00
|
|
|
echo "Unrecognised packets:"
|
|
|
|
nghook -a etf: newproto &
|
|
|
|
# Filter two random ethertypes to that hook.
|
|
|
|
ngctl 'msg etf: setfilter { matchhook="newproto" ethertype=${MATCH1} }
|
|
|
|
ngctl 'msg etf: setfilter { matchhook="newproto" ethertype=${MATCH2} }
|
|
|
|
.Ed
|
|
|
|
.Sh SHUTDOWN
|
|
|
|
This node shuts down upon receipt of a
|
2001-11-21 17:29:00 +00:00
|
|
|
.Dv NGM_SHUTDOWN
|
2001-10-30 07:28:17 +00:00
|
|
|
control message, or when all hooks have been disconnected.
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr netgraph 4 ,
|
|
|
|
.Xr ng_ether 4 ,
|
2001-11-21 17:29:00 +00:00
|
|
|
.Xr ngctl 8 ,
|
2001-10-30 07:28:17 +00:00
|
|
|
.Xr nghook 8
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
node type was implemented in
|
|
|
|
.Fx 5.0 .
|
|
|
|
.Sh AUTHORS
|
2014-06-26 21:46:14 +00:00
|
|
|
.An Julian Elischer Aq Mt julian@FreeBSD.org
|