diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2012-12-29 14:54:46 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2012-12-29 14:54:46 +0000 |
commit | f22310bceda42b8f611ee5b9e18b856ff98ed399 (patch) | |
tree | 05cdf6f33cbbf386ef2afd784606282ba75c8933 | |
parent | fd9dd839fdbf441134929fe03d7a5c9b51c884c2 (diff) |
reset the counter in case its current value has been removed
from the pool (e.g. ifconfig em0 1.2.3.4 -alias)
ok henning@, mikeb@
-rw-r--r-- | sys/net/pf_lb.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/sys/net/pf_lb.c b/sys/net/pf_lb.c index 7d0e0f0a946..70e6d9dc3f0 100644 --- a/sys/net/pf_lb.c +++ b/sys/net/pf_lb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_lb.c,v 1.22 2012/12/29 14:53:05 markus Exp $ */ +/* $OpenBSD: pf_lb.c,v 1.23 2012/12/29 14:54:45 markus Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -396,8 +396,15 @@ pf_map_addr(sa_family_t af, struct pf_rule *r, struct pf_addr *saddr, case PF_POOL_ROUNDROBIN: if (rpool->addr.type == PF_ADDR_TABLE || rpool->addr.type == PF_ADDR_DYNIFTL) { - if (pfr_pool_get(rpool, &raddr, &rmask, af)) - return (1); + if (pfr_pool_get(rpool, &raddr, &rmask, af)) { + /* + * reset counter in case its value + * has been removed from the pool. + */ + bzero(&rpool->counter, sizeof(rpool->counter)); + if (pfr_pool_get(rpool, &raddr, &rmask, af)) + return (1); + } } else if (pf_match_addr(0, raddr, rmask, &rpool->counter, af)) return (1); @@ -434,8 +441,12 @@ pf_map_addr(sa_family_t af, struct pf_rule *r, struct pf_addr *saddr, /* retrieve an address first */ if (rpool->addr.type == PF_ADDR_TABLE || rpool->addr.type == PF_ADDR_DYNIFTL) { - if (pfr_pool_get(rpool, &raddr, &rmask, af)) - return (1); + if (pfr_pool_get(rpool, &raddr, &rmask, af)) { + /* see PF_POOL_ROUNDROBIN */ + bzero(&rpool->counter, sizeof(rpool->counter)); + if (pfr_pool_get(rpool, &raddr, &rmask, af)) + return (1); + } } else if (pf_match_addr(0, raddr, rmask, &rpool->counter, af)) return (1); |