0030-Fix-entries-in-etc-hosts-disabling-static-leases.patch 2.1 KB

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