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.
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 libreCMC because it uses odhcpd for DHCPv6 and IPv6 leases are
9 imported into dnsmasq via a hosts file.
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.
15 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
17 src/dhcp-common.c | 8 ++++++--
19 2 files changed, 7 insertions(+), 2 deletions(-)
21 --- a/src/dhcp-common.c
22 +++ b/src/dhcp-common.c
23 @@ -372,7 +372,11 @@ void dhcp_update_configs(struct dhcp_con
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);
30 + if (config->flags & CONFIG_ADDR6_HOSTS)
31 + config->flags &= ~(CONFIG_ADDR6 | CONFIG_ADDR6_HOSTS);
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))
39 memcpy(&config->addr6, &crec->addr.addr6, IN6ADDRSZ);
40 - config->flags |= CONFIG_ADDR6 | CONFIG_ADDR_HOSTS;
41 + config->flags |= CONFIG_ADDR6 | CONFIG_ADDR6_HOSTS;
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 */