summaryrefslogtreecommitdiffstats
path: root/usr.sbin/dhcpd/memory.c
diff options
context:
space:
mode:
authorbeck <beck@openbsd.org>2008-05-07 12:19:20 +0000
committerbeck <beck@openbsd.org>2008-05-07 12:19:20 +0000
commit5f515bebfbc9b723b65ade175c407708da91f729 (patch)
tree0fa55cc0770ab12fb466af1503df536b0b0341a1 /usr.sbin/dhcpd/memory.c
parentRef to ripd instead of routed. (diff)
downloadwireguard-openbsd-5f515bebfbc9b723b65ade175c407708da91f729.tar.xz
wireguard-openbsd-5f515bebfbc9b723b65ade175c407708da91f729.zip
Add synchronisation support for dhcpd - this allows for two dhcpd's
with the same configuration to be run on the same net and they will keep their lease files/state in synch, and therefore allowing you to run redundant dhcpd's. Synchronization code stolen from spamd, uses an hmac key in /var/db/dhcpd.key if it exists. ok krw@ deraadt@
Diffstat (limited to 'usr.sbin/dhcpd/memory.c')
-rw-r--r--usr.sbin/dhcpd/memory.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.sbin/dhcpd/memory.c b/usr.sbin/dhcpd/memory.c
index a2884ba4689..84714112e7a 100644
--- a/usr.sbin/dhcpd/memory.c
+++ b/usr.sbin/dhcpd/memory.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: memory.c,v 1.14 2006/08/09 22:23:53 cloder Exp $ */
+/* $OpenBSD: memory.c,v 1.15 2008/05/07 12:19:20 beck Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium.
@@ -39,6 +39,7 @@
*/
#include "dhcpd.h"
+#include "sync.h"
struct subnet *subnets;
static struct shared_network *shared_networks;
@@ -52,6 +53,8 @@ static struct lease *dangling_leases;
static struct hash_table *vendor_class_hash;
static struct hash_table *user_class_hash;
+extern int syncsend;
+
void
enter_host(struct host_decl *hd)
{
@@ -843,9 +846,12 @@ write_leases(void)
for (s = shared_networks; s; s = s->next) {
for (l = s->leases; l; l = l->next) {
if (l->hardware_addr.hlen || l->uid_len ||
- (l->flags & ABANDONED_LEASE))
+ (l->flags & ABANDONED_LEASE)) {
if (!write_lease(l))
error("Can't rewrite lease database");
+ if (syncsend)
+ sync_lease(l);
+ }
}
}
if (!commit_leases())