freebsd-dev/sbin/pfilctl/pfilctl.8

118 lines
2.7 KiB
Groff
Raw Normal View History

New pfil(9) KPI together with newborn pfil API and control utility. The KPI have been reviewed and cleansed of features that were planned back 20 years ago and never implemented. The pfil(9) internals have been made opaque to protocols with only returned types and function declarations exposed. The KPI is made more strict, but at the same time more extensible, as kernel uses same command structures that userland ioctl uses. In nutshell [KA]PI is about declaring filtering points, declaring filters and linking and unlinking them together. New [KA]PI makes it possible to reconfigure pfil(9) configuration: change order of hooks, rehook filter from one filtering point to a different one, disconnect a hook on output leaving it on input only, prepend/append a filter to existing list of filters. Now it possible for a single packet filter to provide multiple rulesets that may be linked to different points. Think of per-interface ACLs in Cisco or Juniper. None of existing packet filters yet support that, however limited usage is already possible, e.g. default ruleset can be moved to single interface, as soon as interface would pride their filtering points. Another future feature is possiblity to create pfil heads, that provide not an mbuf pointer but just a memory pointer with length. That would allow filtering at very early stages of a packet lifecycle, e.g. when packet has just been received by a NIC and no mbuf was yet allocated. Differential Revision: https://reviews.freebsd.org/D18951
2019-01-31 23:01:03 +00:00
.\" Copyright (c) 2019 Gleb Smirnoff <glebius@FreeBSD.org>
.\"
.\" 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 January 28, 2019
.Dt PFILCTL 8
.Os
.Sh NAME
.Nm pfilctl
.Nd pfil(9) control utility
.Sh SYNOPSIS
.Nm
.Cm heads
.Nm
.Cm hooks
.Nm
.Cm link
.Aq Fl i | Fl o
.Op Fl a
.Ar hook Ar head
.Nm
.Cm unlink
.Aq Fl i | Fl o
.Ar hook Ar head
.Sh DESCRIPTION
The
.Nm
utility is intended to view and change configuration of the
.Xr pfil 9
packet filtering hooks and filters on them.
.Sh COMMANDS
.Bl -tag -width "unlink"
.It Cm heads
List available packet filtering points.
.It Cm hooks
List available packet filters.
.It Xo
.Cm link
.Aq Fl i | Fl o
.Op Fl a
.Ar hook Ar head
.Xc
Link
.Ar hook
to
.Ar head .
With the
.Fl i
flag the hook will be connected as input and with
.Fl o
as output hook.
At least one of
.Fl i
or
.Fl o
is required.
By default
.Nm
will prepend the hook in front of other hooks if any present:
new hook will be as close to the wire as possible, so that on input
it will be the first filter and on output it will be the last.
Adding the
.Fl a
flag switches to appending new hook instead of prepending.
.It Xo
.Cm unlink
.Aq Fl i | Fl o
.Ar hook Ar head
.Xc
Unlink
.Ar hook
on
.Ar head .
At least one of
.Fl i
or
.Fl o
is required.
With the
.Fl i
flag the hook will be removed from the input list of hooks
and with
.Fl o
on output list.
.El
.Sh SEE ALSO
.Xr ipfilter 4 ,
.Xr ipfw 4 ,
.Xr pf 4 ,
.Xr pfil 9
.Sh AUTHORS
.An -nosplit
The
.Nm
utility was written by
.An Gleb Smirnoff Aq Mt glebius@FreeBSD.org .