Initial commit
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
From 18eac67c0a15b673c8d27002c248651b308093e4 Mon Sep 17 00:00:00 2001
|
||||
From: Steven Siloti <ssiloti@gmail.com>
|
||||
Date: Sun, 13 Jan 2019 22:56:36 +0000
|
||||
Subject: [PATCH 30/30] Fix entries in /etc/hosts disabling static leases.
|
||||
|
||||
It is possible for a config entry to have one address family specified by a
|
||||
dhcp-host directive and the other added from /etc/hosts. This is especially
|
||||
common on OpenWrt because it uses odhcpd for DHCPv6 and IPv6 leases are
|
||||
imported into dnsmasq via a hosts file.
|
||||
|
||||
To handle this case there need to be separate *_HOSTS flags for IPv4 and IPv6.
|
||||
Otherwise when the hosts file is reloaded it will clear the CONFIG_ADDR(6) flag
|
||||
which was set by the dhcp-host directive.
|
||||
|
||||
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
||||
---
|
||||
src/dhcp-common.c | 8 ++++++--
|
||||
src/dnsmasq.h | 1 +
|
||||
2 files changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/src/dhcp-common.c
|
||||
+++ b/src/dhcp-common.c
|
||||
@@ -371,8 +371,14 @@ void dhcp_update_configs(struct dhcp_con
|
||||
int prot = AF_INET;
|
||||
|
||||
for (config = configs; config; config = config->next)
|
||||
+ {
|
||||
if (config->flags & CONFIG_ADDR_HOSTS)
|
||||
- config->flags &= ~(CONFIG_ADDR | CONFIG_ADDR6 | CONFIG_ADDR_HOSTS);
|
||||
+ config->flags &= ~(CONFIG_ADDR | CONFIG_ADDR_HOSTS);
|
||||
+#ifdef HAVE_DHCP6
|
||||
+ if (config->flags & CONFIG_ADDR6_HOSTS)
|
||||
+ config->flags &= ~(CONFIG_ADDR6 | CONFIG_ADDR6_HOSTS);
|
||||
+#endif
|
||||
+ }
|
||||
|
||||
#ifdef HAVE_DHCP6
|
||||
again:
|
||||
@@ -421,7 +427,7 @@ void dhcp_update_configs(struct dhcp_con
|
||||
(!(conf_tmp = config_find_by_address6(configs, &crec->addr.addr.addr.addr6, 128, 0)) || conf_tmp == config))
|
||||
{
|
||||
memcpy(&config->addr6, &crec->addr.addr.addr.addr6, IN6ADDRSZ);
|
||||
- config->flags |= CONFIG_ADDR6 | CONFIG_ADDR_HOSTS;
|
||||
+ config->flags |= CONFIG_ADDR6 | CONFIG_ADDR6_HOSTS;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
--- a/src/dnsmasq.h
|
||||
+++ b/src/dnsmasq.h
|
||||
@@ -796,6 +796,7 @@ struct dhcp_config {
|
||||
#define CONFIG_BANK 2048 /* from dhcp hosts file */
|
||||
#define CONFIG_ADDR6 4096
|
||||
#define CONFIG_WILDCARD 8192
|
||||
+#define CONFIG_ADDR6_HOSTS 16384 /* address added by from /etc/hosts */
|
||||
|
||||
struct dhcp_opt {
|
||||
int opt, len, flags;
|
||||
@@ -0,0 +1,65 @@
|
||||
--- 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))
|
||||
@@ -217,17 +198,10 @@ 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;
|
||||
- }
|
||||
}
|
||||
#endif
|
||||
|
||||
- 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));
|
||||
@@ -0,0 +1,47 @@
|
||||
From 79e60e145f8a595bca5a784c00b437216d51de68 Mon Sep 17 00:00:00 2001
|
||||
From: Steven Barth <steven@midlink.org>
|
||||
Date: Mon, 13 Apr 2015 09:45:20 +0200
|
||||
Subject: [PATCH] dnssec: improve timestamp heuristic
|
||||
|
||||
Signed-off-by: Steven Barth <steven@midlink.org>
|
||||
---
|
||||
src/dnssec.c | 15 +++++++++++----
|
||||
1 file changed, 11 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/src/dnssec.c
|
||||
+++ b/src/dnssec.c
|
||||
@@ -143,17 +143,24 @@ static time_t timestamp_time;
|
||||
int setup_timestamp(void)
|
||||
{
|
||||
struct stat statbuf;
|
||||
+ time_t now;
|
||||
+ time_t base = 1420070400; /* 1-1-2015 */
|
||||
|
||||
daemon->back_to_the_future = 0;
|
||||
|
||||
if (!daemon->timestamp_file)
|
||||
return 0;
|
||||
+
|
||||
+ now = time(NULL);
|
||||
+
|
||||
+ if (!stat("/proc/self/exe", &statbuf) && difftime(statbuf.st_mtime, base) > 0)
|
||||
+ base = statbuf.st_mtime;
|
||||
|
||||
if (stat(daemon->timestamp_file, &statbuf) != -1)
|
||||
{
|
||||
timestamp_time = statbuf.st_mtime;
|
||||
check_and_exit:
|
||||
- if (difftime(timestamp_time, time(0)) <= 0)
|
||||
+ if (difftime(now, base) >= 0 && difftime(timestamp_time, now) <= 0)
|
||||
{
|
||||
/* time already OK, update timestamp, and do key checking from the start. */
|
||||
if (utimes(daemon->timestamp_file, NULL) == -1)
|
||||
@@ -174,7 +181,7 @@ int setup_timestamp(void)
|
||||
|
||||
close(fd);
|
||||
|
||||
- timestamp_time = 1420070400; /* 1-1-2015 */
|
||||
+ timestamp_time = base; /* 1-1-2015 */
|
||||
tv[0].tv_sec = tv[1].tv_sec = timestamp_time;
|
||||
tv[0].tv_usec = tv[1].tv_usec = 0;
|
||||
if (utimes(daemon->timestamp_file, tv) == 0)
|
||||
@@ -0,0 +1,18 @@
|
||||
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>
|
||||
Reference in New Issue
Block a user