diff options
author | Steven Barth <steven@midlink.org> | 2014-08-07 20:08:31 +0200 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2014-08-07 20:08:31 +0200 |
commit | 98b41e5b07b28b438fb0be45ba294a932f4c849b (patch) | |
tree | 72baecb1314964b061980042db68c244a39fc0fb /src | |
parent | c0c1086c51e1abfc991de11e3d687a60240d2df8 (diff) |
sync hostfile more often
Diffstat (limited to 'src')
-rw-r--r-- | src/dhcpv4.c | 9 | ||||
-rw-r--r-- | src/dhcpv6-ia.c | 7 |
2 files changed, 2 insertions, 14 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 9746aa2..2093ecd 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -491,7 +491,6 @@ static struct dhcpv4_assignment* dhcpv4_lease(struct interface *iface, } } - bool update_state = false; if (msg == DHCPV4_MSG_DISCOVER || msg == DHCPV4_MSG_REQUEST) { bool assigned = !!a; size_t hostlen = strlen(hostname) + 1; @@ -530,24 +529,18 @@ static struct dhcpv4_assignment* dhcpv4_lease(struct interface *iface, a = NULL; } - if (a) - update_state = true; - if (assigned && a) lease = a; } else if (msg == DHCPV4_MSG_RELEASE) { if (a) { a->valid_until = 0; - update_state = true; } } else if (msg == DHCPV4_MSG_DECLINE) { memset(a->hwaddr, 0, sizeof(a->hwaddr)); a->valid_until = now + 3600; // Block address for 1h - update_state = true; } - if (update_state) - dhcpv6_write_statefile(); + dhcpv6_write_statefile(); return lease; } diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index 610bca3..8f0307e 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -976,7 +976,6 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface, goto out; update(iface); - bool update_state = false; struct dhcpv6_assignment *first = NULL; dhcpv6_for_each_option(start, end, otype, olen, odata) { @@ -1165,7 +1164,6 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface, } a->accept_reconf = accept_reconf; apply_lease(iface, a, true); - update_state = true; } else if (!assigned && a && a->managed_size == 0) { // Cleanup failed assignment free_dhcpv6_assignment(a); } @@ -1184,11 +1182,9 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface, } else if (hdr->msg_type == DHCPV6_MSG_RELEASE) { a->valid_until = 0; apply_lease(iface, a, false); - update_state = true; } else if (hdr->msg_type == DHCPV6_MSG_DECLINE && a->length == 128) { a->clid_len = 0; a->valid_until = now + 3600; // Block address for 1h - update_state = true; } } else if (hdr->msg_type == DHCPV6_MSG_CONFIRM && ia_addr_present) { // Send NOTONLINK for CONFIRM with addr present so that clients restart connection @@ -1213,8 +1209,7 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface, response_len += 6; } - if (update_state) - dhcpv6_write_statefile(); + dhcpv6_write_statefile(); out: return response_len; |