aboutsummaryrefslogtreecommitdiff
path: root/share/man/man9/pfil.9
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2012-10-22 14:10:17 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2012-10-22 14:10:17 +0000
commit4dab1a18a36cfc844593d960f39444772b926a26 (patch)
treeff3e75b886091b1b012e8212d8b884514bbe1142 /share/man/man9/pfil.9
parent98fd12e162eb3b31ba8ae0a8905386806bfc9a2f (diff)
downloadsrc-4dab1a18a36cfc844593d960f39444772b926a26.tar.gz
src-4dab1a18a36cfc844593d960f39444772b926a26.zip
Make PFIL use per-VNET lock instead of per-AF lock. Since most used packet
filters (ipfw and PF) use the same ruleset with the same lock for both AF_INET and AF_INET6 there is no need in more fine-grade locking. However, it is possible to request personal lock by specifying PFIL_FLAG_PRIVATE_LOCK flag in pfil_head structure (see pfil.9 for more details). Export PFIL lock via rw_lock(9)/rm_lock(9)-like API permitting pfil consumers to use this lock instead of own lock. This help reducing locks on main traffic path. pfil_assert() is currently not implemented due to absense of rm_assert(). Waiting for some kind of r234648 to be merged in HEAD. This change is part of bigger patch reducing routing locking. Sponsored by: Yandex LLC Reviewed by: glebius, ae OK'd by: silence on net@ MFC after: 3 weeks
Notes
Notes: svn path=/head/; revision=241888
Diffstat (limited to 'share/man/man9/pfil.9')
-rw-r--r--share/man/man9/pfil.955
1 files changed, 53 insertions, 2 deletions
diff --git a/share/man/man9/pfil.9 b/share/man/man9/pfil.9
index b6d3a0301c5c..9425f5d6d2b9 100644
--- a/share/man/man9/pfil.9
+++ b/share/man/man9/pfil.9
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 6, 2012
+.Dd October 22, 2012
.Dt PFIL 9
.Os
.Sh NAME
@@ -39,7 +39,11 @@
.Nm pfil_hook_get ,
.Nm pfil_add_hook ,
.Nm pfil_remove_hook ,
-.Nm pfil_run_hooks
+.Nm pfil_run_hooks ,
+.Nm pfil_rlock ,
+.Nm pfil_runlock ,
+.Nm pfil_wlock ,
+.Nm pfil_wunlock
.Nd packet filter interface
.Sh SYNOPSIS
.In sys/param.h
@@ -62,6 +66,14 @@
.Fn (*func) "void *arg" "struct mbuf **mp" "struct ifnet *" "int dir" "struct inpcb *"
.Ft int
.Fn pfil_run_hooks "struct pfil_head *head" "struct mbuf **mp" "struct ifnet *" "int dir" "struct inpcb *"
+.Ft void
+.Fn pfil_rlock "struct pfil_head *" "struct rm_priotracker *"
+.Ft void
+.Fn pfil_runlock "struct pfil_head *" "struct rm_priotracker *"
+.Ft void
+.Fn pfil_wlock "struct pfil_head *"
+.Ft void
+.Fn pfil_wunlock "struct pfil_head *"
.Sh DESCRIPTION
The
.Nm
@@ -86,6 +98,16 @@ The data link type is a
.Xr bpf 4
DLT constant indicating what kind of header is present on the packet
at the filtering point.
+Each filtering point uses common per-VNET rmlock by default.
+This can be changed by specifying
+.Vt PFIL_FLAG_PRIVATE_LOCK
+as
+.Vt "flags"
+field in the
+.Vt pfil_head
+structure.
+Note that specifying private lock can break filters sharing the same
+ruleset and/or state between different data link types.
Filtering points may be unregistered with the
.Fn pfil_head_unregister
function.
@@ -122,6 +144,31 @@ The filter returns an error (errno) if the packet processing is to stop, or 0
if the processing is to continue.
If the packet processing is to stop, it is the responsibility of the
filter to free the packet.
+.Pp
+Every filter hook is called with
+.Nm
+read lock held.
+All heads uses the same lock within the same VNET instance.
+Packet filter can use this lock instead of own locking model to
+improve performance.
+Since
+.Nm
+uses
+.Xr rmlock 9
+.Fn pfil_rlock
+and
+.Fn pfil_runlock
+require
+.Va struct rm_priotracker
+to be passed as argument.
+Filter can acquire and release writer lock via
+.Fn pfil_wlock
+and
+.Fn pfil_wunlock
+functions.
+See
+.Xr rmlock 9
+for more details.
.Sh FILTERING POINTS
Currently, filtering points are implemented for the following link types:
.Pp
@@ -157,6 +204,7 @@ might sleep!
.Sh SEE ALSO
.Xr bpf 4 ,
.Xr if_bridge 4
+.Xr rmlock 4
.Sh HISTORY
The
.Nm
@@ -192,6 +240,9 @@ as well as be less IP-centric.
.Pp
Fine-grained locking was added in
.Fx 5.2 .
+.Nm
+lock export was added in
+.Fx 10.0 .
.Sh BUGS
The
.Fn pfil_hook_get