]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/dnsmasq/002-Add_--dhcp-ttl_option.patch
procps: Update to 3.2.8
[people/pmueller/ipfire-2.x.git] / src / patches / dnsmasq / 002-Add_--dhcp-ttl_option.patch
CommitLineData
3b9815eb
MF
1From 832e47beab95c2918b5264f0504f2fe6fe523e4c Mon Sep 17 00:00:00 2001
2From: Simon Kelley <simon@thekelleys.org.uk>
3Date: Wed, 24 Feb 2016 21:24:45 +0000
4Subject: [PATCH] Add --dhcp-ttl option.
5
6---
7 man/dnsmasq.8 | 5 ++++-
8 src/dnsmasq.h | 2 +-
9 src/option.c | 13 +++++++++++--
10 src/rfc1035.c | 2 +-
11 4 files changed, 17 insertions(+), 5 deletions(-)
12
13diff --git a/man/dnsmasq.8 b/man/dnsmasq.8
14index 7bc1394..2bcce20 100644
15--- a/man/dnsmasq.8
16+++ b/man/dnsmasq.8
17@@ -60,7 +60,7 @@ in the same way as for DHCP-derived names. Note that this does not
18 apply to domain names in cnames, PTR records, TXT records etc.
19 .TP
20 .B \-T, --local-ttl=<time>
21-When replying with information from /etc/hosts or the DHCP leases
22+When replying with information from /etc/hosts or configuration or the DHCP leases
23 file dnsmasq by default sets the time-to-live field to zero, meaning
24 that the requester should not itself cache the information. This is
25 the correct thing to do in almost all situations. This option allows a
26@@ -68,6 +68,9 @@ time-to-live (in seconds) to be given for these replies. This will
27 reduce the load on the server at the expense of clients using stale
28 data under some circumstances.
29 .TP
30+.B --dhcp-ttl=<time>
31+As for --local-ttl, but affects only replies with information from DHCP leases. If both are given, --dhcp-ttl applies for DHCP information, and --local-ttl for others. Setting this to zero eliminates the effect of --local-ttl for DHCP.
32+.TP
33 .B --neg-ttl=<time>
34 Negative replies from upstream servers normally contain time-to-live
35 information in SOA records which dnsmasq uses for caching. If the
36diff --git a/src/dnsmasq.h b/src/dnsmasq.h
37index 6344df5..9f73c3b 100644
38--- a/src/dnsmasq.h
39+++ b/src/dnsmasq.h
40@@ -955,7 +955,7 @@ extern struct daemon {
41 int max_logs; /* queue limit */
42 int cachesize, ftabsize;
43 int port, query_port, min_port, max_port;
44- unsigned long local_ttl, neg_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl;
45+ unsigned long local_ttl, neg_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl, dhcp_ttl, use_dhcp_ttl;
46 char *dns_client_id;
47 struct hostsfile *addn_hosts;
48 struct dhcp_context *dhcp, *dhcp6;
49diff --git a/src/option.c b/src/option.c
50index 7c5e6bc..3f6d162 100644
51--- a/src/option.c
52+++ b/src/option.c
53@@ -157,6 +157,7 @@ struct myoption {
54 #define LOPT_MAXPORT 345
55 #define LOPT_CPE_ID 346
56 #define LOPT_SCRIPT_ARP 347
57+#define LOPT_DHCPTTL 348
58
59 #ifdef HAVE_GETOPT_LONG
60 static const struct option opts[] =
61@@ -319,6 +320,7 @@ static const struct myoption opts[] =
62 { "quiet-ra", 0, 0, LOPT_QUIET_RA },
63 { "dns-loop-detect", 0, 0, LOPT_LOOP_DETECT },
64 { "script-arp", 0, 0, LOPT_SCRIPT_ARP },
65+ { "dhcp-ttl", 1, 0 , LOPT_DHCPTTL },
66 { NULL, 0, 0, 0 }
67 };
68
69@@ -485,9 +487,10 @@ static struct {
70 { LOPT_QUIET_DHCP, OPT_QUIET_DHCP, NULL, gettext_noop("Do not log routine DHCP."), NULL },
71 { LOPT_QUIET_DHCP6, OPT_QUIET_DHCP6, NULL, gettext_noop("Do not log routine DHCPv6."), NULL },
72 { LOPT_QUIET_RA, OPT_QUIET_RA, NULL, gettext_noop("Do not log RA."), NULL },
73- { LOPT_LOCAL_SERVICE, OPT_LOCAL_SERVICE, NULL, gettext_noop("Accept queries only from directly-connected networks"), NULL },
74- { LOPT_LOOP_DETECT, OPT_LOOP_DETECT, NULL, gettext_noop("Detect and remove DNS forwarding loops"), NULL },
75+ { LOPT_LOCAL_SERVICE, OPT_LOCAL_SERVICE, NULL, gettext_noop("Accept queries only from directly-connected networks."), NULL },
76+ { LOPT_LOOP_DETECT, OPT_LOOP_DETECT, NULL, gettext_noop("Detect and remove DNS forwarding loops."), NULL },
77 { LOPT_IGNORE_ADDR, ARG_DUP, "<ipaddr>", gettext_noop("Ignore DNS responses containing ipaddr."), NULL },
78+ { LOPT_DHCPTTL, ARG_ONE, "<ttl>", gettext_noop("Set TTL in DNS responses with DHCP-derived addresses."), NULL },
79 { 0, 0, NULL, NULL, NULL }
80 };
81
82@@ -2580,6 +2583,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
83 case LOPT_MINCTTL: /* --min-cache-ttl */
84 case LOPT_MAXCTTL: /* --max-cache-ttl */
85 case LOPT_AUTHTTL: /* --auth-ttl */
86+ case LOPT_DHCPTTL: /* --dhcp-ttl */
87 {
88 int ttl;
89 if (!atoi_check(arg, &ttl))
90@@ -2598,6 +2602,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
91 daemon->max_cache_ttl = (unsigned long)ttl;
92 else if (option == LOPT_AUTHTTL)
93 daemon->auth_ttl = (unsigned long)ttl;
94+ else if (option == LOPT_DHCPTTL)
95+ {
96+ daemon->dhcp_ttl = (unsigned long)ttl;
97+ daemon->use_dhcp_ttl = 1;
98+ }
99 else
100 daemon->local_ttl = (unsigned long)ttl;
101 break;
102diff --git a/src/rfc1035.c b/src/rfc1035.c
103index 3535a71..8f1e3b4 100644
104--- a/src/rfc1035.c
105+++ b/src/rfc1035.c
106@@ -1170,7 +1170,7 @@ static unsigned long crec_ttl(struct crec *crecp, time_t now)
107 before the lease expires. */
108
109 if (crecp->flags & F_DHCP)
110- return daemon->local_ttl;
111+ return daemon->use_dhcp_ttl ? daemon->dhcp_ttl : daemon->local_ttl;
112
113 /* Immortal entries other than DHCP are local, and hold TTL in TTD field. */
114 if (crecp->flags & F_IMMORTAL)
115--
1161.7.10.4
117