]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/dnsmasq/005-Apply_ceiling_of_lease_length_to_TTL_when_--dhcp-ttl_in_use.patch
Merge branch 'bird' into next
[ipfire-2.x.git] / src / patches / dnsmasq / 005-Apply_ceiling_of_lease_length_to_TTL_when_--dhcp-ttl_in_use.patch
1 From 7480aeffc8ad195e9fd8bcf424bae0fab3839d55 Mon Sep 17 00:00:00 2001
2 From: Simon Kelley <simon@thekelleys.org.uk>
3 Date: Fri, 26 Feb 2016 21:58:20 +0000
4 Subject: [PATCH] Apply ceiling of lease length to TTL when --dhcp-ttl in use.
5
6 ---
7 src/rfc1035.c | 12 ++++++++++--
8 1 file changed, 10 insertions(+), 2 deletions(-)
9
10 diff --git a/src/rfc1035.c b/src/rfc1035.c
11 index 8f1e3b4..bed5312 100644
12 --- a/src/rfc1035.c
13 +++ b/src/rfc1035.c
14 @@ -1167,10 +1167,18 @@ int add_resource_record(struct dns_header *header, char *limit, int *truncp, int
15 static unsigned long crec_ttl(struct crec *crecp, time_t now)
16 {
17 /* Return 0 ttl for DHCP entries, which might change
18 - before the lease expires. */
19 + before the lease expires, unless configured otherwise. */
20
21 if (crecp->flags & F_DHCP)
22 - return daemon->use_dhcp_ttl ? daemon->dhcp_ttl : daemon->local_ttl;
23 + {
24 + int conf_ttl = daemon->use_dhcp_ttl ? daemon->dhcp_ttl : daemon->local_ttl;
25 +
26 + /* Apply ceiling of actual lease length to configured TTL. */
27 + if (!(crecp->flags & F_IMMORTAL) && (crecp->ttd - now) < conf_ttl)
28 + return crecp->ttd - now;
29 +
30 + return conf_ttl;
31 + }
32
33 /* Immortal entries other than DHCP are local, and hold TTL in TTD field. */
34 if (crecp->flags & F_IMMORTAL)
35 --
36 1.7.10.4
37