summaryrefslogtreecommitdiffstats
path: root/sys/net/flowtable.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2009-07-23 20:46:49 +0000
committerrwatson <rwatson@FreeBSD.org>2009-07-23 20:46:49 +0000
commitb3be1c6e3bd7d3b5cf946ddb04c1c5811644229b (patch)
tree0191b21173debdadfbf9f7565dfc5a8b9eefe94a /sys/net/flowtable.c
parentfc8defe5dd957eaee1f1c841d45804df5bbf20f5 (diff)
downloadFreeBSD-src-b3be1c6e3bd7d3b5cf946ddb04c1c5811644229b.zip
FreeBSD-src-b3be1c6e3bd7d3b5cf946ddb04c1c5811644229b.tar.gz
Introduce and use a sysinit-based initialization scheme for virtual
network stacks, VNET_SYSINIT: - Add VNET_SYSINIT and VNET_SYSUNINIT macros to declare events that will occur each time a network stack is instantiated and destroyed. In the !VIMAGE case, these are simply mapped into regular SYSINIT/SYSUNINIT. For the VIMAGE case, we instead use SYSINIT's to track their order and properties on registration, using them for each vnet when created/ destroyed, or immediately on module load for already-started vnets. - Remove vnet_modinfo mechanism that existed to serve this purpose previously, as well as its dependency scheme: we now just use the SYSINIT ordering scheme. - Implement VNET_DOMAIN_SET() to allow protocol domains to declare that they want init functions to be called for each virtual network stack rather than just once at boot, compiling down to DOMAIN_SET() in the non-VIMAGE case. - Walk all virtualized kernel subsystems and make use of these instead of modinfo or DOMAIN_SET() for init/uninit events. In some cases, convert modular components from using modevent to using sysinit (where appropriate). In some cases, do minor rejuggling of SYSINIT ordering to make room for or better manage events. Portions submitted by: jhb (VNET_SYSINIT), bz (cleanup) Discussed with: jhb, bz, julian, zec Reviewed by: bz Approved by: re (VIMAGE blanket)
Diffstat (limited to 'sys/net/flowtable.c')
-rw-r--r--sys/net/flowtable.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/sys/net/flowtable.c b/sys/net/flowtable.c
index d16ffa3..1fe2bbe 100644
--- a/sys/net/flowtable.c
+++ b/sys/net/flowtable.c
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_var.h>
#include <net/route.h>
#include <net/flowtable.h>
+#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -173,18 +174,6 @@ static VNET_DEFINE(uma_zone_t, flow_ipv6_zone);
#define V_flow_ipv4_zone VNET(flow_ipv4_zone)
#define V_flow_ipv6_zone VNET(flow_ipv6_zone)
-static int flowtable_iattach(const void *);
-#ifdef VIMAGE
-static int flowtable_idetach(const void *);
-
-static const vnet_modinfo_t flowtable_modinfo = {
- .vmi_id = VNET_MOD_FLOWTABLE,
- .vmi_name = "flowtable",
- .vmi_iattach = flowtable_iattach,
- .vmi_idetach = flowtable_idetach
-};
-#endif
-
/*
* TODO:
* - Make flowtable stats per-cpu, aggregated at sysctl call time,
@@ -802,18 +791,7 @@ flowtable_alloc(int nentry, int flags)
}
static void
-flowtable_setup(void *arg)
-{
-
-#ifdef VIMAGE
- vnet_mod_register(&flowtable_modinfo);
-#else
- flowtable_iattach(NULL);
-#endif
-}
-
-static int
-flowtable_iattach(const void *unused __unused)
+flowtable_init(const void *unused __unused)
{
V_flow_ipv4_zone = uma_zcreate("ip4flow", sizeof(struct flentry_v4),
@@ -822,21 +800,23 @@ flowtable_iattach(const void *unused __unused)
NULL, NULL, NULL, NULL, 64, UMA_ZONE_MAXBUCKET);
uma_zone_set_max(V_flow_ipv4_zone, V_flowtable_nmbflows);
uma_zone_set_max(V_flow_ipv6_zone, V_flowtable_nmbflows);
- return (0);
}
+VNET_SYSINIT(flowtable_init, SI_SUB_KTHREAD_INIT, SI_ORDER_ANY,
+ flowtable_init, NULL);
+
#ifdef VIMAGE
-static int
-flowtable_idetach(const void *unused __unused)
+static void
+flowtable_uninit(const void *unused __unused)
{
uma_zdestroy(V_flow_ipv4_zone);
uma_zdestroy(V_flow_ipv6_zone);
- return (0);
}
-#endif
-SYSINIT(flowtable_setup, SI_SUB_KTHREAD_INIT, SI_ORDER_ANY, flowtable_setup, NULL);
+VNET_SYSUNINIT(flowtable_uninit, SI_SUB_KTHREAD_INIT, SI_ORDER_ANY,
+ flowtable_uninit, NULL);
+#endif
/*
* The rest of the code is devoted to garbage collection of expired entries.
OpenPOWER on IntegriCloud