mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-29 13:28:14 +00:00
Get rid of dynamic_hosts kludge - do host deletion like group deletion.
This commit is contained in:
parent
5d4afdbcd2
commit
e96b71e15c
67
server/mdb.c
67
server/mdb.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: mdb.c,v 1.12 1999/10/24 17:19:46 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: mdb.c,v 1.13 1999/10/24 23:27:52 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@ -36,7 +36,6 @@ struct hash_table *lease_ip_addr_hash;
|
|||||||
struct hash_table *lease_hw_addr_hash;
|
struct hash_table *lease_hw_addr_hash;
|
||||||
struct hash_table *host_name_hash;
|
struct hash_table *host_name_hash;
|
||||||
static struct lease *dangling_leases;
|
static struct lease *dangling_leases;
|
||||||
static struct host_decl *dynamic_hosts;
|
|
||||||
|
|
||||||
struct hash_table *group_name_hash;
|
struct hash_table *group_name_hash;
|
||||||
|
|
||||||
@ -58,8 +57,19 @@ isc_result_t enter_host (hd, dynamicp, commit)
|
|||||||
} else {
|
} else {
|
||||||
hp = (struct host_decl *)
|
hp = (struct host_decl *)
|
||||||
hash_lookup (host_name_hash,
|
hash_lookup (host_name_hash,
|
||||||
(unsigned char *)hd -> name,
|
(unsigned char *)hd -> name,
|
||||||
strlen (hd -> name));
|
strlen (hd -> name));
|
||||||
|
|
||||||
|
/* If it's deleted, we can supersede it. */
|
||||||
|
if (hp && (hp -> flags & HOST_DECL_DELETED)) {
|
||||||
|
delete_hash_entry (host_name_hash,
|
||||||
|
(unsigned char *)hd -> name,
|
||||||
|
strlen (hd -> name));
|
||||||
|
/* If the old entry wasn't dynamic, then we
|
||||||
|
always have to keep the deletion. */
|
||||||
|
if (!hp -> flags & HOST_DECL_DYNAMIC)
|
||||||
|
hd -> flags &= ~HOST_DECL_DYNAMIC;
|
||||||
|
}
|
||||||
|
|
||||||
/* If there isn't already a host decl matching this
|
/* If there isn't already a host decl matching this
|
||||||
address, add it to the hash table. */
|
address, add it to the hash table. */
|
||||||
@ -75,11 +85,6 @@ isc_result_t enter_host (hd, dynamicp, commit)
|
|||||||
return ISC_R_EXISTS;
|
return ISC_R_EXISTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dynamicp) {
|
|
||||||
hd -> flags |= HOST_DECL_DYNAMIC;
|
|
||||||
hd -> n_dynamic = dynamic_hosts;
|
|
||||||
dynamic_hosts = hd;
|
|
||||||
}
|
|
||||||
hd -> n_ipaddr = (struct host_decl *)0;
|
hd -> n_ipaddr = (struct host_decl *)0;
|
||||||
|
|
||||||
if (!hd -> type)
|
if (!hd -> type)
|
||||||
@ -200,32 +205,6 @@ isc_result_t delete_host (hd, commit)
|
|||||||
/* But we do need to do it once! :') */
|
/* But we do need to do it once! :') */
|
||||||
hd -> flags |= HOST_DECL_DELETED;
|
hd -> flags |= HOST_DECL_DELETED;
|
||||||
|
|
||||||
/* If it's a dynamic entry, we write the deletion to the lease
|
|
||||||
file, but then we can delete the host from the list of dynamic
|
|
||||||
hosts, and next time the lease file is rewritten, the entry
|
|
||||||
will simply be left out. */
|
|
||||||
if (hd -> flags & HOST_DECL_DYNAMIC) {
|
|
||||||
for (hp = dynamic_hosts; hp; hp = np) {
|
|
||||||
np = hp -> n_dynamic;
|
|
||||||
if (hd == hp)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (hp) {
|
|
||||||
if (np)
|
|
||||||
np -> n_dynamic = hp -> n_dynamic;
|
|
||||||
else
|
|
||||||
dynamic_hosts = hp -> n_dynamic;
|
|
||||||
hp -> n_dynamic = (struct host_decl *)0;
|
|
||||||
}
|
|
||||||
np = (struct host_decl *)0;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/* If it's *not* a dynamic entry, then we have to remember
|
|
||||||
in perpetuity that it's been deleted. */
|
|
||||||
hd -> n_dynamic = dynamic_hosts;
|
|
||||||
dynamic_hosts = hd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hd -> interface.hlen) {
|
if (hd -> interface.hlen) {
|
||||||
if (host_hw_addr_hash) {
|
if (host_hw_addr_hash) {
|
||||||
hp = (struct host_decl *)
|
hp = (struct host_decl *)
|
||||||
@ -313,7 +292,7 @@ isc_result_t delete_host (hd, commit)
|
|||||||
strlen (hd -> name));
|
strlen (hd -> name));
|
||||||
|
|
||||||
if (hp) {
|
if (hp) {
|
||||||
if (hp == hd) {
|
if (hp == hd && (hp -> flags & HOST_DECL_DYNAMIC)) {
|
||||||
delete_hash_entry (host_name_hash,
|
delete_hash_entry (host_name_hash,
|
||||||
(unsigned char *)hd -> name,
|
(unsigned char *)hd -> name,
|
||||||
strlen (hd -> name));
|
strlen (hd -> name));
|
||||||
@ -1406,9 +1385,19 @@ void write_leases ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write all the dynamically-created host declarations. */
|
/* Write all the dynamically-created group declarations. */
|
||||||
for (hp = dynamic_hosts; hp; hp = hp -> n_dynamic)
|
if (host_name_hash) {
|
||||||
write_host (hp);
|
for (i = 0; i < host_name_hash -> hash_count; i++) {
|
||||||
|
for (hb = host_name_hash -> buckets [i];
|
||||||
|
hb; hb = hb -> next) {
|
||||||
|
hp = (struct host_decl *)hb -> value;
|
||||||
|
if ((hp -> flags & HOST_DECL_DYNAMIC) ||
|
||||||
|
(!(hp -> flags & HOST_DECL_DYNAMIC) &&
|
||||||
|
(hp -> flags & HOST_DECL_DELETED)))
|
||||||
|
write_host (hp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Write all the leases. */
|
/* Write all the leases. */
|
||||||
for (s = shared_networks; s; s = s -> next) {
|
for (s = shared_networks; s; s = s -> next) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user