svn commit: r232391 - projects/pf/head/sys/contrib/pf/net
Gleb Smirnoff
glebius at FreeBSD.org
Fri Mar 2 12:43:00 UTC 2012
Author: glebius
Date: Fri Mar 2 12:42:59 2012
New Revision: 232391
URL: http://svn.freebsd.org/changeset/base/232391
Log:
Use uma(9) init method to init pf_state_key.
Modified:
projects/pf/head/sys/contrib/pf/net/if_pfsync.c
projects/pf/head/sys/contrib/pf/net/pf.c
projects/pf/head/sys/contrib/pf/net/pf_ioctl.c
Modified: projects/pf/head/sys/contrib/pf/net/if_pfsync.c
==============================================================================
--- projects/pf/head/sys/contrib/pf/net/if_pfsync.c Fri Mar 2 12:33:10 2012 (r232390)
+++ projects/pf/head/sys/contrib/pf/net/if_pfsync.c Fri Mar 2 12:42:59 2012 (r232391)
@@ -484,7 +484,7 @@ pfsync_state_import(struct pfsync_state
if ((st = uma_zalloc(V_pf_state_z, pool_flags)) == NULL)
goto cleanup;
- if ((skw = pf_alloc_state_key(pool_flags)) == NULL)
+ if ((skw = uma_zalloc(V_pf_state_key_z, pool_flags)) == NULL)
goto cleanup;
if (PF_ANEQ(&sp->key[PF_SK_WIRE].addr[0],
@@ -493,7 +493,7 @@ pfsync_state_import(struct pfsync_state
&sp->key[PF_SK_STACK].addr[1], sp->af) ||
sp->key[PF_SK_WIRE].port[0] != sp->key[PF_SK_STACK].port[0] ||
sp->key[PF_SK_WIRE].port[1] != sp->key[PF_SK_STACK].port[1]) {
- if ((sks = pf_alloc_state_key(pool_flags)) == NULL)
+ if ((sks = uma_zalloc(V_pf_state_key_z, pool_flags)) == NULL)
goto cleanup;
} else
sks = skw;
Modified: projects/pf/head/sys/contrib/pf/net/pf.c
==============================================================================
--- projects/pf/head/sys/contrib/pf/net/pf.c Fri Mar 2 12:33:10 2012 (r232390)
+++ projects/pf/head/sys/contrib/pf/net/pf.c Fri Mar 2 12:42:59 2012 (r232391)
@@ -778,18 +778,6 @@ pf_state_key_detach(struct pf_state *s,
s->key[idx] = NULL;
}
-struct pf_state_key *
-pf_alloc_state_key(int pool_flags)
-{
- struct pf_state_key *sk;
-
- if ((sk = uma_zalloc(V_pf_state_key_z, pool_flags)) == NULL)
- return (NULL);
- TAILQ_INIT(&sk->states);
-
- return (sk);
-}
-
int
pf_state_key_setup(struct pf_pdesc *pd, struct pf_rule *nr,
struct pf_state_key **skw, struct pf_state_key **sks,
@@ -800,7 +788,7 @@ pf_state_key_setup(struct pf_pdesc *pd,
KASSERT((*skp == NULL && *nkp == NULL),
("%s: skp == NULL && nkp == NULL", __func__));
- if ((*skp = pf_alloc_state_key(M_NOWAIT | M_ZERO)) == NULL)
+ if ((*skp = uma_zalloc(V_pf_state_key_z, M_NOWAIT | M_ZERO)) == NULL)
return (ENOMEM);
PF_ACPY(&(*skp)->addr[pd->sidx], saddr, pd->af);
@@ -811,7 +799,8 @@ pf_state_key_setup(struct pf_pdesc *pd,
(*skp)->af = pd->af;
if (nr != NULL) {
- if ((*nkp = pf_alloc_state_key(M_NOWAIT | M_ZERO)) == NULL)
+ if ((*nkp = uma_zalloc(V_pf_state_key_z, M_NOWAIT | M_ZERO))
+ == NULL)
return (ENOMEM); /* caller must handle cleanup */
/* XXX maybe just bcopy and TAILQ_INIT(&(*nkp)->states) */
Modified: projects/pf/head/sys/contrib/pf/net/pf_ioctl.c
==============================================================================
--- projects/pf/head/sys/contrib/pf/net/pf_ioctl.c Fri Mar 2 12:33:10 2012 (r232390)
+++ projects/pf/head/sys/contrib/pf/net/pf_ioctl.c Fri Mar 2 12:42:59 2012 (r232391)
@@ -270,6 +270,15 @@ cleanup_pf_zone(void)
uma_zdestroy(V_pfi_addr_z);
}
+static int
+pf_state_key_ini(void *mem, int size, int flags)
+{
+ struct pf_state_key *sk = mem;
+
+ TAILQ_INIT(&sk->states);
+ return (0);
+}
+
int
pfattach(void)
{
@@ -283,8 +292,8 @@ pfattach(void)
V_pf_state_z = uma_zcreate("pf states", sizeof(struct pf_state),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
V_pf_state_key_z = uma_zcreate("pf state keys",
- sizeof(struct pf_state_key), NULL, NULL, NULL, NULL,UMA_ALIGN_PTR,
- 0);
+ sizeof(struct pf_state_key), NULL, NULL, pf_state_key_ini, NULL,
+ UMA_ALIGN_PTR, 0);
V_pf_altq_z = uma_zcreate("pf altq", sizeof(struct pf_altq),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
V_pf_pooladdr_z = uma_zcreate("pf pool addresses",
More information about the svn-src-projects
mailing list