leasefile: do not output expired dhcpv6 leases
authorNikolay Martynov <mar.kolya@gmail.com>
Tue, 1 Jul 2014 02:42:55 +0000 (22:42 -0400)
committerNikolay Martynov <mar.kolya@gmail.com>
Tue, 1 Jul 2014 02:47:30 +0000 (22:47 -0400)
Sometimes ip that is assigned to a host changes, old ip is still kept aroung as 'expired'.
This expired ip gets dumped into leasefile and is read by dnsmasq.
The result is that hotsname is resolved into expired ip and that confuses clients.
This patch prevents expired leases from being written into leasefile.

src/dhcpv6-ia.c

index 181973d..fe47130 100644 (file)
@@ -258,6 +258,8 @@ void dhcpv6_write_statefile(void)
                                        for (size_t i = 0; i < addrlen; ++i) {
                                                if (addrs[i].prefix > 96)
                                                        continue;
                                        for (size_t i = 0; i < addrlen; ++i) {
                                                if (addrs[i].prefix > 96)
                                                        continue;
+                                               if (c->valid_until <= now)
+                                                       continue;
 
                                                addr = addrs[i].addr;
                                                if (c->length == 128)
 
                                                addr = addrs[i].addr;
                                                if (c->length == 128)