diff options
author | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2008-06-10 22:39:32 +0000 |
---|---|---|
committer | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2008-06-10 22:39:32 +0000 |
commit | 8c36b6d8a60c0e0011406c71e975079596d9df67 (patch) | |
tree | be411c28561c317bfe051003bc4799946040b3ec | |
parent | 123e9348dc23ca6c27f7c49e34a254e4f17ff8d3 (diff) |
Simplify code slightly; use PR_ZERO with pool_get() rather than bzero().
ok mpf henning
-rw-r--r-- | sys/net/if_pfsync.c | 8 | ||||
-rw-r--r-- | sys/net/pf.c | 11 | ||||
-rw-r--r-- | sys/net/pf_ioctl.c | 5 | ||||
-rw-r--r-- | sys/net/pf_table.c | 12 |
4 files changed, 14 insertions, 22 deletions
diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c index 6220e8e2343..49f2c074a19 100644 --- a/sys/net/if_pfsync.c +++ b/sys/net/if_pfsync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pfsync.c,v 1.95 2008/06/10 19:32:13 henning Exp $ */ +/* $OpenBSD: if_pfsync.c,v 1.96 2008/06/10 22:39:31 mcbride Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff @@ -224,10 +224,9 @@ pfsync_alloc_scrub_memory(struct pfsync_state_peer *s, struct pf_state_peer *d) { if (s->scrub.scrub_flag && d->scrub == NULL) { - d->scrub = pool_get(&pf_state_scrub_pl, PR_NOWAIT); + d->scrub = pool_get(&pf_state_scrub_pl, PR_NOWAIT | PR_ZERO); if (d->scrub == NULL) return (ENOMEM); - bzero(d->scrub, sizeof(*d->scrub)); } return (0); @@ -269,12 +268,11 @@ pfsync_insert_net_state(struct pfsync_state *sp, u_int8_t chksum_flag) r = &pf_default_rule; if (!r->max_states || r->states_cur < r->max_states) - st = pool_get(&pf_state_pl, PR_NOWAIT); + st = pool_get(&pf_state_pl, PR_NOWAIT | PR_ZERO); if (st == NULL) { pfi_kif_unref(kif, PFI_KIF_REF_NONE); return (ENOMEM); } - bzero(st, sizeof(*st)); if ((skw = pf_alloc_state_key()) == NULL) { pool_put(&pf_state_pl, st); diff --git a/sys/net/pf.c b/sys/net/pf.c index b4dacaa3130..3fd065b102a 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.587 2008/06/10 21:14:39 reyk Exp $ */ +/* $OpenBSD: pf.c,v 1.588 2008/06/10 22:39:31 mcbride Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -527,12 +527,11 @@ pf_insert_src_node(struct pf_src_node **sn, struct pf_rule *rule, if (*sn == NULL) { if (!rule->max_src_nodes || rule->src_nodes < rule->max_src_nodes) - (*sn) = pool_get(&pf_src_tree_pl, PR_NOWAIT); + (*sn) = pool_get(&pf_src_tree_pl, PR_NOWAIT | PR_ZERO); else pf_status.lcounters[LCNT_SRCNODES]++; if ((*sn) == NULL) return (-1); - bzero(*sn, sizeof(struct pf_src_node)); pf_init_threshold(&(*sn)->conn_rate, rule->max_src_conn_rate.limit, @@ -728,9 +727,8 @@ pf_alloc_state_key(void) { struct pf_state_key *sk; - if ((sk = pool_get(&pf_state_key_pl, PR_NOWAIT)) == NULL) + if ((sk = pool_get(&pf_state_key_pl, PR_NOWAIT | PR_ZERO)) == NULL) return (NULL); - bzero(sk, sizeof(*sk)); TAILQ_INIT(&sk->states); return (sk); @@ -3375,7 +3373,7 @@ pf_test_rule(struct pf_rule **rm, struct pf_state **sm, int direction, REASON_SET(&reason, PFRES_SRCLIMIT); goto cleanup; } - s = pool_get(&pf_state_pl, PR_NOWAIT); + s = pool_get(&pf_state_pl, PR_NOWAIT | PR_ZERO); if (s == NULL) { REASON_SET(&reason, PFRES_MEMORY); cleanup: @@ -3398,7 +3396,6 @@ cleanup: pool_put(&pf_state_key_pl, nk); return (PF_DROP); } - bzero(s, sizeof(*s)); s->rule.ptr = r; s->nat_rule.ptr = nr; s->anchor.ptr = a; diff --git a/sys/net/pf_ioctl.c b/sys/net/pf_ioctl.c index 8e803a5e8b6..61f3d99d728 100644 --- a/sys/net/pf_ioctl.c +++ b/sys/net/pf_ioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_ioctl.c,v 1.203 2008/06/10 20:14:02 henning Exp $ */ +/* $OpenBSD: pf_ioctl.c,v 1.204 2008/06/10 22:39:31 mcbride Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -1676,12 +1676,11 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) error = EINVAL; break; } - s = pool_get(&pf_state_pl, PR_NOWAIT); + s = pool_get(&pf_state_pl, PR_NOWAIT | PR_ZERO); if (s == NULL) { error = ENOMEM; break; } - bzero(s, sizeof(struct pf_state)); if ((skw = pf_alloc_state_key()) == NULL) { pool_put(&pf_state_pl, s); error = ENOMEM; diff --git a/sys/net/pf_table.c b/sys/net/pf_table.c index 031f556f764..ff605324110 100644 --- a/sys/net/pf_table.c +++ b/sys/net/pf_table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_table.c,v 1.75 2008/06/10 21:25:29 mcbride Exp $ */ +/* $OpenBSD: pf_table.c,v 1.76 2008/06/10 22:39:31 mcbride Exp $ */ /* * Copyright (c) 2002 Cedric Berger @@ -811,12 +811,11 @@ pfr_create_kentry(struct pfr_addr *ad, int intr) struct pfr_kentry *ke; if (intr) - ke = pool_get(&pfr_kentry_pl2, PR_NOWAIT); + ke = pool_get(&pfr_kentry_pl2, PR_NOWAIT | PR_ZERO); else - ke = pool_get(&pfr_kentry_pl, PR_NOWAIT); + ke = pool_get(&pfr_kentry_pl, PR_NOWAIT | PR_ZERO); if (ke == NULL) return (NULL); - bzero(ke, sizeof(*ke)); if (ad->pfra_af == AF_INET) FILLIN_SIN(ke->pfrke_sa.sin, ad->pfra_ip4addr); @@ -1901,10 +1900,9 @@ pfr_create_ktable(struct pfr_table *tbl, long tzero, int attachruleset) struct pfr_ktable *kt; struct pf_ruleset *rs; - kt = pool_get(&pfr_ktable_pl, PR_NOWAIT); + kt = pool_get(&pfr_ktable_pl, PR_NOWAIT | PR_ZERO); if (kt == NULL) return (NULL); - bzero(kt, sizeof(*kt)); kt->pfrkt_t = *tbl; if (attachruleset) { @@ -2060,7 +2058,7 @@ pfr_update_stats(struct pfr_ktable *kt, struct pf_addr *a, sa_family_t af, (kt->pfrkt_flags & PFR_TFLAG_COUNTERS)) { if (ke->pfrke_counters == NULL) ke->pfrke_counters = pool_get(&pfr_kcounters_pl, - PR_NOWAIT|PR_ZERO); + PR_NOWAIT | PR_ZERO); if (ke->pfrke_counters != NULL) { ke->pfrke_counters->pfrkc_packets[dir_out][op_pass]++; ke->pfrke_counters->pfrkc_bytes[dir_out][op_pass] += len; |