Virtualise ipfilter.
authorbz <bz@FreeBSD.org>
Thu, 30 Jun 2016 15:01:07 +0000 (15:01 +0000)
committerbz <bz@FreeBSD.org>
Thu, 30 Jun 2016 15:01:07 +0000 (15:01 +0000)
commit0c1171f994c5ad66aa192de0cc43b326e8cee144
tree0226109929013a43480d069000c5f5a39c8521b4
parentb281d573a9937cf7f6f8aebd506d4b39a067209c
Virtualise ipfilter.
Split initializzation an teardown into module (global state) and VNET
(per virtual network stack) parts.  Virtualise global state, which is
not "const".

Cleanup eventhandlers, so that we can make use of the passed in argument
to get the vnet state from the ifp;  disable the "cloner" event as it is
too early, has no state, and can fire before initialisation (see comment
in the source).

Handle the dynamic sysctls specially.  The problem is that "ipmain"
is the virtualized struct, but the fields used for the sysctls are
hanging off memory allocated and attached to the virtualized "ipmain"
thus standard VNET macros and sysctl handling do not work.
We still say it is VNET sysctls to get the proper protection checks
in the VIMAGE case;  to solve the problem of accessing the right bit
of memory hanging of each per-VNET ipmain, we use a dedicated handler
function wrapping around sysctl_ipf_int() undoing the base calculation
from kern_sysctl.c and then adding the passed-in offset into the right
struct depending on handler.  A bit of a mess exposing VNET-internals
this way but the only way to keep the code without having to massively
restructure ipf internals.

Approved by: re (hrs)
Sponsored by: The FreeBSD Foundation
Obtained from: projects/vnet
MFC after: 2 weeks
Reviewed by: cy
Differential Revision: https://reviews.freebsd.org/D7000
sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
sys/contrib/ipfilter/netinet/ip_proxy.c
sys/contrib/ipfilter/netinet/ip_rpcb_pxy.c
sys/contrib/ipfilter/netinet/ip_rules.c
sys/contrib/ipfilter/netinet/mlfk_ipl.c