dnsmasq: bump to 2.81
This commit is contained in:
parent
a47b953854
commit
e57fe791fc
@ -8,12 +8,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=dnsmasq
|
||||
PKG_VERSION:=2.80
|
||||
PKG_RELEASE:=12
|
||||
PKG_VERSION:=2.81
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq
|
||||
PKG_HASH:=cdaba2785e92665cf090646cba6f94812760b9d7d8c8d0cfb07ac819377a63bb
|
||||
PKG_HASH:=749ca903537c5197c26444ac24b0dce242cf42595fdfe6b9a5b9e4c7ad32f8fb
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
@ -1,495 +0,0 @@
|
||||
From a799ca0c6314ad73a97bc6c89382d2712a9c0b0e Mon Sep 17 00:00:00 2001
|
||||
From: Simon Kelley <simon@thekelleys.org.uk>
|
||||
Date: Thu, 18 Oct 2018 19:35:29 +0100
|
||||
Subject: [PATCH 01/11] Impove cache behaviour for TCP connections.
|
||||
|
||||
For ease of implementaion, dnsmasq has always forked a new process to
|
||||
handle each incoming TCP connection. A side-effect of this is that any
|
||||
DNS queries answered from TCP connections are not cached: when TCP
|
||||
connections were rare, this was not a problem. With the coming of
|
||||
DNSSEC, it's now the case that some DNSSEC queries have answers which
|
||||
spill to TCP, and if, for instance, this applies to the keys for the
|
||||
root then those never get cached, and performance is very bad. This
|
||||
fix passes cache entries back from the TCP child process to the main
|
||||
server process, and fixes the problem.
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
CHANGELOG | 14 ++++
|
||||
src/blockdata.c | 37 ++++++++-
|
||||
src/cache.c | 196 ++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
src/dnsmasq.c | 58 ++++++++++++--
|
||||
src/dnsmasq.h | 5 ++
|
||||
5 files changed, 291 insertions(+), 19 deletions(-)
|
||||
|
||||
--- a/CHANGELOG
|
||||
+++ b/CHANGELOG
|
||||
@@ -1,3 +1,17 @@
|
||||
+version 2.81
|
||||
+ Impove cache behaviour for TCP connections. For ease of
|
||||
+ implementaion, dnsmasq has always forked a new process to handle
|
||||
+ each incoming TCP connection. A side-effect of this is that
|
||||
+ any DNS queries answered from TCP connections are not cached:
|
||||
+ when TCP connections were rare, this was not a problem.
|
||||
+ With the coming of DNSSEC, it's now the case that some
|
||||
+ DNSSEC queries have answers which spill to TCP, and if,
|
||||
+ for instance, this applies to the keys for the root then
|
||||
+ those never get cached, and performance is very bad.
|
||||
+ This fix passes cache entries back from the TCP child process to
|
||||
+ the main server process, and fixes the problem.
|
||||
+
|
||||
+
|
||||
version 2.80
|
||||
Add support for RFC 4039 DHCP rapid commit. Thanks to Ashram Method
|
||||
for the initial patch and motivation.
|
||||
--- a/src/blockdata.c
|
||||
+++ b/src/blockdata.c
|
||||
@@ -61,7 +61,7 @@ void blockdata_report(void)
|
||||
blockdata_alloced * sizeof(struct blockdata));
|
||||
}
|
||||
|
||||
-struct blockdata *blockdata_alloc(char *data, size_t len)
|
||||
+static struct blockdata *blockdata_alloc_real(int fd, char *data, size_t len)
|
||||
{
|
||||
struct blockdata *block, *ret = NULL;
|
||||
struct blockdata **prev = &ret;
|
||||
@@ -89,8 +89,17 @@ struct blockdata *blockdata_alloc(char *
|
||||
blockdata_hwm = blockdata_count;
|
||||
|
||||
blen = len > KEYBLOCK_LEN ? KEYBLOCK_LEN : len;
|
||||
- memcpy(block->key, data, blen);
|
||||
- data += blen;
|
||||
+ if (data)
|
||||
+ {
|
||||
+ memcpy(block->key, data, blen);
|
||||
+ data += blen;
|
||||
+ }
|
||||
+ else if (!read_write(fd, block->key, blen, 1))
|
||||
+ {
|
||||
+ /* failed read free partial chain */
|
||||
+ blockdata_free(ret);
|
||||
+ return NULL;
|
||||
+ }
|
||||
len -= blen;
|
||||
*prev = block;
|
||||
prev = &block->next;
|
||||
@@ -100,6 +109,10 @@ struct blockdata *blockdata_alloc(char *
|
||||
return ret;
|
||||
}
|
||||
|
||||
+struct blockdata *blockdata_alloc(char *data, size_t len)
|
||||
+{
|
||||
+ return blockdata_alloc_real(0, data, len);
|
||||
+}
|
||||
|
||||
void blockdata_free(struct blockdata *blocks)
|
||||
{
|
||||
@@ -148,5 +161,21 @@ void *blockdata_retrieve(struct blockdat
|
||||
|
||||
return data;
|
||||
}
|
||||
-
|
||||
+
|
||||
+
|
||||
+void blockdata_write(struct blockdata *block, size_t len, int fd)
|
||||
+{
|
||||
+ for (; len > 0 && block; block = block->next)
|
||||
+ {
|
||||
+ size_t blen = len > KEYBLOCK_LEN ? KEYBLOCK_LEN : len;
|
||||
+ read_write(fd, block->key, blen, 0);
|
||||
+ len -= blen;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+struct blockdata *blockdata_read(int fd, size_t len)
|
||||
+{
|
||||
+ return blockdata_alloc_real(fd, NULL, len);
|
||||
+}
|
||||
+
|
||||
#endif
|
||||
--- a/src/cache.c
|
||||
+++ b/src/cache.c
|
||||
@@ -26,6 +26,8 @@ static union bigname *big_free = NULL;
|
||||
static int bignames_left, hash_size;
|
||||
|
||||
static void make_non_terminals(struct crec *source);
|
||||
+static struct crec *really_insert(char *name, struct all_addr *addr,
|
||||
+ time_t now, unsigned long ttl, unsigned short flags);
|
||||
|
||||
/* type->string mapping: this is also used by the name-hash function as a mixing table. */
|
||||
static const struct {
|
||||
@@ -464,16 +466,10 @@ void cache_start_insert(void)
|
||||
new_chain = NULL;
|
||||
insert_error = 0;
|
||||
}
|
||||
-
|
||||
+
|
||||
struct crec *cache_insert(char *name, struct all_addr *addr,
|
||||
time_t now, unsigned long ttl, unsigned short flags)
|
||||
{
|
||||
- struct crec *new, *target_crec = NULL;
|
||||
- union bigname *big_name = NULL;
|
||||
- int freed_all = flags & F_REVERSE;
|
||||
- int free_avail = 0;
|
||||
- unsigned int target_uid;
|
||||
-
|
||||
/* Don't log DNSSEC records here, done elsewhere */
|
||||
if (flags & (F_IPV4 | F_IPV6 | F_CNAME))
|
||||
{
|
||||
@@ -484,7 +480,20 @@ struct crec *cache_insert(char *name, st
|
||||
if (daemon->min_cache_ttl != 0 && daemon->min_cache_ttl > ttl)
|
||||
ttl = daemon->min_cache_ttl;
|
||||
}
|
||||
+
|
||||
+ return really_insert(name, addr, now, ttl, flags);
|
||||
+}
|
||||
|
||||
+
|
||||
+static struct crec *really_insert(char *name, struct all_addr *addr,
|
||||
+ time_t now, unsigned long ttl, unsigned short flags)
|
||||
+{
|
||||
+ struct crec *new, *target_crec = NULL;
|
||||
+ union bigname *big_name = NULL;
|
||||
+ int freed_all = flags & F_REVERSE;
|
||||
+ int free_avail = 0;
|
||||
+ unsigned int target_uid;
|
||||
+
|
||||
/* if previous insertion failed give up now. */
|
||||
if (insert_error)
|
||||
return NULL;
|
||||
@@ -645,12 +654,185 @@ void cache_end_insert(void)
|
||||
cache_hash(new_chain);
|
||||
cache_link(new_chain);
|
||||
daemon->metrics[METRIC_DNS_CACHE_INSERTED]++;
|
||||
+
|
||||
+ /* If we're a child process, send this cache entry up the pipe to the master.
|
||||
+ The marshalling process is rather nasty. */
|
||||
+ if (daemon->pipe_to_parent != -1)
|
||||
+ {
|
||||
+ char *name = cache_get_name(new_chain);
|
||||
+ ssize_t m = strlen(name);
|
||||
+ unsigned short flags = new_chain->flags;
|
||||
+#ifdef HAVE_DNSSEC
|
||||
+ u16 class = new_chain->uid;
|
||||
+#endif
|
||||
+
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&m, sizeof(m), 0);
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)name, m, 0);
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->ttd, sizeof(new_chain->ttd), 0);
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&flags, sizeof(flags), 0);
|
||||
+
|
||||
+ if (flags & (F_IPV4 | F_IPV6))
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->addr, sizeof(new_chain->addr), 0);
|
||||
+#ifdef HAVE_DNSSEC
|
||||
+ else if (flags & F_DNSKEY)
|
||||
+ {
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&class, sizeof(class), 0);
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->addr.key.algo, sizeof(new_chain->addr.key.algo), 0);
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->addr.key.keytag, sizeof(new_chain->addr.key.keytag), 0);
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->addr.key.flags, sizeof(new_chain->addr.key.flags), 0);
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->addr.key.keylen, sizeof(new_chain->addr.key.keylen), 0);
|
||||
+ blockdata_write(new_chain->addr.key.keydata, new_chain->addr.key.keylen, daemon->pipe_to_parent);
|
||||
+ }
|
||||
+ else if (flags & F_DS)
|
||||
+ {
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&class, sizeof(class), 0);
|
||||
+ /* A negative DS entry is possible and has no data, obviously. */
|
||||
+ if (!(flags & F_NEG))
|
||||
+ {
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->addr.ds.algo, sizeof(new_chain->addr.ds.algo), 0);
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->addr.ds.keytag, sizeof(new_chain->addr.ds.keytag), 0);
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->addr.ds.digest, sizeof(new_chain->addr.ds.digest), 0);
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&new_chain->addr.ds.keylen, sizeof(new_chain->addr.ds.keylen), 0);
|
||||
+ blockdata_write(new_chain->addr.ds.keydata, new_chain->addr.ds.keylen, daemon->pipe_to_parent);
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ }
|
||||
}
|
||||
+
|
||||
new_chain = tmp;
|
||||
}
|
||||
+
|
||||
+ /* signal end of cache insert in master process */
|
||||
+ if (daemon->pipe_to_parent != -1)
|
||||
+ {
|
||||
+ ssize_t m = -1;
|
||||
+ read_write(daemon->pipe_to_parent, (unsigned char *)&m, sizeof(m), 0);
|
||||
+ }
|
||||
+
|
||||
new_chain = NULL;
|
||||
}
|
||||
|
||||
+
|
||||
+/* A marshalled cache entry arrives on fd, read, unmarshall and insert into cache of master process. */
|
||||
+int cache_recv_insert(time_t now, int fd)
|
||||
+{
|
||||
+ ssize_t m;
|
||||
+ struct all_addr addr;
|
||||
+ unsigned long ttl;
|
||||
+ time_t ttd;
|
||||
+ unsigned short flags;
|
||||
+ struct crec *crecp = NULL;
|
||||
+
|
||||
+ cache_start_insert();
|
||||
+
|
||||
+ while(1)
|
||||
+ {
|
||||
+
|
||||
+ if (!read_write(fd, (unsigned char *)&m, sizeof(m), 1))
|
||||
+ return 0;
|
||||
+
|
||||
+ if (m == -1)
|
||||
+ {
|
||||
+ cache_end_insert();
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ if (!read_write(fd, (unsigned char *)daemon->namebuff, m, 1) ||
|
||||
+ !read_write(fd, (unsigned char *)&ttd, sizeof(ttd), 1) ||
|
||||
+ !read_write(fd, (unsigned char *)&flags, sizeof(flags), 1))
|
||||
+ return 0;
|
||||
+
|
||||
+ daemon->namebuff[m] = 0;
|
||||
+
|
||||
+ ttl = difftime(ttd, now);
|
||||
+
|
||||
+ if (flags & (F_IPV4 | F_IPV6))
|
||||
+ {
|
||||
+ if (!read_write(fd, (unsigned char *)&addr, sizeof(addr), 1))
|
||||
+ return 0;
|
||||
+ crecp = really_insert(daemon->namebuff, &addr, now, ttl, flags);
|
||||
+ }
|
||||
+ else if (flags & F_CNAME)
|
||||
+ {
|
||||
+ struct crec *newc = really_insert(daemon->namebuff, NULL, now, ttl, flags);
|
||||
+ /* This relies on the fact the the target of a CNAME immediately preceeds
|
||||
+ it because of the order of extraction in extract_addresses, and
|
||||
+ the order reversal on the new_chain. */
|
||||
+ if (newc)
|
||||
+ {
|
||||
+ if (!crecp)
|
||||
+ {
|
||||
+ newc->addr.cname.target.cache = NULL;
|
||||
+ /* anything other than zero, to avoid being mistaken for CNAME to interface-name */
|
||||
+ newc->addr.cname.uid = 1;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ next_uid(crecp);
|
||||
+ newc->addr.cname.target.cache = crecp;
|
||||
+ newc->addr.cname.uid = crecp->uid;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+#ifdef HAVE_DNSSEC
|
||||
+ else if (flags & (F_DNSKEY | F_DS))
|
||||
+ {
|
||||
+ unsigned short class, keylen, keyflags, keytag;
|
||||
+ unsigned char algo, digest;
|
||||
+ struct blockdata *keydata;
|
||||
+
|
||||
+ if (!read_write(fd, (unsigned char *)&class, sizeof(class), 1))
|
||||
+ return 0;
|
||||
+ /* Cache needs to known class for DNSSEC stuff */
|
||||
+ addr.addr.dnssec.class = class;
|
||||
+
|
||||
+ crecp = really_insert(daemon->namebuff, &addr, now, ttl, flags);
|
||||
+
|
||||
+ if (flags & F_DNSKEY)
|
||||
+ {
|
||||
+ if (!read_write(fd, (unsigned char *)&algo, sizeof(algo), 1) ||
|
||||
+ !read_write(fd, (unsigned char *)&keytag, sizeof(keytag), 1) ||
|
||||
+ !read_write(fd, (unsigned char *)&keyflags, sizeof(keyflags), 1) ||
|
||||
+ !read_write(fd, (unsigned char *)&keylen, sizeof(keylen), 1) ||
|
||||
+ !(keydata = blockdata_read(fd, keylen)))
|
||||
+ return 0;
|
||||
+ }
|
||||
+ else if (!(flags & F_NEG))
|
||||
+ {
|
||||
+ if (!read_write(fd, (unsigned char *)&algo, sizeof(algo), 1) ||
|
||||
+ !read_write(fd, (unsigned char *)&keytag, sizeof(keytag), 1) ||
|
||||
+ !read_write(fd, (unsigned char *)&digest, sizeof(digest), 1) ||
|
||||
+ !read_write(fd, (unsigned char *)&keylen, sizeof(keylen), 1) ||
|
||||
+ !(keydata = blockdata_read(fd, keylen)))
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (crecp)
|
||||
+ {
|
||||
+ if (flags & F_DNSKEY)
|
||||
+ {
|
||||
+ crecp->addr.key.algo = algo;
|
||||
+ crecp->addr.key.keytag = keytag;
|
||||
+ crecp->addr.key.flags = flags;
|
||||
+ crecp->addr.key.keylen = keylen;
|
||||
+ crecp->addr.key.keydata = keydata;
|
||||
+ }
|
||||
+ else if (!(flags & F_NEG))
|
||||
+ {
|
||||
+ crecp->addr.ds.algo = algo;
|
||||
+ crecp->addr.ds.keytag = keytag;
|
||||
+ crecp->addr.ds.digest = digest;
|
||||
+ crecp->addr.ds.keylen = keylen;
|
||||
+ crecp->addr.ds.keydata = keydata;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
int cache_find_non_terminal(char *name, time_t now)
|
||||
{
|
||||
struct crec *crecp;
|
||||
--- a/src/dnsmasq.c
|
||||
+++ b/src/dnsmasq.c
|
||||
@@ -930,6 +930,10 @@ int main (int argc, char **argv)
|
||||
check_servers();
|
||||
|
||||
pid = getpid();
|
||||
+
|
||||
+ daemon->pipe_to_parent = -1;
|
||||
+ for (i = 0; i < MAX_PROCS; i++)
|
||||
+ daemon->tcp_pipes[i] = -1;
|
||||
|
||||
#ifdef HAVE_INOTIFY
|
||||
/* Using inotify, have to select a resolv file at startup */
|
||||
@@ -1611,7 +1615,7 @@ static int set_dns_listeners(time_t now)
|
||||
we don't need to explicitly arrange to wake up here */
|
||||
if (listener->tcpfd != -1)
|
||||
for (i = 0; i < MAX_PROCS; i++)
|
||||
- if (daemon->tcp_pids[i] == 0)
|
||||
+ if (daemon->tcp_pids[i] == 0 && daemon->tcp_pipes[i] == -1)
|
||||
{
|
||||
poll_listen(listener->tcpfd, POLLIN);
|
||||
break;
|
||||
@@ -1624,6 +1628,13 @@ static int set_dns_listeners(time_t now)
|
||||
|
||||
}
|
||||
|
||||
+#ifndef NO_FORK
|
||||
+ if (!option_bool(OPT_DEBUG))
|
||||
+ for (i = 0; i < MAX_PROCS; i++)
|
||||
+ if (daemon->tcp_pipes[i] != -1)
|
||||
+ poll_listen(daemon->tcp_pipes[i], POLLIN);
|
||||
+#endif
|
||||
+
|
||||
return wait;
|
||||
}
|
||||
|
||||
@@ -1632,7 +1643,10 @@ static void check_dns_listeners(time_t n
|
||||
struct serverfd *serverfdp;
|
||||
struct listener *listener;
|
||||
int i;
|
||||
-
|
||||
+#ifndef NO_FORK
|
||||
+ int pipefd[2];
|
||||
+#endif
|
||||
+
|
||||
for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next)
|
||||
if (poll_check(serverfdp->fd, POLLIN))
|
||||
reply_query(serverfdp->fd, serverfdp->source_addr.sa.sa_family, now);
|
||||
@@ -1642,7 +1656,26 @@ static void check_dns_listeners(time_t n
|
||||
if (daemon->randomsocks[i].refcount != 0 &&
|
||||
poll_check(daemon->randomsocks[i].fd, POLLIN))
|
||||
reply_query(daemon->randomsocks[i].fd, daemon->randomsocks[i].family, now);
|
||||
-
|
||||
+
|
||||
+#ifndef NO_FORK
|
||||
+ /* Races. The child process can die before we read all of the data from the
|
||||
+ pipe, or vice versa. Therefore send tcp_pids to zero when we wait() the
|
||||
+ process, and tcp_pipes to -1 and close the FD when we read the last
|
||||
+ of the data - indicated by cache_recv_insert returning zero.
|
||||
+ The order of these events is indeterminate, and both are needed
|
||||
+ to free the process slot. Once the child process has gone, poll()
|
||||
+ returns POLLHUP, not POLLIN, so have to check for both here. */
|
||||
+ if (!option_bool(OPT_DEBUG))
|
||||
+ for (i = 0; i < MAX_PROCS; i++)
|
||||
+ if (daemon->tcp_pipes[i] != -1 &&
|
||||
+ poll_check(daemon->tcp_pipes[i], POLLIN | POLLHUP) &&
|
||||
+ !cache_recv_insert(now, daemon->tcp_pipes[i]))
|
||||
+ {
|
||||
+ close(daemon->tcp_pipes[i]);
|
||||
+ daemon->tcp_pipes[i] = -1;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
for (listener = daemon->listeners; listener; listener = listener->next)
|
||||
{
|
||||
if (listener->fd != -1 && poll_check(listener->fd, POLLIN))
|
||||
@@ -1736,15 +1769,20 @@ static void check_dns_listeners(time_t n
|
||||
while (retry_send(close(confd)));
|
||||
}
|
||||
#ifndef NO_FORK
|
||||
- else if (!option_bool(OPT_DEBUG) && (p = fork()) != 0)
|
||||
+ else if (!option_bool(OPT_DEBUG) && pipe(pipefd) == 0 && (p = fork()) != 0)
|
||||
{
|
||||
- if (p != -1)
|
||||
+ close(pipefd[1]); /* parent needs read pipe end. */
|
||||
+ if (p == -1)
|
||||
+ close(pipefd[0]);
|
||||
+ else
|
||||
{
|
||||
int i;
|
||||
+
|
||||
for (i = 0; i < MAX_PROCS; i++)
|
||||
- if (daemon->tcp_pids[i] == 0)
|
||||
+ if (daemon->tcp_pids[i] == 0 && daemon->tcp_pipes[i] == -1)
|
||||
{
|
||||
daemon->tcp_pids[i] = p;
|
||||
+ daemon->tcp_pipes[i] = pipefd[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1761,7 +1799,7 @@ static void check_dns_listeners(time_t n
|
||||
int flags;
|
||||
struct in_addr netmask;
|
||||
int auth_dns;
|
||||
-
|
||||
+
|
||||
if (iface)
|
||||
{
|
||||
netmask = iface->netmask;
|
||||
@@ -1777,7 +1815,11 @@ static void check_dns_listeners(time_t n
|
||||
/* Arrange for SIGALRM after CHILD_LIFETIME seconds to
|
||||
terminate the process. */
|
||||
if (!option_bool(OPT_DEBUG))
|
||||
- alarm(CHILD_LIFETIME);
|
||||
+ {
|
||||
+ alarm(CHILD_LIFETIME);
|
||||
+ close(pipefd[0]); /* close read end in child. */
|
||||
+ daemon->pipe_to_parent = pipefd[1];
|
||||
+ }
|
||||
#endif
|
||||
|
||||
/* start with no upstream connections. */
|
||||
--- a/src/dnsmasq.h
|
||||
+++ b/src/dnsmasq.h
|
||||
@@ -1091,6 +1091,8 @@ extern struct daemon {
|
||||
size_t packet_len; /* " " */
|
||||
struct randfd *rfd_save; /* " " */
|
||||
pid_t tcp_pids[MAX_PROCS];
|
||||
+ int tcp_pipes[MAX_PROCS];
|
||||
+ int pipe_to_parent;
|
||||
struct randfd randomsocks[RANDOM_SOCKS];
|
||||
int v6pktinfo;
|
||||
struct addrlist *interface_addrs; /* list of all addresses/prefix lengths associated with all local interfaces */
|
||||
@@ -1152,6 +1154,7 @@ struct crec *cache_find_by_name(struct c
|
||||
char *name, time_t now, unsigned int prot);
|
||||
void cache_end_insert(void);
|
||||
void cache_start_insert(void);
|
||||
+int cache_recv_insert(time_t now, int fd);
|
||||
struct crec *cache_insert(char *name, struct all_addr *addr,
|
||||
time_t now, unsigned long ttl, unsigned short flags);
|
||||
void cache_reload(void);
|
||||
@@ -1174,6 +1177,8 @@ void blockdata_init(void);
|
||||
void blockdata_report(void);
|
||||
struct blockdata *blockdata_alloc(char *data, size_t len);
|
||||
void *blockdata_retrieve(struct blockdata *block, size_t len, void *data);
|
||||
+struct blockdata *blockdata_read(int fd, size_t len);
|
||||
+void blockdata_write(struct blockdata *block, size_t len, int fd);
|
||||
void blockdata_free(struct blockdata *blocks);
|
||||
#endif
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
From a220545c4277cba534be5ef4638b5076fc7d2cf4 Mon Sep 17 00:00:00 2001
|
||||
From: Simon Kelley <simon@thekelleys.org.uk>
|
||||
Date: Mon, 22 Oct 2018 18:21:48 +0100
|
||||
Subject: [PATCH 02/11] Ensure that AD bit is reset on answers from
|
||||
--address=/<domain>/<address>.
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
src/rfc1035.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/src/rfc1035.c
|
||||
+++ b/src/rfc1035.c
|
||||
@@ -938,9 +938,9 @@ size_t setup_reply(struct dns_header *he
|
||||
return 0;
|
||||
|
||||
/* clear authoritative and truncated flags, set QR flag */
|
||||
- header->hb3 = (header->hb3 & ~(HB3_AA | HB3_TC)) | HB3_QR;
|
||||
- /* set RA flag */
|
||||
- header->hb4 |= HB4_RA;
|
||||
+ header->hb3 = (header->hb3 & ~(HB3_AA | HB3_TC )) | HB3_QR;
|
||||
+ /* clear AD flag, set RA flag */
|
||||
+ header->hb4 = (header->hb4 & ~HB4_AD) | HB4_RA;
|
||||
|
||||
header->nscount = htons(0);
|
||||
header->arcount = htons(0);
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,52 +0,0 @@
|
||||
From cf5984367bc6a949e3803a576512c5a7bc48ebab Mon Sep 17 00:00:00 2001
|
||||
From: Vladislav Grishenko <themiron@mail.ru>
|
||||
Date: Thu, 18 Oct 2018 04:55:21 +0500
|
||||
Subject: [PATCH 04/11] Don't forward *.bind/*.server queries upstream
|
||||
|
||||
Chaos .bind and .server (RFC4892) zones are local, therefore
|
||||
don't forward queries upstream to avoid mixing with supported
|
||||
locally and false replies with NO_ID enabled.
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
src/rfc1035.c | 15 ++++++++++++++-
|
||||
1 file changed, 14 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/src/rfc1035.c
|
||||
+++ b/src/rfc1035.c
|
||||
@@ -1276,7 +1276,7 @@ size_t answer_request(struct dns_header
|
||||
int q, ans, anscount = 0, addncount = 0;
|
||||
int dryrun = 0;
|
||||
struct crec *crecp;
|
||||
- int nxdomain = 0, auth = 1, trunc = 0, sec_data = 1;
|
||||
+ int nxdomain = 0, notimp = 0, auth = 1, trunc = 0, sec_data = 1;
|
||||
struct mx_srv_record *rec;
|
||||
size_t len;
|
||||
|
||||
@@ -1355,6 +1355,17 @@ size_t answer_request(struct dns_header
|
||||
}
|
||||
}
|
||||
|
||||
+ if (qclass == C_CHAOS)
|
||||
+ {
|
||||
+ /* don't forward *.bind and *.server chaos queries */
|
||||
+ if (hostname_issubdomain("bind", name) || hostname_issubdomain("server", name))
|
||||
+ {
|
||||
+ if (!ans)
|
||||
+ notimp = 1, auth = 0;
|
||||
+ ans = 1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (qclass == C_IN)
|
||||
{
|
||||
struct txt_record *t;
|
||||
@@ -1903,6 +1914,8 @@ size_t answer_request(struct dns_header
|
||||
|
||||
if (nxdomain)
|
||||
SET_RCODE(header, NXDOMAIN);
|
||||
+ else if (notimp)
|
||||
+ SET_RCODE(header, NOTIMP);
|
||||
else
|
||||
SET_RCODE(header, NOERROR); /* no error */
|
||||
header->ancount = htons(anscount);
|
||||
@ -1,63 +0,0 @@
|
||||
From cbb5b17ad8e03e08ade62376a4f6a2066e55960d Mon Sep 17 00:00:00 2001
|
||||
From: Simon Kelley <simon@thekelleys.org.uk>
|
||||
Date: Tue, 23 Oct 2018 23:45:57 +0100
|
||||
Subject: [PATCH 05/11] Fix logging in cf5984367bc6a949e3803a576512c5a7bc48ebab
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
src/rfc1035.c | 27 ++++++++++++++++++---------
|
||||
1 file changed, 18 insertions(+), 9 deletions(-)
|
||||
|
||||
--- a/src/rfc1035.c
|
||||
+++ b/src/rfc1035.c
|
||||
@@ -1335,7 +1335,6 @@ size_t answer_request(struct dns_header
|
||||
{
|
||||
unsigned long ttl = daemon->local_ttl;
|
||||
int ok = 1;
|
||||
- log_query(F_CONFIG | F_RRNAME, name, NULL, "<TXT>");
|
||||
#ifndef NO_ID
|
||||
/* Dynamically generate stat record */
|
||||
if (t->stat != 0)
|
||||
@@ -1345,11 +1344,14 @@ size_t answer_request(struct dns_header
|
||||
ok = 0;
|
||||
}
|
||||
#endif
|
||||
- if (ok && add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||
- ttl, NULL,
|
||||
- T_TXT, t->class, "t", t->len, t->txt))
|
||||
- anscount++;
|
||||
-
|
||||
+ if (ok)
|
||||
+ {
|
||||
+ log_query(F_CONFIG | F_RRNAME, name, NULL, "<TXT>");
|
||||
+ if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||
+ ttl, NULL,
|
||||
+ T_TXT, t->class, "t", t->len, t->txt))
|
||||
+ anscount++;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1357,12 +1359,19 @@ size_t answer_request(struct dns_header
|
||||
|
||||
if (qclass == C_CHAOS)
|
||||
{
|
||||
- /* don't forward *.bind and *.server chaos queries */
|
||||
+ /* don't forward *.bind and *.server chaos queries - always reply with NOTIMP */
|
||||
if (hostname_issubdomain("bind", name) || hostname_issubdomain("server", name))
|
||||
{
|
||||
if (!ans)
|
||||
- notimp = 1, auth = 0;
|
||||
- ans = 1;
|
||||
+ {
|
||||
+ notimp = 1, auth = 0;
|
||||
+ if (!dryrun)
|
||||
+ {
|
||||
+ addr.addr.rcode.rcode = NOTIMP;
|
||||
+ log_query(F_CONFIG | F_RCODE, name, &addr, NULL);
|
||||
+ }
|
||||
+ ans = 1;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,120 +0,0 @@
|
||||
From 6f7812d97bc8f87004c0a5069c6c94c64af78106 Mon Sep 17 00:00:00 2001
|
||||
From: Simon Kelley <simon@thekelleys.org.uk>
|
||||
Date: Tue, 23 Oct 2018 23:54:44 +0100
|
||||
Subject: [PATCH 06/11] Fix spurious AD flags in some DNS replies from local
|
||||
config.
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
src/rfc1035.c | 42 ++++++++++++++++++++++++------------------
|
||||
1 file changed, 24 insertions(+), 18 deletions(-)
|
||||
|
||||
--- a/src/rfc1035.c
|
||||
+++ b/src/rfc1035.c
|
||||
@@ -1330,7 +1330,7 @@ size_t answer_request(struct dns_header
|
||||
{
|
||||
if (t->class == qclass && hostname_isequal(name, t->name))
|
||||
{
|
||||
- ans = 1;
|
||||
+ ans = 1, sec_data = 0;
|
||||
if (!dryrun)
|
||||
{
|
||||
unsigned long ttl = daemon->local_ttl;
|
||||
@@ -1370,7 +1370,7 @@ size_t answer_request(struct dns_header
|
||||
addr.addr.rcode.rcode = NOTIMP;
|
||||
log_query(F_CONFIG | F_RCODE, name, &addr, NULL);
|
||||
}
|
||||
- ans = 1;
|
||||
+ ans = 1, sec_data = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1725,7 +1725,7 @@ size_t answer_request(struct dns_header
|
||||
}
|
||||
else if (is_name_synthetic(flag, name, &addr))
|
||||
{
|
||||
- ans = 1;
|
||||
+ ans = 1, sec_data = 0;
|
||||
if (!dryrun)
|
||||
{
|
||||
log_query(F_FORWARD | F_CONFIG | flag, name, &addr, NULL);
|
||||
@@ -1763,25 +1763,27 @@ size_t answer_request(struct dns_header
|
||||
for (rec = daemon->mxnames; rec; rec = rec->next)
|
||||
if (!rec->issrv && hostname_isequal(name, rec->name))
|
||||
{
|
||||
- ans = found = 1;
|
||||
- if (!dryrun)
|
||||
- {
|
||||
- int offset;
|
||||
- log_query(F_CONFIG | F_RRNAME, name, NULL, "<MX>");
|
||||
- if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, daemon->local_ttl,
|
||||
- &offset, T_MX, C_IN, "sd", rec->weight, rec->target))
|
||||
- {
|
||||
- anscount++;
|
||||
- if (rec->target)
|
||||
- rec->offset = offset;
|
||||
- }
|
||||
- }
|
||||
+ ans = found = 1;
|
||||
+ sec_data = 0;
|
||||
+ if (!dryrun)
|
||||
+ {
|
||||
+ int offset;
|
||||
+ log_query(F_CONFIG | F_RRNAME, name, NULL, "<MX>");
|
||||
+ if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, daemon->local_ttl,
|
||||
+ &offset, T_MX, C_IN, "sd", rec->weight, rec->target))
|
||||
+ {
|
||||
+ anscount++;
|
||||
+ if (rec->target)
|
||||
+ rec->offset = offset;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
if (!found && (option_bool(OPT_SELFMX) || option_bool(OPT_LOCALMX)) &&
|
||||
cache_find_by_name(NULL, name, now, F_HOSTS | F_DHCP | F_NO_RR))
|
||||
{
|
||||
ans = 1;
|
||||
+ sec_data = 0;
|
||||
if (!dryrun)
|
||||
{
|
||||
log_query(F_CONFIG | F_RRNAME, name, NULL, "<MX>");
|
||||
@@ -1802,6 +1804,7 @@ size_t answer_request(struct dns_header
|
||||
if (rec->issrv && hostname_isequal(name, rec->name))
|
||||
{
|
||||
found = ans = 1;
|
||||
+ sec_data = 0;
|
||||
if (!dryrun)
|
||||
{
|
||||
int offset;
|
||||
@@ -1838,6 +1841,7 @@ size_t answer_request(struct dns_header
|
||||
if (!found && option_bool(OPT_FILTER) && (qtype == T_SRV || (qtype == T_ANY && strchr(name, '_'))))
|
||||
{
|
||||
ans = 1;
|
||||
+ sec_data = 0;
|
||||
if (!dryrun)
|
||||
log_query(F_CONFIG | F_NEG, name, NULL, NULL);
|
||||
}
|
||||
@@ -1850,6 +1854,7 @@ size_t answer_request(struct dns_header
|
||||
if (hostname_isequal(name, na->name))
|
||||
{
|
||||
ans = 1;
|
||||
+ sec_data = 0;
|
||||
if (!dryrun)
|
||||
{
|
||||
log_query(F_CONFIG | F_RRNAME, name, NULL, "<NAPTR>");
|
||||
@@ -1862,11 +1867,12 @@ size_t answer_request(struct dns_header
|
||||
}
|
||||
|
||||
if (qtype == T_MAILB)
|
||||
- ans = 1, nxdomain = 1;
|
||||
+ ans = 1, nxdomain = 1, sec_data = 0;
|
||||
|
||||
if (qtype == T_SOA && option_bool(OPT_FILTER))
|
||||
{
|
||||
- ans = 1;
|
||||
+ ans = 1;
|
||||
+ sec_data = 0;
|
||||
if (!dryrun)
|
||||
log_query(F_CONFIG | F_NEG, name, &addr, NULL);
|
||||
}
|
||||
@ -1,71 +0,0 @@
|
||||
From 24b87607c1353e94689e8a2190571ab3f3b36f31 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
|
||||
Date: Wed, 24 Oct 2018 22:30:18 +0100
|
||||
Subject: [PATCH 07/11] Do not rely on dead code elimination, use array
|
||||
instead. Make options bits derived from size and count. Use size of option
|
||||
bits and last supported bit in computation. No new change would be required
|
||||
when new options are added. Just change OPT_LAST constant.
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
src/dnsmasq.h | 11 +++++++----
|
||||
src/option.c | 10 ++--------
|
||||
2 files changed, 9 insertions(+), 12 deletions(-)
|
||||
|
||||
--- a/src/dnsmasq.h
|
||||
+++ b/src/dnsmasq.h
|
||||
@@ -200,9 +200,6 @@ struct event_desc {
|
||||
#define EC_MISC 5
|
||||
#define EC_INIT_OFFSET 10
|
||||
|
||||
-/* Trust the compiler dead-code eliminator.... */
|
||||
-#define option_bool(x) (((x) < 32) ? daemon->options & (1u << (x)) : daemon->options2 & (1u << ((x) - 32)))
|
||||
-
|
||||
#define OPT_BOGUSPRIV 0
|
||||
#define OPT_FILTER 1
|
||||
#define OPT_LOG 2
|
||||
@@ -264,6 +261,12 @@ struct event_desc {
|
||||
#define OPT_UBUS 58
|
||||
#define OPT_LAST 59
|
||||
|
||||
+#define OPTION_BITS (sizeof(unsigned int)*8)
|
||||
+#define OPTION_SIZE ( (OPT_LAST/OPTION_BITS)+((OPT_LAST%OPTION_BITS)!=0) )
|
||||
+#define option_var(x) (daemon->options[(x) / OPTION_BITS])
|
||||
+#define option_val(x) ((1u) << ((x) % OPTION_BITS))
|
||||
+#define option_bool(x) (option_var(x) & option_val(x))
|
||||
+
|
||||
/* extra flags for my_syslog, we use a couple of facilities since they are known
|
||||
not to occupy the same bits as priorities, no matter how syslog.h is set up. */
|
||||
#define MS_TFTP LOG_USER
|
||||
@@ -978,7 +981,7 @@ extern struct daemon {
|
||||
config file arguments. All set (including defaults)
|
||||
in option.c */
|
||||
|
||||
- unsigned int options, options2;
|
||||
+ unsigned int options[OPTION_SIZE];
|
||||
struct resolvc default_resolv, *resolv_files;
|
||||
time_t last_resolv;
|
||||
char *servers_file;
|
||||
--- a/src/option.c
|
||||
+++ b/src/option.c
|
||||
@@ -1490,18 +1490,12 @@ static int parse_dhcp_opt(char *errstr,
|
||||
|
||||
void set_option_bool(unsigned int opt)
|
||||
{
|
||||
- if (opt < 32)
|
||||
- daemon->options |= 1u << opt;
|
||||
- else
|
||||
- daemon->options2 |= 1u << (opt - 32);
|
||||
+ option_var(opt) |= option_val(opt);
|
||||
}
|
||||
|
||||
void reset_option_bool(unsigned int opt)
|
||||
{
|
||||
- if (opt < 32)
|
||||
- daemon->options &= ~(1u << opt);
|
||||
- else
|
||||
- daemon->options2 &= ~(1u << (opt - 32));
|
||||
+ option_var(opt) &= ~(option_val(opt));
|
||||
}
|
||||
|
||||
static int one_opt(int option, char *arg, char *errstr, char *gen_err, int command_line, int servers_only)
|
||||
@ -1,63 +0,0 @@
|
||||
From 3a5a84cdd1488bad118eeac72d09a60299bca744 Mon Sep 17 00:00:00 2001
|
||||
From: Simon Kelley <simon@thekelleys.org.uk>
|
||||
Date: Wed, 31 Oct 2018 21:30:13 +0000
|
||||
Subject: [PATCH 08/11] Fix Makefile lines generating UBUS linker config.
|
||||
|
||||
If arg2 of pkg-wrapper is "--copy", then arg1 is NOT the name of
|
||||
the package manager (--copy doesn't invoke it) it's a secondary
|
||||
config string that inhibts the copy if found. This patch allows that
|
||||
to be the empty string, for unconditional copy, and modifies the
|
||||
ubus linker config to use it. It worked by coincidence before, because
|
||||
there was no config string called "pkg-config".
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
Makefile | 2 +-
|
||||
bld/pkg-wrapper | 14 ++++++++------
|
||||
2 files changed, 9 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -53,7 +53,7 @@ top?=$(CURDIR)
|
||||
|
||||
dbus_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1`
|
||||
dbus_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1`
|
||||
-ubus_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_UBUS $(PKG_CONFIG) --copy -lubox -lubus`
|
||||
+ubus_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_UBUS "" --copy -lubox -lubus`
|
||||
idn_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --cflags libidn`
|
||||
idn_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --libs libidn`
|
||||
idn2_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LIBIDN2 $(PKG_CONFIG) --cflags libidn2`
|
||||
--- a/bld/pkg-wrapper
|
||||
+++ b/bld/pkg-wrapper
|
||||
@@ -11,23 +11,25 @@ in=`cat`
|
||||
|
||||
if grep "^\#[[:space:]]*define[[:space:]]*$search" config.h >/dev/null 2>&1 || \
|
||||
echo $in | grep $search >/dev/null 2>&1; then
|
||||
-# Nasty, nasty, in --copy, arg 2 is another config to search for, use with NO_GMP
|
||||
+# Nasty, nasty, in --copy, arg 2 (if non-empty) is another config to search for, used with NO_GMP
|
||||
if [ $op = "--copy" ]; then
|
||||
- if grep "^\#[[:space:]]*define[[:space:]]*$pkg" config.h >/dev/null 2>&1 || \
|
||||
- echo $in | grep $pkg >/dev/null 2>&1; then
|
||||
+ if [ -z "$pkg" ]; then
|
||||
+ pkg="$*"
|
||||
+ elif grep "^\#[[:space:]]*define[[:space:]]*$pkg" config.h >/dev/null 2>&1 || \
|
||||
+ echo $in | grep $pkg >/dev/null 2>&1; then
|
||||
pkg=""
|
||||
else
|
||||
pkg="$*"
|
||||
fi
|
||||
elif grep "^\#[[:space:]]*define[[:space:]]*${search}_STATIC" config.h >/dev/null 2>&1 || \
|
||||
- echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
|
||||
+ echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
|
||||
pkg=`$pkg --static $op $*`
|
||||
else
|
||||
pkg=`$pkg $op $*`
|
||||
fi
|
||||
-
|
||||
+
|
||||
if grep "^\#[[:space:]]*define[[:space:]]*${search}_STATIC" config.h >/dev/null 2>&1 || \
|
||||
- echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
|
||||
+ echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
|
||||
if [ $op = "--libs" ] || [ $op = "--copy" ]; then
|
||||
echo "-Wl,-Bstatic $pkg -Wl,-Bdynamic"
|
||||
else
|
||||
@ -1,41 +0,0 @@
|
||||
From 122392e0b352507cabb9e982208d35d2e56902e0 Mon Sep 17 00:00:00 2001
|
||||
From: Simon Kelley <simon@thekelleys.org.uk>
|
||||
Date: Wed, 31 Oct 2018 22:24:02 +0000
|
||||
Subject: [PATCH 09/11] Revert 68f6312d4bae30b78daafcd6f51dc441b8685b1e
|
||||
|
||||
The above is intended to increase robustness, but actually does the
|
||||
opposite. The problem is that by ignoring SERVFAIL messages and hoping
|
||||
for a better answer from another of the servers we've forwarded to,
|
||||
we become vulnerable in the case that one or more of the configured
|
||||
servers is down or not responding.
|
||||
|
||||
Consider the case that a domain is indeed BOGUS, and we've send the
|
||||
query to n servers. With 68f6312d4bae30b78daafcd6f51dc441b8685b1e
|
||||
we ignore the first n-1 SERVFAIL replies, and only return the
|
||||
final n'th answer to the client. Now, if one of the servers we are
|
||||
forwarding to is down, then we won't get all n replies, and the
|
||||
client will never get an answer! This is a far more likely scenario
|
||||
than a temporary SERVFAIL from only one of a set of notionally identical
|
||||
servers, so, on the ground of robustness, we have to believe
|
||||
any SERVFAIL answers we get, and return them to the client.
|
||||
|
||||
The client could be using the same recursive servers we are,
|
||||
so it should, in theory, retry on SERVFAIL anyway.
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
src/forward.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
--- a/src/forward.c
|
||||
+++ b/src/forward.c
|
||||
@@ -957,8 +957,7 @@ void reply_query(int fd, int family, tim
|
||||
we get a good reply from another server. Kill it when we've
|
||||
had replies from all to avoid filling the forwarding table when
|
||||
everything is broken */
|
||||
- if (forward->forwardall == 0 || --forward->forwardall == 1 ||
|
||||
- (RCODE(header) != REFUSED && RCODE(header) != SERVFAIL))
|
||||
+ if (forward->forwardall == 0 || --forward->forwardall == 1 || RCODE(header) != REFUSED)
|
||||
{
|
||||
int check_rebind = 0, no_cache_dnssec = 0, cache_secure = 0, bogusanswer = 0;
|
||||
|
||||
@ -1,199 +0,0 @@
|
||||
From 48d12f14c9c0fc8cf943b52774c3892517dd72d4 Mon Sep 17 00:00:00 2001
|
||||
From: Simon Kelley <simon@thekelleys.org.uk>
|
||||
Date: Fri, 2 Nov 2018 21:55:04 +0000
|
||||
Subject: [PATCH 10/11] Remove the NO_FORK compile-time option, and support for
|
||||
uclinux.
|
||||
|
||||
In an era where everything has an MMU, this looks like
|
||||
an anachronism, and it adds to (Ok, multiplies!) the
|
||||
combinatorial explosion of compile-time options.
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
CHANGELOG | 6 ++++++
|
||||
src/config.h | 21 ++-------------------
|
||||
src/dnsmasq.c | 14 --------------
|
||||
src/option.c | 4 +---
|
||||
4 files changed, 9 insertions(+), 36 deletions(-)
|
||||
|
||||
--- a/CHANGELOG
|
||||
+++ b/CHANGELOG
|
||||
@@ -11,6 +11,12 @@ version 2.81
|
||||
This fix passes cache entries back from the TCP child process to
|
||||
the main server process, and fixes the problem.
|
||||
|
||||
+ Remove the NO_FORK compile-time option, and support for uclinux.
|
||||
+ In an era where everything has an MMU, this looks like
|
||||
+ an anachronism, and it adds to (Ok, multiplies!) the
|
||||
+ combinatorial explosion of compile-time options. Thanks to
|
||||
+ Kevin Darbyshire-Bryant for the patch.
|
||||
+
|
||||
|
||||
version 2.80
|
||||
Add support for RFC 4039 DHCP rapid commit. Thanks to Ashram Method
|
||||
--- a/src/config.h
|
||||
+++ b/src/config.h
|
||||
@@ -239,27 +239,13 @@ HAVE_SOCKADDR_SA_LEN
|
||||
defined if struct sockaddr has sa_len field (*BSD)
|
||||
*/
|
||||
|
||||
-/* Must precede __linux__ since uClinux defines __linux__ too. */
|
||||
-#if defined(__uClinux__)
|
||||
-#define HAVE_LINUX_NETWORK
|
||||
-#define HAVE_GETOPT_LONG
|
||||
-#undef HAVE_SOCKADDR_SA_LEN
|
||||
-/* Never use fork() on uClinux. Note that this is subtly different from the
|
||||
- --keep-in-foreground option, since it also suppresses forking new
|
||||
- processes for TCP connections and disables the call-a-script on leasechange
|
||||
- system. It's intended for use on MMU-less kernels. */
|
||||
-#define NO_FORK
|
||||
-
|
||||
-#elif defined(__UCLIBC__)
|
||||
+#if defined(__UCLIBC__)
|
||||
#define HAVE_LINUX_NETWORK
|
||||
#if defined(__UCLIBC_HAS_GNU_GETOPT__) || \
|
||||
((__UCLIBC_MAJOR__==0) && (__UCLIBC_MINOR__==9) && (__UCLIBC_SUBLEVEL__<21))
|
||||
# define HAVE_GETOPT_LONG
|
||||
#endif
|
||||
#undef HAVE_SOCKADDR_SA_LEN
|
||||
-#if !defined(__ARCH_HAS_MMU__) && !defined(__UCLIBC_HAS_MMU__)
|
||||
-# define NO_FORK
|
||||
-#endif
|
||||
#if defined(__UCLIBC_HAS_IPV6__)
|
||||
# ifndef IPV6_V6ONLY
|
||||
# define IPV6_V6ONLY 26
|
||||
@@ -328,7 +314,7 @@ HAVE_SOCKADDR_SA_LEN
|
||||
#define HAVE_DHCP
|
||||
#endif
|
||||
|
||||
-#if defined(NO_SCRIPT) || defined(NO_FORK)
|
||||
+#if defined(NO_SCRIPT)
|
||||
#undef HAVE_SCRIPT
|
||||
#undef HAVE_LUASCRIPT
|
||||
#endif
|
||||
@@ -372,9 +358,6 @@ static char *compile_opts =
|
||||
#ifdef HAVE_BROKEN_RTC
|
||||
"no-RTC "
|
||||
#endif
|
||||
-#ifdef NO_FORK
|
||||
-"no-MMU "
|
||||
-#endif
|
||||
#ifndef HAVE_DBUS
|
||||
"no-"
|
||||
#endif
|
||||
--- a/src/dnsmasq.c
|
||||
+++ b/src/dnsmasq.c
|
||||
@@ -485,7 +485,6 @@ int main (int argc, char **argv)
|
||||
if (chdir("/") != 0)
|
||||
die(_("cannot chdir to filesystem root: %s"), NULL, EC_MISC);
|
||||
|
||||
-#ifndef NO_FORK
|
||||
if (!option_bool(OPT_NO_FORK))
|
||||
{
|
||||
pid_t pid;
|
||||
@@ -525,7 +524,6 @@ int main (int argc, char **argv)
|
||||
if (pid != 0)
|
||||
_exit(0);
|
||||
}
|
||||
-#endif
|
||||
|
||||
/* write pidfile _after_ forking ! */
|
||||
if (daemon->runfile)
|
||||
@@ -1628,12 +1626,10 @@ static int set_dns_listeners(time_t now)
|
||||
|
||||
}
|
||||
|
||||
-#ifndef NO_FORK
|
||||
if (!option_bool(OPT_DEBUG))
|
||||
for (i = 0; i < MAX_PROCS; i++)
|
||||
if (daemon->tcp_pipes[i] != -1)
|
||||
poll_listen(daemon->tcp_pipes[i], POLLIN);
|
||||
-#endif
|
||||
|
||||
return wait;
|
||||
}
|
||||
@@ -1643,9 +1639,7 @@ static void check_dns_listeners(time_t n
|
||||
struct serverfd *serverfdp;
|
||||
struct listener *listener;
|
||||
int i;
|
||||
-#ifndef NO_FORK
|
||||
int pipefd[2];
|
||||
-#endif
|
||||
|
||||
for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next)
|
||||
if (poll_check(serverfdp->fd, POLLIN))
|
||||
@@ -1657,7 +1651,6 @@ static void check_dns_listeners(time_t n
|
||||
poll_check(daemon->randomsocks[i].fd, POLLIN))
|
||||
reply_query(daemon->randomsocks[i].fd, daemon->randomsocks[i].family, now);
|
||||
|
||||
-#ifndef NO_FORK
|
||||
/* Races. The child process can die before we read all of the data from the
|
||||
pipe, or vice versa. Therefore send tcp_pids to zero when we wait() the
|
||||
process, and tcp_pipes to -1 and close the FD when we read the last
|
||||
@@ -1674,7 +1667,6 @@ static void check_dns_listeners(time_t n
|
||||
close(daemon->tcp_pipes[i]);
|
||||
daemon->tcp_pipes[i] = -1;
|
||||
}
|
||||
-#endif
|
||||
|
||||
for (listener = daemon->listeners; listener; listener = listener->next)
|
||||
{
|
||||
@@ -1768,7 +1760,6 @@ static void check_dns_listeners(time_t n
|
||||
shutdown(confd, SHUT_RDWR);
|
||||
while (retry_send(close(confd)));
|
||||
}
|
||||
-#ifndef NO_FORK
|
||||
else if (!option_bool(OPT_DEBUG) && pipe(pipefd) == 0 && (p = fork()) != 0)
|
||||
{
|
||||
close(pipefd[1]); /* parent needs read pipe end. */
|
||||
@@ -1791,7 +1782,6 @@ static void check_dns_listeners(time_t n
|
||||
/* The child can use up to TCP_MAX_QUERIES ids, so skip that many. */
|
||||
daemon->log_id += TCP_MAX_QUERIES;
|
||||
}
|
||||
-#endif
|
||||
else
|
||||
{
|
||||
unsigned char *buff;
|
||||
@@ -1811,7 +1801,6 @@ static void check_dns_listeners(time_t n
|
||||
auth_dns = 0;
|
||||
}
|
||||
|
||||
-#ifndef NO_FORK
|
||||
/* Arrange for SIGALRM after CHILD_LIFETIME seconds to
|
||||
terminate the process. */
|
||||
if (!option_bool(OPT_DEBUG))
|
||||
@@ -1820,7 +1809,6 @@ static void check_dns_listeners(time_t n
|
||||
close(pipefd[0]); /* close read end in child. */
|
||||
daemon->pipe_to_parent = pipefd[1];
|
||||
}
|
||||
-#endif
|
||||
|
||||
/* start with no upstream connections. */
|
||||
for (s = daemon->servers; s; s = s->next)
|
||||
@@ -1846,13 +1834,11 @@ static void check_dns_listeners(time_t n
|
||||
shutdown(s->tcpfd, SHUT_RDWR);
|
||||
while (retry_send(close(s->tcpfd)));
|
||||
}
|
||||
-#ifndef NO_FORK
|
||||
if (!option_bool(OPT_DEBUG))
|
||||
{
|
||||
flush_log();
|
||||
_exit(0);
|
||||
}
|
||||
-#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
--- a/src/option.c
|
||||
+++ b/src/option.c
|
||||
@@ -1828,9 +1828,7 @@ static int one_opt(int option, char *arg
|
||||
/* Sorry about the gross pre-processor abuse */
|
||||
case '6': /* --dhcp-script */
|
||||
case LOPT_LUASCRIPT: /* --dhcp-luascript */
|
||||
-# if defined(NO_FORK)
|
||||
- ret_err(_("cannot run scripts under uClinux"));
|
||||
-# elif !defined(HAVE_SCRIPT)
|
||||
+# if !defined(HAVE_SCRIPT)
|
||||
ret_err(_("recompile with HAVE_SCRIPT defined to enable lease-change scripts"));
|
||||
# else
|
||||
if (option == LOPT_LUASCRIPT)
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,27 +0,0 @@
|
||||
From 061eb8599636bb360e0b7fa5986935b86db39497 Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
Date: Mon, 10 Dec 2018 10:07:33 +0000
|
||||
Subject: [PATCH] option: fix non DHCPv6 build error
|
||||
|
||||
option.c: In function 'dhcp_context_free':
|
||||
option.c:1042:15: error: 'struct dhcp_context' has no member named 'template_interface'
|
||||
free(ctx->template_interface);
|
||||
^~
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
src/option.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
--- a/src/option.c
|
||||
+++ b/src/option.c
|
||||
@@ -1039,7 +1039,9 @@ static void dhcp_context_free(struct dhc
|
||||
{
|
||||
dhcp_netid_free(ctx->filter);
|
||||
free(ctx->netid.net);
|
||||
+#ifdef HAVE_DHCP6
|
||||
free(ctx->template_interface);
|
||||
+#endif
|
||||
free(ctx);
|
||||
}
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
From 46de5d4954b470db155098001cffc357b51e50f4 Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
Date: Wed, 12 Dec 2018 11:35:12 +0000
|
||||
Subject: [PATCH] ipset fix ternary order swap
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
src/ipset.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/src/ipset.c
|
||||
+++ b/src/ipset.c
|
||||
@@ -120,7 +120,7 @@ static int new_add_to_ipset(const char *
|
||||
struct my_nfgenmsg *nfg;
|
||||
struct my_nlattr *nested[2];
|
||||
uint8_t proto;
|
||||
- int addrsz = (af == AF_INET6) ? INADDRSZ : IN6ADDRSZ;
|
||||
+ int addrsz = (af == AF_INET6) ? IN6ADDRSZ : INADDRSZ;
|
||||
|
||||
if (strlen(setname) >= IPSET_MAXNAMELEN)
|
||||
{
|
||||
@ -1,40 +0,0 @@
|
||||
From 668b45c29c38d440c8fce4bc994c56910adc3919 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
|
||||
Date: Fri, 14 Dec 2018 17:03:08 +0100
|
||||
Subject: [PATCH] Fix required tags in few places
|
||||
|
||||
Some locations were incorrectly changed to require always tags, else
|
||||
dnsmasq will not start. Fix dhcp-boot, dhcp-reply-delay and pxe-prompt.
|
||||
---
|
||||
src/option.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/src/option.c
|
||||
+++ b/src/option.c
|
||||
@@ -3434,7 +3434,7 @@ static int one_opt(int option, char *arg
|
||||
{
|
||||
struct dhcp_netid *id = dhcp_tags(&arg);
|
||||
|
||||
- if (!id)
|
||||
+ if (!arg)
|
||||
{
|
||||
ret_err(gen_err);
|
||||
}
|
||||
@@ -3485,7 +3485,7 @@ static int one_opt(int option, char *arg
|
||||
{
|
||||
struct dhcp_netid *id = dhcp_tags(&arg);
|
||||
|
||||
- if (!id)
|
||||
+ if (!arg)
|
||||
{
|
||||
ret_err(gen_err);
|
||||
}
|
||||
@@ -3515,7 +3515,7 @@ static int one_opt(int option, char *arg
|
||||
new->opt = 10; /* PXE_MENU_PROMPT */
|
||||
new->netid = dhcp_tags(&arg);
|
||||
|
||||
- if (!new->netid)
|
||||
+ if (!arg)
|
||||
{
|
||||
dhcp_opt_free(new);
|
||||
ret_err(gen_err);
|
||||
@ -1,33 +0,0 @@
|
||||
diff --git a/src/crypto.c b/src/crypto.c
|
||||
index ebb871e..94d0332 100644
|
||||
--- a/src/crypto.c
|
||||
+++ b/src/crypto.c
|
||||
@@ -275,6 +275,10 @@ static int dnsmasq_ecdsa_verify(struct blockdata *key_data, unsigned int key_len
|
||||
static struct ecc_point *key_256 = NULL, *key_384 = NULL;
|
||||
static mpz_t x, y;
|
||||
static struct dsa_signature *sig_struct;
|
||||
+#if NETTLE_VERSION_MAJOR == 3 && NETTLE_VERSION_MINOR < 4
|
||||
+#define nettle_get_secp_256r1() (&nettle_secp_256r1)
|
||||
+#define nettle_get_secp_384r1() (&nettle_secp_384r1)
|
||||
+#endif
|
||||
|
||||
if (!sig_struct)
|
||||
{
|
||||
@@ -294,7 +298,7 @@ static int dnsmasq_ecdsa_verify(struct blockdata *key_data, unsigned int key_len
|
||||
if (!(key_256 = whine_malloc(sizeof(struct ecc_point))))
|
||||
return 0;
|
||||
|
||||
- nettle_ecc_point_init(key_256, &nettle_secp_256r1);
|
||||
+ nettle_ecc_point_init(key_256, nettle_get_secp_256r1());
|
||||
}
|
||||
|
||||
key = key_256;
|
||||
@@ -307,7 +311,7 @@ static int dnsmasq_ecdsa_verify(struct blockdata *key_data, unsigned int key_len
|
||||
if (!(key_384 = whine_malloc(sizeof(struct ecc_point))))
|
||||
return 0;
|
||||
|
||||
- nettle_ecc_point_init(key_384, &nettle_secp_384r1);
|
||||
+ nettle_ecc_point_init(key_384, nettle_get_secp_256r1());
|
||||
}
|
||||
|
||||
key = key_384;
|
||||
@ -0,0 +1,178 @@
|
||||
From 7df4c681678612d196b4e1eec24963d181fdb28a Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
Date: Sun, 5 Apr 2020 17:18:23 +0100
|
||||
Subject: [PATCH] drop runtime old kernel support
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
src/dnsmasq.c | 4 ----
|
||||
src/dnsmasq.h | 5 +---
|
||||
src/ipset.c | 64 ++++-----------------------------------------------
|
||||
src/netlink.c | 3 +--
|
||||
src/util.c | 19 ---------------
|
||||
5 files changed, 6 insertions(+), 89 deletions(-)
|
||||
|
||||
--- a/src/dnsmasq.c
|
||||
+++ b/src/dnsmasq.c
|
||||
@@ -94,10 +94,6 @@ int main (int argc, char **argv)
|
||||
|
||||
read_opts(argc, argv, compile_opts);
|
||||
|
||||
-#ifdef HAVE_LINUX_NETWORK
|
||||
- daemon->kernel_version = kernel_version();
|
||||
-#endif
|
||||
-
|
||||
if (daemon->edns_pktsz < PACKETSZ)
|
||||
daemon->edns_pktsz = PACKETSZ;
|
||||
|
||||
--- a/src/dnsmasq.h
|
||||
+++ b/src/dnsmasq.h
|
||||
@@ -1110,7 +1110,7 @@ extern struct daemon {
|
||||
int inotifyfd;
|
||||
#endif
|
||||
#if defined(HAVE_LINUX_NETWORK)
|
||||
- int netlinkfd, kernel_version;
|
||||
+ int netlinkfd;
|
||||
#elif defined(HAVE_BSD_NETWORK)
|
||||
int dhcp_raw_fd, dhcp_icmp_fd, routefd;
|
||||
#endif
|
||||
@@ -1290,9 +1290,6 @@ int read_write(int fd, unsigned char *pa
|
||||
void close_fds(long max_fd, int spare1, int spare2, int spare3);
|
||||
int wildcard_match(const char* wildcard, const char* match);
|
||||
int wildcard_matchn(const char* wildcard, const char* match, int num);
|
||||
-#ifdef HAVE_LINUX_NETWORK
|
||||
-int kernel_version(void);
|
||||
-#endif
|
||||
|
||||
/* log.c */
|
||||
void die(char *message, char *arg1, int exit_code) ATTRIBUTE_NORETURN;
|
||||
--- a/src/ipset.c
|
||||
+++ b/src/ipset.c
|
||||
@@ -70,7 +70,7 @@ struct my_nfgenmsg {
|
||||
|
||||
#define NL_ALIGN(len) (((len)+3) & ~(3))
|
||||
static const struct sockaddr_nl snl = { .nl_family = AF_NETLINK };
|
||||
-static int ipset_sock, old_kernel;
|
||||
+static int ipset_sock;
|
||||
static char *buffer;
|
||||
|
||||
static inline void add_attr(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data)
|
||||
@@ -85,12 +85,7 @@ static inline void add_attr(struct nlmsg
|
||||
|
||||
void ipset_init(void)
|
||||
{
|
||||
- old_kernel = (daemon->kernel_version < KERNEL_VERSION(2,6,32));
|
||||
-
|
||||
- if (old_kernel && (ipset_sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) != -1)
|
||||
- return;
|
||||
-
|
||||
- if (!old_kernel &&
|
||||
+ if (
|
||||
(buffer = safe_malloc(BUFF_SZ)) &&
|
||||
(ipset_sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER)) != -1 &&
|
||||
(bind(ipset_sock, (struct sockaddr *)&snl, sizeof(snl)) != -1))
|
||||
@@ -147,65 +142,14 @@ static int new_add_to_ipset(const char *
|
||||
return errno == 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
-
|
||||
-static int old_add_to_ipset(const char *setname, const union all_addr *ipaddr, int remove)
|
||||
-{
|
||||
- socklen_t size;
|
||||
- struct ip_set_req_adt_get {
|
||||
- unsigned op;
|
||||
- unsigned version;
|
||||
- union {
|
||||
- char name[IPSET_MAXNAMELEN];
|
||||
- uint16_t index;
|
||||
- } set;
|
||||
- char typename[IPSET_MAXNAMELEN];
|
||||
- } req_adt_get;
|
||||
- struct ip_set_req_adt {
|
||||
- unsigned op;
|
||||
- uint16_t index;
|
||||
- uint32_t ip;
|
||||
- } req_adt;
|
||||
-
|
||||
- if (strlen(setname) >= sizeof(req_adt_get.set.name))
|
||||
- {
|
||||
- errno = ENAMETOOLONG;
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- req_adt_get.op = 0x10;
|
||||
- req_adt_get.version = 3;
|
||||
- strcpy(req_adt_get.set.name, setname);
|
||||
- size = sizeof(req_adt_get);
|
||||
- if (getsockopt(ipset_sock, SOL_IP, 83, &req_adt_get, &size) < 0)
|
||||
- return -1;
|
||||
- req_adt.op = remove ? 0x102 : 0x101;
|
||||
- req_adt.index = req_adt_get.set.index;
|
||||
- req_adt.ip = ntohl(ipaddr->addr4.s_addr);
|
||||
- if (setsockopt(ipset_sock, SOL_IP, 83, &req_adt, sizeof(req_adt)) < 0)
|
||||
- return -1;
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-
|
||||
-
|
||||
int add_to_ipset(const char *setname, const union all_addr *ipaddr, int flags, int remove)
|
||||
{
|
||||
int ret = 0, af = AF_INET;
|
||||
|
||||
if (flags & F_IPV6)
|
||||
- {
|
||||
af = AF_INET6;
|
||||
- /* old method only supports IPv4 */
|
||||
- if (old_kernel)
|
||||
- {
|
||||
- errno = EAFNOSUPPORT ;
|
||||
- ret = -1;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (ret != -1)
|
||||
- ret = old_kernel ? old_add_to_ipset(setname, ipaddr, remove) : new_add_to_ipset(setname, ipaddr, af, remove);
|
||||
+
|
||||
+ ret = new_add_to_ipset(setname, ipaddr, af, remove);
|
||||
|
||||
if (ret == -1)
|
||||
my_syslog(LOG_ERR, _("failed to update ipset %s: %s"), setname, strerror(errno));
|
||||
--- a/src/netlink.c
|
||||
+++ b/src/netlink.c
|
||||
@@ -82,8 +82,7 @@ void netlink_init(void)
|
||||
}
|
||||
|
||||
if (daemon->netlinkfd == -1 ||
|
||||
- (daemon->kernel_version >= KERNEL_VERSION(2,6,30) &&
|
||||
- setsockopt(daemon->netlinkfd, SOL_NETLINK, NETLINK_NO_ENOBUFS, &opt, sizeof(opt)) == -1) ||
|
||||
+ (setsockopt(daemon->netlinkfd, SOL_NETLINK, NETLINK_NO_ENOBUFS, &opt, sizeof(opt)) == -1) ||
|
||||
getsockname(daemon->netlinkfd, (struct sockaddr *)&addr, &slen) == -1)
|
||||
die(_("cannot create netlink socket: %s"), NULL, EC_MISC);
|
||||
|
||||
--- a/src/util.c
|
||||
+++ b/src/util.c
|
||||
@@ -786,22 +786,3 @@ int wildcard_matchn(const char* wildcard
|
||||
|
||||
return (!num) || (*wildcard == *match);
|
||||
}
|
||||
-
|
||||
-#ifdef HAVE_LINUX_NETWORK
|
||||
-int kernel_version(void)
|
||||
-{
|
||||
- struct utsname utsname;
|
||||
- int version;
|
||||
- char *split;
|
||||
-
|
||||
- if (uname(&utsname) < 0)
|
||||
- die(_("failed to find kernel version: %s"), NULL, EC_MISC);
|
||||
-
|
||||
- split = strtok(utsname.release, ".");
|
||||
- version = (split ? atoi(split) : 0);
|
||||
- split = strtok(NULL, ".");
|
||||
- version = version * 256 + (split ? atoi(split) : 0);
|
||||
- split = strtok(NULL, ".");
|
||||
- return version * 256 + (split ? atoi(split) : 0);
|
||||
-}
|
||||
-#endif
|
||||
@ -1,64 +0,0 @@
|
||||
--- a/src/ipset.c
|
||||
+++ b/src/ipset.c
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
-#include <sys/utsname.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/netlink.h>
|
||||
@@ -72,7 +71,7 @@ struct my_nfgenmsg {
|
||||
|
||||
#define NL_ALIGN(len) (((len)+3) & ~(3))
|
||||
static const struct sockaddr_nl snl = { .nl_family = AF_NETLINK };
|
||||
-static int ipset_sock, old_kernel;
|
||||
+static int ipset_sock;
|
||||
static char *buffer;
|
||||
|
||||
static inline void add_attr(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data)
|
||||
@@ -87,25 +86,7 @@ static inline void add_attr(struct nlmsg
|
||||
|
||||
void ipset_init(void)
|
||||
{
|
||||
- struct utsname utsname;
|
||||
- int version;
|
||||
- char *split;
|
||||
-
|
||||
- if (uname(&utsname) < 0)
|
||||
- die(_("failed to find kernel version: %s"), NULL, EC_MISC);
|
||||
-
|
||||
- split = strtok(utsname.release, ".");
|
||||
- version = (split ? atoi(split) : 0);
|
||||
- split = strtok(NULL, ".");
|
||||
- version = version * 256 + (split ? atoi(split) : 0);
|
||||
- split = strtok(NULL, ".");
|
||||
- version = version * 256 + (split ? atoi(split) : 0);
|
||||
- old_kernel = (version < KERNEL_VERSION(2,6,32));
|
||||
-
|
||||
- if (old_kernel && (ipset_sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) != -1)
|
||||
- return;
|
||||
-
|
||||
- if (!old_kernel &&
|
||||
+ if (
|
||||
(buffer = safe_malloc(BUFF_SZ)) &&
|
||||
(ipset_sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER)) != -1 &&
|
||||
(bind(ipset_sock, (struct sockaddr *)&snl, sizeof(snl)) != -1))
|
||||
@@ -211,16 +192,9 @@ int add_to_ipset(const char *setname, co
|
||||
if (flags & F_IPV6)
|
||||
{
|
||||
af = AF_INET6;
|
||||
- /* old method only supports IPv4 */
|
||||
- if (old_kernel)
|
||||
- {
|
||||
- errno = EAFNOSUPPORT ;
|
||||
- ret = -1;
|
||||
- }
|
||||
}
|
||||
|
||||
- if (ret != -1)
|
||||
- ret = old_kernel ? old_add_to_ipset(setname, ipaddr, remove) : new_add_to_ipset(setname, ipaddr, af, remove);
|
||||
+ ret = new_add_to_ipset(setname, ipaddr, af, remove);
|
||||
|
||||
if (ret == -1)
|
||||
my_syslog(LOG_ERR, _("failed to update ipset %s: %s"), setname, strerror(errno));
|
||||
@ -1,18 +0,0 @@
|
||||
dnsmasq: fix warning with poll.h include on musl
|
||||
|
||||
Warning is:
|
||||
#warning redirecting incorrect #include <sys/poll.h> to <poll.h>
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
|
||||
|
||||
--- a/src/dnsmasq.h
|
||||
+++ b/src/dnsmasq.h
|
||||
@@ -95,7 +95,7 @@ typedef unsigned long long u64;
|
||||
#if defined(HAVE_SOLARIS_NETWORK)
|
||||
# include <sys/sockio.h>
|
||||
#endif
|
||||
-#include <sys/poll.h>
|
||||
+#include <poll.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/un.h>
|
||||
@ -1,62 +1,71 @@
|
||||
diff --git a/src/dnsmasq.h b/src/dnsmasq.h
|
||||
--- a/src/dnsmasq.h 2018-10-19 02:21:55.000000000 +0800
|
||||
+++ b/src/dnsmasq.h 2020-01-13 10:38:16.940067371 +0800
|
||||
@@ -1017,7 +1017,7 @@
|
||||
--- a/src/dnsmasq.h 2020-03-16 04:31:43.337573724 +0800
|
||||
+++ b/src/dnsmasq.h 2020-03-16 04:32:07.138008046 +0800
|
||||
@@ -1029,7 +1029,7 @@
|
||||
int max_logs; /* queue limit */
|
||||
int cachesize, ftabsize;
|
||||
int port, query_port, min_port, max_port;
|
||||
- unsigned long local_ttl, neg_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl, dhcp_ttl, use_dhcp_ttl;
|
||||
+ unsigned long local_ttl, neg_ttl, min_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl, dhcp_ttl, use_dhcp_ttl;
|
||||
+ unsigned long local_ttl, neg_ttl, max_ttl, min_ttl, min_cache_ttl, max_cache_ttl, auth_ttl, dhcp_ttl, use_dhcp_ttl;
|
||||
char *dns_client_id;
|
||||
struct hostsfile *addn_hosts;
|
||||
struct dhcp_context *dhcp, *dhcp6;
|
||||
diff --git a/src/option.c b/src/option.c
|
||||
--- a/src/option.c 2018-10-19 02:21:55.000000000 +0800
|
||||
+++ b/src/option.c 2020-01-13 17:21:13.925164926 +0800
|
||||
@@ -106,6 +106,7 @@
|
||||
--- a/src/option.c 2020-03-16 04:33:35.999622026 +0800
|
||||
+++ b/src/option.c 2020-03-16 04:40:44.839289942 +0800
|
||||
@@ -105,6 +105,7 @@
|
||||
#define LOPT_TAG_IF 294
|
||||
#define LOPT_PROXY 295
|
||||
#define LOPT_GEN_NAMES 296
|
||||
+#define LOPT_MINTTL 361
|
||||
#define LOPT_MAXTTL 297
|
||||
+#define LOPT_MINTTL 397
|
||||
#define LOPT_NO_REBIND 298
|
||||
#define LOPT_LOC_REBND 299
|
||||
#define LOPT_ADD_MAC 300
|
||||
@@ -282,6 +283,7 @@
|
||||
@@ -167,7 +168,7 @@
|
||||
#define LOPT_IGNORE_CLID 358
|
||||
#define LOPT_SINGLE_PORT 359
|
||||
#define LOPT_SCRIPT_TIME 360
|
||||
-
|
||||
+
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
static const struct option opts[] =
|
||||
#else
|
||||
@@ -284,6 +285,7 @@
|
||||
{ "dhcp-name-match", 1, 0, LOPT_NAME_MATCH },
|
||||
{ "dhcp-broadcast", 2, 0, LOPT_BROADCAST },
|
||||
{ "neg-ttl", 1, 0, LOPT_NEGTTL },
|
||||
{ "max-ttl", 1, 0, LOPT_MAXTTL },
|
||||
+ { "min-ttl", 1, 0, LOPT_MINTTL },
|
||||
{ "max-ttl", 1, 0, LOPT_MAXTTL },
|
||||
{ "min-cache-ttl", 1, 0, LOPT_MINCTTL },
|
||||
{ "max-cache-ttl", 1, 0, LOPT_MAXCTTL },
|
||||
{ "dhcp-alternate-port", 2, 0, LOPT_ALTPORT },
|
||||
@@ -411,6 +413,7 @@
|
||||
@@ -410,6 +412,7 @@
|
||||
{ 't', ARG_ONE, "<host_name>", gettext_noop("Specify default target in an MX record."), NULL },
|
||||
{ 'T', ARG_ONE, "<integer>", gettext_noop("Specify time-to-live in seconds for replies from /etc/hosts."), NULL },
|
||||
{ LOPT_NEGTTL, ARG_ONE, "<integer>", gettext_noop("Specify time-to-live in seconds for negative caching."), NULL },
|
||||
{ LOPT_MAXTTL, ARG_ONE, "<integer>", gettext_noop("Specify time-to-live in seconds for maximum TTL to send to clients."), NULL },
|
||||
+ { LOPT_MINTTL, ARG_ONE, "<integer>", gettext_noop("Specify time-to-live in seconds for minimum TTL to send to clients."), NULL },
|
||||
{ LOPT_MAXTTL, ARG_ONE, "<integer>", gettext_noop("Specify time-to-live in seconds for maximum TTL to send to clients."), NULL },
|
||||
{ LOPT_MAXCTTL, ARG_ONE, "<integer>", gettext_noop("Specify time-to-live ceiling for cache."), NULL },
|
||||
{ LOPT_MINCTTL, ARG_ONE, "<integer>", gettext_noop("Specify time-to-live floor for cache."), NULL },
|
||||
{ 'u', ARG_ONE, "<username>", gettext_noop("Change to this user after startup. (defaults to %s)."), CHUSER },
|
||||
@@ -2747,6 +2750,7 @@
|
||||
@@ -2812,6 +2815,7 @@
|
||||
|
||||
case 'T': /* --local-ttl */
|
||||
case LOPT_NEGTTL: /* --neg-ttl */
|
||||
case LOPT_MAXTTL: /* --max-ttl */
|
||||
+ case LOPT_MINTTL: /* --min-ttl */
|
||||
case LOPT_MAXTTL: /* --max-ttl */
|
||||
case LOPT_MINCTTL: /* --min-cache-ttl */
|
||||
case LOPT_MAXCTTL: /* --max-cache-ttl */
|
||||
case LOPT_AUTHTTL: /* --auth-ttl */
|
||||
@@ -2759,6 +2763,8 @@
|
||||
@@ -2823,6 +2827,8 @@
|
||||
ret_err(gen_err);
|
||||
else if (option == LOPT_NEGTTL)
|
||||
daemon->neg_ttl = (unsigned long)ttl;
|
||||
else if (option == LOPT_MAXTTL)
|
||||
daemon->max_ttl = (unsigned long)ttl;
|
||||
+ else if (option == LOPT_MINTTL)
|
||||
+ daemon->min_ttl = (unsigned long)ttl;
|
||||
else if (option == LOPT_MAXTTL)
|
||||
daemon->max_ttl = (unsigned long)ttl;
|
||||
else if (option == LOPT_MINCTTL)
|
||||
{
|
||||
if (ttl > TTL_FLOOR_LIMIT)
|
||||
diff --git a/src/rfc1035.c b/src/rfc1035.c
|
||||
--- a/src/rfc1035.c 2018-10-19 02:21:55.000000000 +0800
|
||||
+++ b/src/rfc1035.c 2020-01-13 17:12:25.455445871 +0800
|
||||
--- a/src/rfc1035.c 2020-03-08 23:56:19.000000000 +0800
|
||||
+++ b/src/rfc1035.c 2020-03-16 04:41:50.888215364 +0800
|
||||
@@ -664,11 +664,20 @@
|
||||
GETSHORT(aqtype, p1);
|
||||
GETSHORT(aqclass, p1);
|
||||
@ -81,7 +90,7 @@ diff --git a/src/rfc1035.c b/src/rfc1035.c
|
||||
GETSHORT(ardlen, p1);
|
||||
endrr = p1+ardlen;
|
||||
|
||||
@@ -755,11 +764,20 @@
|
||||
@@ -760,11 +769,20 @@
|
||||
GETSHORT(aqtype, p1);
|
||||
GETSHORT(aqclass, p1);
|
||||
GETLONG(attl, p1);
|
||||
|
||||
@ -13,13 +13,13 @@ diff --git a/src/dnsmasq.h b/src/dnsmasq.h
|
||||
index 1896a64..e10d6c4 100644
|
||||
--- a/src/dnsmasq.h
|
||||
+++ b/src/dnsmasq.h
|
||||
@@ -259,7 +259,8 @@ struct event_desc {
|
||||
#define OPT_TFTP_APREF_MAC 56
|
||||
#define OPT_RAPID_COMMIT 57
|
||||
#define OPT_UBUS 58
|
||||
-#define OPT_LAST 59
|
||||
+#define OPT_FILTER_AAAA 59
|
||||
+#define OPT_LAST 60
|
||||
@@ -268,7 +268,8 @@
|
||||
#define OPT_IGNORE_CLID 59
|
||||
#define OPT_SINGLE_PORT 60
|
||||
#define OPT_LEASE_RENEW 61
|
||||
-#define OPT_LAST 62
|
||||
+#define OPT_FILTER_AAAA 62
|
||||
+#define OPT_LAST 63
|
||||
|
||||
#define OPTION_BITS (sizeof(unsigned int)*8)
|
||||
#define OPTION_SIZE ( (OPT_LAST/OPTION_BITS)+((OPT_LAST%OPTION_BITS)!=0) )
|
||||
@ -27,26 +27,26 @@ diff --git a/src/option.c b/src/option.c
|
||||
index d8c57d6..1cc65bf 100644
|
||||
--- a/src/option.c
|
||||
+++ b/src/option.c
|
||||
@@ -166,6 +166,7 @@ struct myoption {
|
||||
#define LOPT_UBUS 354
|
||||
#define LOPT_NAME_MATCH 355
|
||||
#define LOPT_CAA 356
|
||||
+#define LOPT_FILTER_AAAA 357
|
||||
|
||||
@@ -168,6 +168,7 @@
|
||||
#define LOPT_IGNORE_CLID 358
|
||||
#define LOPT_SINGLE_PORT 359
|
||||
#define LOPT_SCRIPT_TIME 360
|
||||
+#define LOPT_FILTER_AAAA 362
|
||||
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
static const struct option opts[] =
|
||||
@@ -337,6 +338,7 @@ static const struct myoption opts[] =
|
||||
{ "dhcp-rapid-commit", 0, 0, LOPT_RAPID_COMMIT },
|
||||
@@ -341,6 +342,7 @@
|
||||
{ "dumpfile", 1, 0, LOPT_DUMPFILE },
|
||||
{ "dumpmask", 1, 0, LOPT_DUMPMASK },
|
||||
{ "dhcp-ignore-clid", 0, 0, LOPT_IGNORE_CLID },
|
||||
+ { "filter-aaaa", 0, 0, LOPT_FILTER_AAAA },
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
@@ -515,6 +517,7 @@ static struct {
|
||||
{ LOPT_RAPID_COMMIT, OPT_RAPID_COMMIT, NULL, gettext_noop("Enables DHCPv4 Rapid Commit option."), NULL },
|
||||
@@ -521,6 +523,7 @@
|
||||
{ LOPT_DUMPFILE, ARG_ONE, "<path>", gettext_noop("Path to debug packet dump file"), NULL },
|
||||
{ LOPT_DUMPMASK, ARG_ONE, "<hex>", gettext_noop("Mask which packets to dump"), NULL },
|
||||
{ LOPT_SCRIPT_TIME, OPT_LEASE_RENEW, NULL, gettext_noop("Call dhcp-script when lease expiry changes."), NULL },
|
||||
+ { LOPT_FILTER_AAAA, OPT_FILTER_AAAA, NULL, gettext_noop("Filter all AAAA requests."), NULL },
|
||||
{ 0, 0, NULL, NULL, NULL }
|
||||
};
|
||||
@ -55,7 +55,7 @@ diff --git a/src/rfc1035.c b/src/rfc1035.c
|
||||
index 24d08c1..1594962 100644
|
||||
--- a/src/rfc1035.c
|
||||
+++ b/src/rfc1035.c
|
||||
@@ -1970,6 +1970,15 @@ size_t answer_request(struct dns_header
|
||||
@@ -1959,6 +1959,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user