summaryrefslogtreecommitdiffhomepage
path: root/src/dhcpv6-ia.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2016-12-15 22:37:47 +0100
committerHans Dedecker <dedeckeh@gmail.com>2016-12-27 21:53:55 +0100
commit4c89614ccf5d72ee0c0824e5050a8814748a32c3 (patch)
treef54a82daadd4ed089ff2b53967a58d98baf436b6 /src/dhcpv6-ia.c
parent8dc2a59dcaef51be41cf82621c0e00eac88074aa (diff)
Limit lifetime of non-static leases in case of release and decline
In case infinite leasetime is assigned to a non static DHCPv4/v6 lease override the infinite lifetime of the lease when either a DHCPv4/v6 decline or release is received. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/dhcpv6-ia.c')
-rw-r--r--src/dhcpv6-ia.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c
index e8b6e9f..a7146a7 100644
--- a/src/dhcpv6-ia.c
+++ b/src/dhcpv6-ia.c
@@ -114,6 +114,8 @@ int setup_dhcpv6_ia_interface(struct interface *iface, bool enable)
odhcpd_urandom(a->key, sizeof(a->key));
memcpy(a->clid_data, lease->duid, lease->duid_len);
memcpy(a->mac, lease->mac.ether_addr_octet, sizeof(a->mac));
+ /* Static assignment */
+ a->flags |= OAF_STATIC;
/* Infinite valid */
a->valid_until = 0;
@@ -1130,7 +1132,7 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface,
if (assigned && hdr->msg_type == DHCPV6_MSG_SOLICIT) {
a->flags &= ~OAF_BOUND;
- if (!INFINITE_VALID(a->valid_until))
+ if (!(a->flags & OAF_STATIC))
a->valid_until = now;
} else if (assigned && hdr->msg_type == DHCPV6_MSG_REQUEST) {
if (hostname_len > 0) {
@@ -1161,7 +1163,7 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface,
apply_lease(iface, a, true);
}
} else if (hdr->msg_type == DHCPV6_MSG_RELEASE) {
- if (!INFINITE_VALID(a->valid_until))
+ if (!(a->flags & OAF_STATIC))
a->valid_until = now - 1;
a->flags &= ~OAF_BOUND;
@@ -1169,7 +1171,7 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface,
} else if (hdr->msg_type == DHCPV6_MSG_DECLINE && a->length == 128) {
a->flags &= ~OAF_BOUND;
- if (!INFINITE_VALID(a->valid_until)) {
+ if (!(a->flags & OAF_STATIC)) {
a->clid_len = 0;
a->valid_until = now + 3600; // Block address for 1h
}