]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/dnsmasq/0037-Allow-inotify-to-be-disabled-at-compile-time-on-Linu.patch
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next
[ipfire-2.x.git] / src / patches / dnsmasq / 0037-Allow-inotify-to-be-disabled-at-compile-time-on-Linu.patch
CommitLineData
6644c1c7
MT
1From 0491805d2ff6e7727f0272c94fd97d9897d1e22c Mon Sep 17 00:00:00 2001
2From: Simon Kelley <simon@thekelleys.org.uk>
3Date: Mon, 26 Jan 2015 11:23:43 +0000
697b4f04
MT
4Subject: [PATCH 037/113] Allow inotify to be disabled at compile time on
5 Linux.
6644c1c7
MT
6
7---
8 CHANGELOG | 4 +++-
9 src/config.h | 13 ++++++++++++-
10 src/dnsmasq.c | 21 +++++++++++++--------
11 src/dnsmasq.h | 11 +++++++----
12 src/inotify.c | 4 ++--
13 5 files changed, 37 insertions(+), 16 deletions(-)
14
15diff --git a/CHANGELOG b/CHANGELOG
16index a4cb901e83ae..c05dec63c587 100644
17--- a/CHANGELOG
18+++ b/CHANGELOG
19@@ -9,7 +9,9 @@ version 2.73
20
21 Use inotify for checking on updates to /etc/resolv.conf and
22 friends under Linux. This fixes race conditions when the files are
23- updated rapidly and saves CPU by noy polling.
24+ updated rapidly and saves CPU by noy polling. To build
25+ a binary that runs on old Linux kernels without inotify,
26+ use make COPTS=-DNO_INOTIFY
27
28 Fix breakage of --domain=<domain>,<subnet>,local - only reverse
29 queries were intercepted. THis appears to have been broken
30diff --git a/src/config.h b/src/config.h
31index cdca231b4079..5e5009271eba 100644
32--- a/src/config.h
33+++ b/src/config.h
34@@ -115,6 +115,8 @@ HAVE_DNSSEC
35 HAVE_LOOP
36 include functionality to probe for and remove DNS forwarding loops.
37
38+HAVE_INOTIFY
39+ use the Linux inotify facility to efficiently re-read configuration files.
40
41 NO_IPV6
42 NO_TFTP
43@@ -123,6 +125,7 @@ NO_DHCP6
44 NO_SCRIPT
45 NO_LARGEFILE
46 NO_AUTH
47+NO_INOTIFY
48 these are avilable to explictly disable compile time options which would
49 otherwise be enabled automatically (HAVE_IPV6, >2Gb file sizes) or
50 which are enabled by default in the distributed source tree. Building dnsmasq
51@@ -355,6 +358,10 @@ HAVE_SOCKADDR_SA_LEN
52 #undef HAVE_LOOP
53 #endif
54
55+#if defined (HAVE_LINUX_NETWORK) && !defined(NO_INOTIFY)
56+#define HAVE_INOTIFY
57+#endif
58+
59 /* Define a string indicating which options are in use.
60 DNSMASQP_COMPILE_OPTS is only defined in dnsmasq.c */
61
62@@ -428,7 +435,11 @@ static char *compile_opts =
63 #ifndef HAVE_LOOP
64 "no-"
65 #endif
66-"loop-detect";
67+"loop-detect "
68+#ifndef HAVE_INOTIFY
69+"no-"
70+#endif
71+"inotify";
72
73
74 #endif
75diff --git a/src/dnsmasq.c b/src/dnsmasq.c
76index 04cc98278f62..bc4f47170705 100644
77--- a/src/dnsmasq.c
78+++ b/src/dnsmasq.c
79@@ -142,7 +142,9 @@ int main (int argc, char **argv)
80 set_option_bool(OPT_NOWILD);
81 reset_option_bool(OPT_CLEVERBIND);
82 }
83+#endif
84
85+#ifndef HAVE_INOTIFY
86 if (daemon->inotify_hosts)
87 die(_("dhcp-hostsdir not supported on this platform"), NULL, EC_BADCONF);
88 #endif
89@@ -321,7 +323,7 @@ int main (int argc, char **argv)
90 #endif
91 }
92
93-#ifdef HAVE_LINUX_NETWORK
94+#ifdef HAVE_INOTIFY
95 if ((!option_bool(OPT_NO_POLL) && daemon->port != 0) ||
96 daemon->dhcp || daemon->doing_dhcp6)
97 inotify_dnsmasq_init();
98@@ -802,7 +804,7 @@ int main (int argc, char **argv)
99
100 pid = getpid();
101
102-#ifdef HAVE_LINUX_NETWORK
103+#ifdef HAVE_INOTIFY
104 /* Using inotify, have to select a resolv file at startup */
105 poll_resolv(1, 0, now);
106 #endif
107@@ -872,15 +874,18 @@ int main (int argc, char **argv)
108 bump_maxfd(daemon->icmp6fd, &maxfd);
109 }
110 #endif
111-
112-#if defined(HAVE_LINUX_NETWORK)
113- FD_SET(daemon->netlinkfd, &rset);
114- bump_maxfd(daemon->netlinkfd, &maxfd);
115+
116+#ifdef HAVE_INOTIFY
117 if (daemon->inotifyfd != -1)
118 {
119 FD_SET(daemon->inotifyfd, &rset);
120 bump_maxfd(daemon->inotifyfd, &maxfd);
121 }
122+#endif
123+
124+#if defined(HAVE_LINUX_NETWORK)
125+ FD_SET(daemon->netlinkfd, &rset);
126+ bump_maxfd(daemon->netlinkfd, &maxfd);
127 #elif defined(HAVE_BSD_NETWORK)
128 FD_SET(daemon->routefd, &rset);
129 bump_maxfd(daemon->routefd, &maxfd);
130@@ -948,7 +953,7 @@ int main (int argc, char **argv)
131 route_sock();
132 #endif
133
134-#ifdef HAVE_LINUX_NETWORK
135+#ifdef HAVE_INOTIFY
136 if (daemon->inotifyfd != -1 && FD_ISSET(daemon->inotifyfd, &rset) && inotify_check(now))
137 {
138 if (daemon->port != 0 && !option_bool(OPT_NO_POLL))
139@@ -1394,7 +1399,7 @@ void clear_cache_and_reload(time_t now)
140 if (option_bool(OPT_ETHERS))
141 dhcp_read_ethers();
142 reread_dhcp();
143-#ifdef HAVE_LINUX_NETWORK
144+#ifdef HAVE_INOTIFY
145 set_dhcp_inotify();
146 #endif
147 dhcp_update_configs(daemon->dhcp_conf);
148diff --git a/src/dnsmasq.h b/src/dnsmasq.h
149index d841fdc064ad..8091634f69db 100644
150--- a/src/dnsmasq.h
151+++ b/src/dnsmasq.h
152@@ -544,7 +544,7 @@ struct resolvc {
153 int is_default, logged;
154 time_t mtime;
155 char *name;
156-#ifdef HAVE_LINUX_NETWORK
157+#ifdef HAVE_INOTIFY
158 int wd; /* inotify watch descriptor */
159 char *file; /* pointer to file part if path */
160 #endif
161@@ -558,7 +558,7 @@ struct hostsfile {
162 struct hostsfile *next;
163 int flags;
164 char *fname;
165-#ifdef HAVE_LINUX_NETWORK
166+#ifdef HAVE_INOTIFY
167 int wd; /* inotify watch descriptor */
168 #endif
169 unsigned int index; /* matches to cache entries for logging */
170@@ -1013,8 +1013,11 @@ extern struct daemon {
171
172 /* DHCP state */
173 int dhcpfd, helperfd, pxefd;
174+#ifdef HAVE_INOTIFY
175+ int inotifyfd;
176+#endif
177 #if defined(HAVE_LINUX_NETWORK)
178- int netlinkfd, inotifyfd;
179+ int netlinkfd;
180 #elif defined(HAVE_BSD_NETWORK)
181 int dhcp_raw_fd, dhcp_icmp_fd, routefd;
182 #endif
183@@ -1488,7 +1491,7 @@ int detect_loop(char *query, int type);
184 #endif
185
186 /* inotify.c */
187-#ifdef HAVE_LINUX_NETWORK
188+#ifdef HAVE_INOTIFY
189 void inotify_dnsmasq_init();
190 int inotify_check(time_t now);
191 # ifdef HAVE_DHCP
192diff --git a/src/inotify.c b/src/inotify.c
193index 52a30d7f44db..818fe8eddda4 100644
194--- a/src/inotify.c
195+++ b/src/inotify.c
196@@ -15,7 +15,7 @@
197 */
198
199 #include "dnsmasq.h"
200-#ifdef HAVE_LINUX_NETWORK
201+#ifdef HAVE_INOTIFY
202
203 #include <sys/inotify.h>
204
205@@ -216,5 +216,5 @@ static void check_for_dhcp_inotify(struct inotify_event *in, time_t now)
206
207 #endif /* DHCP */
208
209-#endif /* LINUX_NETWORK */
210+#endif /* INOTIFY */
211
212--
2132.1.0
214