diff options
Diffstat (limited to 'sys/contrib/ipfilter/netinet/ip_pool.c')
-rw-r--r-- | sys/contrib/ipfilter/netinet/ip_pool.c | 87 |
1 files changed, 37 insertions, 50 deletions
diff --git a/sys/contrib/ipfilter/netinet/ip_pool.c b/sys/contrib/ipfilter/netinet/ip_pool.c index b7e9946..eab3310 100644 --- a/sys/contrib/ipfilter/netinet/ip_pool.c +++ b/sys/contrib/ipfilter/netinet/ip_pool.c @@ -53,6 +53,9 @@ struct file; # include <sys/malloc.h> #endif +#if defined(SOLARIS2) && !defined(_KERNEL) +# include "radix_ipf.h" +#endif #if defined(_KERNEL) && (defined(__osf__) || defined(AIX) || \ defined(__hpux) || defined(__sgi)) # include "radix_ipf_local.h" @@ -75,15 +78,16 @@ static int rn_freenode __P((struct radix_node *, void *)); #if !defined(lint) static const char sccsid[] = "@(#)ip_fil.c 2.41 6/5/96 (C) 1993-2000 Darren Reed"; -static const char rcsid[] = "@(#)$Id: ip_pool.c,v 2.55.2.20 2007/05/31 12:27:35 darrenr Exp $"; +static const char rcsid[] = "@(#)$Id: ip_pool.c,v 2.55.2.24 2007/10/10 09:45:37 darrenr Exp $"; #endif #ifdef IPFILTER_LOOKUP -# ifndef RADIX_NODE_HEAD_LOCK +# if !defined(RADIX_NODE_HEAD_LOCK) || !defined(RADIX_NODE_HEAD_UNLOCK) || \ + !defined(_KERNEL) +# undef RADIX_NODE_HEAD_LOCK +# undef RADIX_NODE_HEAD_UNLOCK # define RADIX_NODE_HEAD_LOCK(x) ; -# endif -# ifndef RADIX_NODE_HEAD_UNLOCK # define RADIX_NODE_HEAD_UNLOCK(x) ; # endif @@ -264,8 +268,6 @@ void ip_pool_fini() ip_pool_t *p, *q; int i; - ASSERT(rw_read_locked(&ipf_global.ipf_lk) == 0); - for (i = 0; i <= IPL_LOGMAX; i++) { for (q = ip_pool_list[i]; (p = q) != NULL; ) { q = p->ipo_next; @@ -463,8 +465,6 @@ int info; struct radix_node *rn; ip_pool_node_t *x; - ASSERT(rw_read_locked(&ip_poolrw.ipf_lk) == 0); - KMALLOC(x, ip_pool_node_t *); if (x == NULL) { return ENOMEM; @@ -529,32 +529,27 @@ iplookupop_t *op; int poolnum, unit; ip_pool_t *h; - ASSERT(rw_read_locked(&ip_poolrw.ipf_lk) == 0); - unit = op->iplo_unit; - if ((op->iplo_arg & LOOKUP_ANON) == 0) + if ((op->iplo_arg & LOOKUP_ANON) == 0) { h = ip_pool_exists(unit, op->iplo_name); - else - h = NULL; - - if (h != NULL) { - if ((h->ipo_flags & IPOOL_DELETE) != 0) { + if (h != NULL) { + if ((h->ipo_flags & IPOOL_DELETE) == 0) + return EEXIST; h->ipo_flags &= ~IPOOL_DELETE; return 0; } - return EEXIST; - } else { - KMALLOC(h, ip_pool_t *); - if (h == NULL) - return ENOMEM; - bzero(h, sizeof(*h)); - - if (rn_inithead((void **)&h->ipo_head, - offsetof(addrfamily_t, adf_addr) << 3) == 0) { - KFREE(h); - return ENOMEM; - } + } + + KMALLOC(h, ip_pool_t *); + if (h == NULL) + return ENOMEM; + bzero(h, sizeof(*h)); + + if (rn_inithead((void **)&h->ipo_head, + offsetof(addrfamily_t, adf_addr) << 3) == 0) { + KFREE(h); + return ENOMEM; } if ((op->iplo_arg & LOOKUP_ANON) != 0) { @@ -589,18 +584,16 @@ iplookupop_t *op; (void)strncpy(h->ipo_name, op->iplo_name, sizeof(h->ipo_name)); } - if ((h->ipo_flags & IPOOL_DELETE) == 0) { - h->ipo_ref = 1; - h->ipo_list = NULL; - h->ipo_unit = unit; - h->ipo_next = ip_pool_list[unit]; - if (ip_pool_list[unit] != NULL) - ip_pool_list[unit]->ipo_pnext = &h->ipo_next; - h->ipo_pnext = &ip_pool_list[unit]; - ip_pool_list[unit] = h; - - ipoolstat.ipls_pools++; - } + h->ipo_ref = 1; + h->ipo_list = NULL; + h->ipo_unit = unit; + h->ipo_next = ip_pool_list[unit]; + if (ip_pool_list[unit] != NULL) + ip_pool_list[unit]->ipo_pnext = &h->ipo_next; + h->ipo_pnext = &ip_pool_list[unit]; + ip_pool_list[unit] = h; + + ipoolstat.ipls_pools++; return 0; } @@ -620,8 +613,6 @@ ip_pool_t *ipo; ip_pool_node_t *ipe; { - ASSERT(rw_read_locked(&ip_poolrw.ipf_lk) == 0); - if (ipe->ipn_pnext != NULL) *ipe->ipn_pnext = ipe->ipn_next; if (ipe->ipn_next != NULL) @@ -789,8 +780,6 @@ void ip_pool_deref(ipo) ip_pool_t *ipo; { - ASSERT(rw_read_locked(&ip_poolrw.ipf_lk) == 0); - ipo->ipo_ref--; if (ipo->ipo_ref == 0) @@ -858,11 +847,11 @@ ipflookupiter_t *ilp; if (nextipo != NULL) { ATOMIC_INC(nextipo->ipo_ref); - if (nextipo->ipo_next == NULL) - token->ipt_alive = 0; + token->ipt_data = nextipo; } else { bzero((char *)&zp, sizeof(zp)); nextipo = &zp; + token->ipt_data = NULL; } break; @@ -882,11 +871,11 @@ ipflookupiter_t *ilp; if (nextnode != NULL) { ATOMIC_INC(nextnode->ipn_ref); - if (nextnode->ipn_next == NULL) - token->ipt_alive = 0; + token->ipt_data = nextnode; } else { bzero((char *)&zn, sizeof(zn)); nextnode = &zn; + token->ipt_data = NULL; } break; default : @@ -907,7 +896,6 @@ ipflookupiter_t *ilp; ip_pool_deref(ipo); RWLOCK_EXIT(&ip_poolrw); } - token->ipt_data = nextipo; err = COPYOUT(nextipo, ilp->ili_data, sizeof(*nextipo)); if (err != 0) err = EFAULT; @@ -919,7 +907,6 @@ ipflookupiter_t *ilp; ip_pool_node_deref(node); RWLOCK_EXIT(&ip_poolrw); } - token->ipt_data = nextnode; err = COPYOUT(nextnode, ilp->ili_data, sizeof(*nextnode)); if (err != 0) err = EFAULT; |