dnsmasq: backport missing braces fix
[openwrt/staging/dedeckeh.git] / package / network / services / dnsmasq / patches / 001-Fix-entries-in-etc-hosts-disabling-static-leases.patch
1 From 18eac67c0a15b673c8d27002c248651b308093e4 Mon Sep 17 00:00:00 2001
2 From: Steven Siloti <ssiloti@gmail.com>
3 Date: Sun, 13 Jan 2019 22:56:36 +0000
4 Subject: [PATCH 30/30] Fix entries in /etc/hosts disabling static leases.
5
6 It is possible for a config entry to have one address family specified by a
7 dhcp-host directive and the other added from /etc/hosts. This is especially
8 common on OpenWrt because it uses odhcpd for DHCPv6 and IPv6 leases are
9 imported into dnsmasq via a hosts file.
10
11 To handle this case there need to be separate *_HOSTS flags for IPv4 and IPv6.
12 Otherwise when the hosts file is reloaded it will clear the CONFIG_ADDR(6) flag
13 which was set by the dhcp-host directive.
14
15 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
16 ---
17 src/dhcp-common.c | 8 ++++++--
18 src/dnsmasq.h | 1 +
19 2 files changed, 7 insertions(+), 2 deletions(-)
20
21 --- a/src/dhcp-common.c
22 +++ b/src/dhcp-common.c
23 @@ -371,8 +371,14 @@ void dhcp_update_configs(struct dhcp_con
24 int prot = AF_INET;
25
26 for (config = configs; config; config = config->next)
27 + {
28 if (config->flags & CONFIG_ADDR_HOSTS)
29 - config->flags &= ~(CONFIG_ADDR | CONFIG_ADDR6 | CONFIG_ADDR_HOSTS);
30 + config->flags &= ~(CONFIG_ADDR | CONFIG_ADDR_HOSTS);
31 +#ifdef HAVE_DHCP6
32 + if (config->flags & CONFIG_ADDR6_HOSTS)
33 + config->flags &= ~(CONFIG_ADDR6 | CONFIG_ADDR6_HOSTS);
34 +#endif
35 + }
36
37 #ifdef HAVE_DHCP6
38 again:
39 @@ -421,7 +427,7 @@ void dhcp_update_configs(struct dhcp_con
40 (!(conf_tmp = config_find_by_address6(configs, &crec->addr.addr.addr.addr6, 128, 0)) || conf_tmp == config))
41 {
42 memcpy(&config->addr6, &crec->addr.addr.addr.addr6, IN6ADDRSZ);
43 - config->flags |= CONFIG_ADDR6 | CONFIG_ADDR_HOSTS;
44 + config->flags |= CONFIG_ADDR6 | CONFIG_ADDR6_HOSTS;
45 continue;
46 }
47 #endif
48 --- a/src/dnsmasq.h
49 +++ b/src/dnsmasq.h
50 @@ -796,6 +796,7 @@ struct dhcp_config {
51 #define CONFIG_BANK 2048 /* from dhcp hosts file */
52 #define CONFIG_ADDR6 4096
53 #define CONFIG_WILDCARD 8192
54 +#define CONFIG_ADDR6_HOSTS 16384 /* address added by from /etc/hosts */
55
56 struct dhcp_opt {
57 int opt, len, flags;