1. Added patch 005 because of the discussion on the dnsmasq-list: "I've noticed that replies which get their TTL from the dhcp-ttl option always get the TTL specified in dhcp-ttl. I'd prefer something like max(0, min(<dhcp-ttl>, <lease-expire-time> - <now>)). Otherwise, dns might hand out a high TTL for a dhcp-lease which expires one second later. ... Seems a sensible addition.
Cheers,
Simon."
2. Fixed several line numbers and patch lines in 'dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch'. On the last build I got some "Hunk failed" messages. Patches are now applied exactly at the given lines.
3. Nevertheless, I still get some warnings: ... dnsmasq.c: In function 'main': dnsmasq.c:55:7: warning: unused variable 'did_bind' [-Wunused-variable] int did_bind = 0; ^ dnsmasq.c:54:9: warning: unused variable 'bound_device' [-Wunused-variable] char *bound_device = NULL; ^ ... isc.c: In function 'dhcp_lease_new': isc.c:40:3: warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result] asprintf(&lease->fqdn, "%s.%s", hostname, daemon->domain_suffix); ^
Asking about these warnings in the dnsmasq-list showed no reaction - no one answered.
Best, Matthias
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org --- lfs/dnsmasq | 1 + ...q-Add-support-to-read-ISC-DHCP-lease-file.patch | 14 ++++---- ...ease_length_to_TTL_when_--dhcp-ttl_in_use.patch | 37 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 src/patches/dnsmasq/005-Apply_ceiling_of_lease_length_to_TTL_when_--dhcp-ttl_in_use.patch
diff --git a/lfs/dnsmasq b/lfs/dnsmasq index 29d7895..84585c1 100644 --- a/lfs/dnsmasq +++ b/lfs/dnsmasq @@ -77,6 +77,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/002-Add_--dhcp-ttl_option.patch cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/003-Update_CHANGELOG.patch cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/004-Add_--tftp-mtu_option.patch + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/005-Apply_ceiling_of_lease_length_to_TTL_when_--dhcp-ttl_in_use.patch cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch
cd $(DIR_APP) && sed -i src/config.h \ diff --git a/src/patches/dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch b/src/patches/dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch index f55ebe8..703e94f 100644 --- a/src/patches/dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch +++ b/src/patches/dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch @@ -19,7 +19,7 @@ #ifdef HAVE_DNSSEC cache_blockdata_free(crecp); #endif -@@ -1131,7 +1134,7 @@ +@@ -1138,7 +1141,7 @@
}
@@ -28,7 +28,7 @@ struct in_addr a_record_from_hosts(char *name, time_t now) { struct crec *crecp = NULL; -@@ -1274,7 +1277,11 @@ +@@ -1281,7 +1284,11 @@ else crec->ttd = ttd; crec->addr.addr = *host_address; @@ -42,7 +42,7 @@
--- a/src/dnsmasq.c Thu Jul 30 20:59:06 2015 +++ b/src/dnsmasq.c Wed Dec 16 19:38:32 2015 -@@ -982,6 +982,11 @@ +@@ -1013,6 +1013,11 @@
poll_resolv(0, daemon->last_resolv != 0, now); daemon->last_resolv = now; @@ -56,7 +56,7 @@
--- a/src/dnsmasq.h Wed Dec 16 19:24:12 2015 +++ b/src/dnsmasq.h Wed Dec 16 19:40:11 2015 -@@ -1513,8 +1513,12 @@ +@@ -1514,6 +1514,11 @@ void poll_listen(int fd, short event); int do_poll(int timeout);
@@ -326,7 +326,7 @@ +#endif --- a/src/option.c Wed Dec 16 19:24:12 2015 +++ b/src/option.c Wed Dec 16 19:42:48 2015 -@@ -1754,7 +1754,7 @@ +@@ -1769,7 +1769,7 @@ ret_err(_("bad MX target")); break;
@@ -341,8 +341,8 @@ helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o \ dhcp-common.o outpacket.o radv.o slaac.o auth.o ipset.o \ domain.o dnssec.o blockdata.o tables.o loop.o inotify.o \ -- poll.o rrfilter.o -+ poll.o rrfilter.o isc.o +- poll.o rrfilter.o edns0.o arp.o ++ poll.o rrfilter.o edns0.o arp.o isc.o
hdrs = dnsmasq.h config.h dhcp-protocol.h dhcp6-protocol.h \ dns-protocol.h radv-protocol.h ip6addr.h diff --git a/src/patches/dnsmasq/005-Apply_ceiling_of_lease_length_to_TTL_when_--dhcp-ttl_in_use.patch b/src/patches/dnsmasq/005-Apply_ceiling_of_lease_length_to_TTL_when_--dhcp-ttl_in_use.patch new file mode 100644 index 0000000..2875d2c --- /dev/null +++ b/src/patches/dnsmasq/005-Apply_ceiling_of_lease_length_to_TTL_when_--dhcp-ttl_in_use.patch @@ -0,0 +1,37 @@ +From 7480aeffc8ad195e9fd8bcf424bae0fab3839d55 Mon Sep 17 00:00:00 2001 +From: Simon Kelley simon@thekelleys.org.uk +Date: Fri, 26 Feb 2016 21:58:20 +0000 +Subject: [PATCH] Apply ceiling of lease length to TTL when --dhcp-ttl in use. + +--- + src/rfc1035.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/src/rfc1035.c b/src/rfc1035.c +index 8f1e3b4..bed5312 100644 +--- a/src/rfc1035.c ++++ b/src/rfc1035.c +@@ -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) + { + /* 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) +- 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. */ + if (crecp->flags & F_IMMORTAL) +-- +1.7.10.4 +