00f2102fde1b0fd2a1c5a1fdf1722603d767076d
[openwrt/staging/nbd.git] /
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/32] 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 @@ -372,7 +372,11 @@ void dhcp_update_configs(struct dhcp_con
24
25 for (config = configs; config; config = config->next)
26 if (config->flags & CONFIG_ADDR_HOSTS)
27 - config->flags &= ~(CONFIG_ADDR | CONFIG_ADDR6 | CONFIG_ADDR_HOSTS);
28 + config->flags &= ~(CONFIG_ADDR | CONFIG_ADDR_HOSTS);
29 +#ifdef HAVE_DHCP6
30 + if (config->flags & CONFIG_ADDR6_HOSTS)
31 + config->flags &= ~(CONFIG_ADDR6 | CONFIG_ADDR6_HOSTS);
32 +#endif
33
34 #ifdef HAVE_DHCP6
35 again:
36 @@ -421,7 +425,7 @@ void dhcp_update_configs(struct dhcp_con
37 (!(conf_tmp = config_find_by_address6(configs, &crec->addr.addr6, 128, 0)) || conf_tmp == config))
38 {
39 memcpy(&config->addr6, &crec->addr.addr6, IN6ADDRSZ);
40 - config->flags |= CONFIG_ADDR6 | CONFIG_ADDR_HOSTS;
41 + config->flags |= CONFIG_ADDR6 | CONFIG_ADDR6_HOSTS;
42 continue;
43 }
44 #endif
45 --- a/src/dnsmasq.h
46 +++ b/src/dnsmasq.h
47 @@ -789,6 +789,7 @@ struct dhcp_config {
48 #define CONFIG_BANK 2048 /* from dhcp hosts file */
49 #define CONFIG_ADDR6 4096
50 #define CONFIG_WILDCARD 8192
51 +#define CONFIG_ADDR6_HOSTS 16384 /* address added by from /etc/hosts */
52
53 struct dhcp_opt {
54 int opt, len, flags;