mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-23 20:21:53 +00:00
Clear down SLAAC-name data when a DHCP lease loses its hostname.
If a DHCPv4 lease loses its hostname, then the DHCPv6 name-address mapping derived from it become invalid and need to be cleared. Similarly, when a hostname is added to an existing lease, new SLAAC-name data needs to be generated. Thanks Martin Vlach (and Claude) for finding a symptom of this in the SLAAC logging code. This patch fixes that and does the correct thing more generally.
This commit is contained in:
2 files changed
+19
-17
No files matched your search
+12
-10
@@ -1027,6 +1027,13 @@ static void kill_name(struct dhcp_lease *lease)
|
|||||||
lease->old_hostname = lease->hostname;
|
lease->old_hostname = lease->hostname;
|
||||||
|
|
||||||
lease->hostname = lease->fqdn = NULL;
|
lease->hostname = lease->fqdn = NULL;
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP6
|
||||||
|
/* A lease which had a hostname when slaac_add_addrs() was called on it
|
||||||
|
may have slaac-address records. Since it no longer has a hostname,
|
||||||
|
they are no-longer valid, so update to remove them */
|
||||||
|
slaac_add_addrs(lease, 0, 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void lease_calc_fqdns(void)
|
void lease_calc_fqdns(void)
|
||||||
@@ -1151,6 +1158,10 @@ void lease_set_hostname(struct dhcp_lease *lease, const char *name, int auth, ch
|
|||||||
file_dirty = 1;
|
file_dirty = 1;
|
||||||
dns_dirty = 1;
|
dns_dirty = 1;
|
||||||
lease->flags |= LEASE_CHANGED; /* run script on change */
|
lease->flags |= LEASE_CHANGED; /* run script on change */
|
||||||
|
#ifdef HAVE_DHCP6
|
||||||
|
slaac_add_addrs(lease, dnsmasq_time(), 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lease_set_interface(struct dhcp_lease *lease, int interface, time_t now)
|
void lease_set_interface(struct dhcp_lease *lease, int interface, time_t now)
|
||||||
@@ -1250,15 +1261,6 @@ int do_script_run(time_t now)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DHCP6
|
|
||||||
struct slaac_address *slaac, *tmp;
|
|
||||||
for (slaac = lease->slaac_address; slaac; slaac = tmp)
|
|
||||||
{
|
|
||||||
tmp = slaac->next;
|
|
||||||
free(slaac);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
kill_name(lease);
|
|
||||||
#ifdef HAVE_SCRIPT
|
#ifdef HAVE_SCRIPT
|
||||||
queue_script(ACTION_DEL, lease, lease->old_hostname, now);
|
queue_script(ACTION_DEL, lease, lease->old_hostname, now);
|
||||||
#endif
|
#endif
|
||||||
@@ -1267,7 +1269,7 @@ int do_script_run(time_t now)
|
|||||||
#endif
|
#endif
|
||||||
old_leases = lease->next;
|
old_leases = lease->next;
|
||||||
|
|
||||||
free(lease->hostname);
|
kill_name(lease); /* frees slaac_addr, hostname and fqdn */
|
||||||
free(lease->clid);
|
free(lease->clid);
|
||||||
free(lease->extradata);
|
free(lease->extradata);
|
||||||
free(lease->agent_id);
|
free(lease->agent_id);
|
||||||
|
|||||||
+7
-7
@@ -28,15 +28,14 @@ void slaac_add_addrs(struct dhcp_lease *lease, time_t now, int force)
|
|||||||
struct dhcp_context *context;
|
struct dhcp_context *context;
|
||||||
int dns_dirty = 0;
|
int dns_dirty = 0;
|
||||||
|
|
||||||
if (!(lease->flags & LEASE_HAVE_HWADDR) ||
|
|
||||||
(lease->flags & (LEASE_TA | LEASE_NA)) ||
|
|
||||||
lease->last_interface == 0 ||
|
|
||||||
!lease->hostname)
|
|
||||||
return ;
|
|
||||||
|
|
||||||
old = lease->slaac_address;
|
old = lease->slaac_address;
|
||||||
lease->slaac_address = NULL;
|
lease->slaac_address = NULL;
|
||||||
|
|
||||||
|
if ((lease->flags & LEASE_HAVE_HWADDR) &&
|
||||||
|
!(lease->flags & (LEASE_TA | LEASE_NA)) &&
|
||||||
|
lease->last_interface != 0 &&
|
||||||
|
lease->hostname)
|
||||||
|
{
|
||||||
for (context = daemon->dhcp6; context; context = context->next)
|
for (context = daemon->dhcp6; context; context = context->next)
|
||||||
if ((context->flags & CONTEXT_RA_NAME) &&
|
if ((context->flags & CONTEXT_RA_NAME) &&
|
||||||
!(context->flags & CONTEXT_OLD) &&
|
!(context->flags & CONTEXT_OLD) &&
|
||||||
@@ -103,11 +102,12 @@ void slaac_add_addrs(struct dhcp_lease *lease, time_t now, int force)
|
|||||||
lease->slaac_address = slaac;
|
lease->slaac_address = slaac;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (old || dns_dirty)
|
if (old || dns_dirty)
|
||||||
lease_update_dns(1);
|
lease_update_dns(1);
|
||||||
|
|
||||||
/* Free any no reused */
|
/* Free any not reused */
|
||||||
for (; old; old = slaac)
|
for (; old; old = slaac)
|
||||||
{
|
{
|
||||||
slaac = old->next;
|
slaac = old->next;
|
||||||
|
|||||||
Reference in new issue
Block a user