Commit 7480aeff authored by Simon Kelley's avatar Simon Kelley

Apply ceiling of lease length to TTL when --dhcp-ttl in use.

parent bec366b4
...@@ -1167,10 +1167,18 @@ int add_resource_record(struct dns_header *header, char *limit, int *truncp, int ...@@ -1167,10 +1167,18 @@ int add_resource_record(struct dns_header *header, char *limit, int *truncp, int
static unsigned long crec_ttl(struct crec *crecp, time_t now) static unsigned long crec_ttl(struct crec *crecp, time_t now)
{ {
/* Return 0 ttl for DHCP entries, which might change /* Return 0 ttl for DHCP entries, which might change
before the lease expires. */ before the lease expires, unless configured otherwise. */
if (crecp->flags & F_DHCP) if (crecp->flags & F_DHCP)
return daemon->use_dhcp_ttl ? daemon->dhcp_ttl : daemon->local_ttl; {
int conf_ttl = daemon->use_dhcp_ttl ? daemon->dhcp_ttl : daemon->local_ttl;
/* Apply ceiling of actual lease length to configured TTL. */
if (!(crecp->flags & F_IMMORTAL) && (crecp->ttd - now) < conf_ttl)
return crecp->ttd - now;
return conf_ttl;
}
/* Immortal entries other than DHCP are local, and hold TTL in TTD field. */ /* Immortal entries other than DHCP are local, and hold TTL in TTD field. */
if (crecp->flags & F_IMMORTAL) if (crecp->flags & F_IMMORTAL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment