integ/base/dnsmasq/centos/patches/dnsmasq-update-ipv6-leases-from-config.patch
slin14 79eb1d3a08 de-fuzz dnsmasq patches
When do Centos 7.5 upgraded, some patches didn't resolve and cause
the fuzzy in the line numbers of the patches. And it may cause
.orig file is created when do patch. And this .orig file will lead
to rpm packaging failure due to the unexpected and unpackaged .orig
file.

Please visit below link to get more detail info:
https://bugs.launchpad.net/starlingx/+bug/1794611

Solution:
  Safest solution is to de-fuzz our patches.

Story: 2003389
Task: 26755

Change-Id: Ic7d7d8b060861a8d6af5555872add23ee8b348bf
Signed-off-by: slin14 <shuicheng.lin@intel.com>
2018-09-28 08:09:34 +08:00

84 lines
3.3 KiB
Diff

From 1a91b72146893dab1cca1354dd3b0a8fa74d6b55 Mon Sep 17 00:00:00 2001
From: Scott Little <scott.little@windriver.com>
Date: Tue, 18 Oct 2016 13:07:56 -0400
Subject: WRS: Patch22: dnsmasq-update-ipv6-leases-from-config.patch
---
src/lease.c | 53 +++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 43 insertions(+), 10 deletions(-)
diff --git a/src/lease.c b/src/lease.c
index 69e698c..bc56c47 100644
--- a/src/lease.c
+++ b/src/lease.c
@@ -210,6 +210,18 @@ void lease_init(time_t now)
dns_dirty = 1;
}
+static int lease_match_config_addr(struct dhcp_lease *lease, struct dhcp_config *config)
+{
+ if (!(lease->flags & (LEASE_TA | LEASE_NA)) && (config->flags & CONFIG_ADDR))
+ return (lease->addr.s_addr == config->addr.s_addr);
+#ifdef HAVE_DHCP6
+ else if ((lease->flags & (LEASE_TA | LEASE_NA)) && (config->flags & CONFIG_ADDR6))
+ return IN6_ARE_ADDR_EQUAL(&config->addr6, &lease->addr6);
+#endif
+ else
+ return 0;
+}
+
void lease_update_from_configs(void)
{
/* changes to the config may change current leases. */
@@ -218,16 +230,37 @@ void lease_update_from_configs(void)
struct dhcp_config *config;
char *name;
- for (lease = leases; lease; lease = lease->next)
- if (lease->flags & (LEASE_TA | LEASE_NA))
- continue;
- else if ((config = find_config(daemon->dhcp_conf, NULL, lease->clid, lease->clid_len,
- lease->hwaddr, lease->hwaddr_len, lease->hwaddr_type, NULL)) &&
- (config->flags & CONFIG_NAME) &&
- (!(config->flags & CONFIG_ADDR) || config->addr.s_addr == lease->addr.s_addr))
- lease_set_hostname(lease, config->hostname, 1, get_domain(lease->addr), NULL);
- else if ((name = host_from_dns(lease->addr)))
- lease_set_hostname(lease, name, 1, get_domain(lease->addr), NULL); /* updates auth flag only */
+ for (lease = leases; lease; lease = lease->next) {
+ if (lease->flags & LEASE_TA)
+ continue; /* we do not update temporary ipv6 leases */
+
+ config = find_config(daemon->dhcp_conf, NULL, lease->clid, lease->clid_len,
+ (lease->hwaddr_len > 0 ? lease->hwaddr : NULL),
+ lease->hwaddr_len, lease->hwaddr_type, NULL);
+ if (config)
+ {
+ if ((!(config->flags & (CONFIG_ADDR | CONFIG_ADDR6))) ||
+ lease_match_config_addr(lease, config))
+ {
+ /*
+ * Either we matched on a config that doesn't have an address in
+ * which case we'll just use the hostname, or we matched on a
+ * config that has the same IP address.
+ */
+ if (!(lease->flags & (LEASE_TA | LEASE_NA)))
+ lease_set_hostname(lease, config->hostname, 1, get_domain(lease->addr), NULL);
+#ifdef HAVE_DHCP6
+ else
+ lease_set_hostname(lease, config->hostname, 1, get_domain6(&lease->addr6), NULL);
+#endif
+ continue; /* lease updated; move on to next lease */
+ }
+ }
+
+ /* attempt to find a matching DNS cache entry for an IPv4 entry */
+ if (!(lease->flags & (LEASE_TA | LEASE_NA)) && (name = host_from_dns(lease->addr)))
+ lease_set_hostname(lease, name, 1, get_domain(lease->addr), NULL); /* updates auth flag only */
+ }
}
static void ourprintf(int *errp, char *format, ...)
--
2.7.4