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