summaryrefslogtreecommitdiff
path: root/server/confpars.c
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2012-04-10 00:54:35 +0000
committerShawn Routhier <sar@isc.org>2012-04-10 00:54:35 +0000
commitbc7f8b8e3933b80d4e241f62b14a1917256d9c14 (patch)
treee69aedde61428ca3bebdb16e4447545cada80e44 /server/confpars.c
parent6bc3ebf0880156496eae046d4bd27fbe8007eef6 (diff)
downloadisc-dhcp-bc7f8b8e3933b80d4e241f62b14a1917256d9c14.tar.gz
Multiple items to clean up IPv6 address processing.
When processing an IA that we've seen check to see if the addresses are usable (not in use by somebody else) before handing it out. When reading in leases from the file discard expired addresses. When picking an address for a client include the IA ID in addition to the client ID to generally pick different addresses for different IAs. [ISC-Bugs #23138] [ISC-Bugs #27945] [ISC-Bugs #25586] [ISC-Bugs #27684]
Diffstat (limited to 'server/confpars.c')
-rw-r--r--server/confpars.c88
1 files changed, 71 insertions, 17 deletions
diff --git a/server/confpars.c b/server/confpars.c
index c0742d49..1d822536 100644
--- a/server/confpars.c
+++ b/server/confpars.c
@@ -3,7 +3,7 @@
Parser for dhcpd config file... */
/*
- * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -4441,21 +4441,39 @@ parse_ia_na_declaration(struct parse *cfile) {
binding_scope_dereference(&scope, MDL);
}
- /* add to our various structures */
- ia_add_iasubopt(ia, iaaddr, MDL);
- ia_reference(&iaaddr->ia, ia, MDL);
+ /* find the pool this address is in */
pool = NULL;
if (find_ipv6_pool(&pool, D6O_IA_NA,
&iaaddr->addr) != ISC_R_SUCCESS) {
inet_ntop(AF_INET6, &iaaddr->addr,
addr_buf, sizeof(addr_buf));
- parse_warn(cfile, "no pool found for address %s",
+ parse_warn(cfile, "no pool found for address %s",
addr_buf);
return;
}
- add_lease6(pool, iaaddr, end_time);
- ipv6_pool_dereference(&pool, MDL);
+
+ /* remove old information */
+ if (cleanup_lease6(ia_na_active, pool,
+ iaaddr, ia) != ISC_R_SUCCESS) {
+ inet_ntop(AF_INET6, &iaaddr->addr,
+ addr_buf, sizeof(addr_buf));
+ parse_warn(cfile, "duplicate na lease for address %s",
+ addr_buf);
+ }
+
+ /*
+ * if we like the lease we add it to our various structues
+ * otherwise we leave it and it will get cleaned when we
+ * do the iasubopt_dereference.
+ */
+ if ((state == FTS_ACTIVE) || (state == FTS_ABANDONED)) {
+ ia_add_iasubopt(ia, iaaddr, MDL);
+ ia_reference(&iaaddr->ia, ia, MDL);
+ add_lease6(pool, iaaddr, end_time);
+ }
+
iasubopt_dereference(&iaaddr, MDL);
+ ipv6_pool_dereference(&pool, MDL);
}
/*
@@ -4804,19 +4822,37 @@ parse_ia_ta_declaration(struct parse *cfile) {
binding_scope_dereference(&scope, MDL);
}
- /* add to our various structures */
- ia_add_iasubopt(ia, iaaddr, MDL);
- ia_reference(&iaaddr->ia, ia, MDL);
+ /* find the pool this address is in */
pool = NULL;
if (find_ipv6_pool(&pool, D6O_IA_TA,
&iaaddr->addr) != ISC_R_SUCCESS) {
inet_ntop(AF_INET6, &iaaddr->addr,
addr_buf, sizeof(addr_buf));
- parse_warn(cfile, "no pool found for address %s",
+ parse_warn(cfile, "no pool found for address %s",
addr_buf);
return;
}
- add_lease6(pool, iaaddr, end_time);
+
+ /* remove old information */
+ if (cleanup_lease6(ia_ta_active, pool,
+ iaaddr, ia) != ISC_R_SUCCESS) {
+ inet_ntop(AF_INET6, &iaaddr->addr,
+ addr_buf, sizeof(addr_buf));
+ parse_warn(cfile, "duplicate ta lease for address %s",
+ addr_buf);
+ }
+
+ /*
+ * if we like the lease we add it to our various structues
+ * otherwise we leave it and it will get cleaned when we
+ * do the iasubopt_dereference.
+ */
+ if ((state == FTS_ACTIVE) || (state == FTS_ABANDONED)) {
+ ia_add_iasubopt(ia, iaaddr, MDL);
+ ia_reference(&iaaddr->ia, ia, MDL);
+ add_lease6(pool, iaaddr, end_time);
+ }
+
ipv6_pool_dereference(&pool, MDL);
iasubopt_dereference(&iaaddr, MDL);
}
@@ -5168,19 +5204,37 @@ parse_ia_pd_declaration(struct parse *cfile) {
binding_scope_dereference(&scope, MDL);
}
- /* add to our various structures */
- ia_add_iasubopt(ia, iapref, MDL);
- ia_reference(&iapref->ia, ia, MDL);
+ /* find the pool this address is in */
pool = NULL;
if (find_ipv6_pool(&pool, D6O_IA_PD,
&iapref->addr) != ISC_R_SUCCESS) {
inet_ntop(AF_INET6, &iapref->addr,
addr_buf, sizeof(addr_buf));
- parse_warn(cfile, "no pool found for address %s",
+ parse_warn(cfile, "no pool found for address %s",
addr_buf);
return;
}
- add_lease6(pool, iapref, end_time);
+
+ /* remove old information */
+ if (cleanup_lease6(ia_pd_active, pool,
+ iapref, ia) != ISC_R_SUCCESS) {
+ inet_ntop(AF_INET6, &iapref->addr,
+ addr_buf, sizeof(addr_buf));
+ parse_warn(cfile, "duplicate pd lease for address %s",
+ addr_buf);
+ }
+
+ /*
+ * if we like the lease we add it to our various structues
+ * otherwise we leave it and it will get cleaned when we
+ * do the iasubopt_dereference.
+ */
+ if ((state == FTS_ACTIVE) || (state == FTS_ABANDONED)) {
+ ia_add_iasubopt(ia, iapref, MDL);
+ ia_reference(&iapref->ia, ia, MDL);
+ add_lease6(pool, iapref, end_time);
+ }
+
ipv6_pool_dereference(&pool, MDL);
iasubopt_dereference(&iapref, MDL);
}