diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2017-08-17 11:16:00 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2017-08-17 11:17:08 +0200 |
commit | e2d6eb4148d5c575cea23617e938982bd5d93abc (patch) | |
tree | 25344ccccd768e936d249dfe83f98c522e805f62 | |
parent | 94e65ee0aecf0749e64fb29b4532c614e7be86a8 (diff) |
dhcpv4: dhcpv4: move interface lease list insertion out of dhcpv4_assign
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r-- | src/dhcpv4.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 976e1c9..db900c1 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -518,7 +518,6 @@ static bool dhcpv4_assign(struct interface *iface, // try to assign the IP the client asked for if (start <= raddr && raddr <= end && dhcpv4_test(iface, raddr)) { assign->addr = raddr; - list_add(&assign->head, &iface->dhcpv4_assignments); syslog(LOG_INFO, "assigning the IP the client asked for: %u.%u.%u.%u", (assign->addr & 0xff000000) >> 24, (assign->addr & 0x00ff0000) >> 16, @@ -541,7 +540,6 @@ static bool dhcpv4_assign(struct interface *iface, if (list_empty(&iface->dhcpv4_assignments)) { assign->addr = try; - list_add(&assign->head, &iface->dhcpv4_assignments); syslog(LOG_INFO, "assigning mapped IP (empty list): %u.%u.%u.%u", (assign->addr & 0xff000000) >> 24, (assign->addr & 0x00ff0000) >> 16, @@ -554,7 +552,6 @@ static bool dhcpv4_assign(struct interface *iface, if (dhcpv4_test(iface, try)) { /* test was successful: IP address is not assigned, assign it */ assign->addr = try; - list_add(&assign->head, &iface->dhcpv4_assignments); syslog(LOG_DEBUG, "assigning mapped IP: %u.%u.%u.%u (try %u of %u)", (assign->addr & 0xff000000) >> 24, (assign->addr & 0x00ff0000) >> 16, @@ -604,6 +601,8 @@ static struct dhcpv4_assignment* dhcpv4_lease(struct interface *iface, a->valid_until = now; assigned = dhcpv4_assign(iface, a, raddr); + if (assigned) + list_add(&a->head, &iface->dhcpv4_assignments); } if (a->leasetime) |