From: Ted Lemon Date: Thu, 25 Jun 1998 22:12:05 +0000 (+0000) Subject: Only release non-requested leases on DHCPREQUEST. Use server-identifier if it's... X-Git-Tag: V2-BETA-1-PATCH-3~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8f14059949054217cffd801bb08bc402dd896b58;p=thirdparty%2Fdhcp.git Only release non-requested leases on DHCPREQUEST. Use server-identifier if it's in scope. --- diff --git a/server/dhcp.c b/server/dhcp.c index 2f1573c0a..8c94b88a1 100644 --- a/server/dhcp.c +++ b/server/dhcp.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: dhcp.c,v 1.57.2.3 1998/06/25 21:20:41 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dhcp.c,v 1.57.2.4 1998/06/25 22:12:05 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -834,14 +834,18 @@ void ack_lease (packet, lease, offer, when) state -> options [i] -> tree = (struct tree *)0; i = DHO_DHCP_SERVER_IDENTIFIER; - state -> options [i] = new_tree_cache ("server-id"); - state -> options [i] -> value = - (unsigned char *)&state -> ip -> primary_address; - state -> options [i] -> len = - sizeof state -> ip -> primary_address; - state -> options [i] -> buf_size = state -> options [i] -> len; - state -> options [i] -> timeout = 0xFFFFFFFF; - state -> options [i] -> tree = (struct tree *)0; + if (!state -> options [i]) { + state -> options [i] = new_tree_cache ("server-id"); + state -> options [i] -> value = + (unsigned char *)&state -> + ip -> primary_address; + state -> options [i] -> len = + sizeof state -> ip -> primary_address; + state -> options [i] -> buf_size + = state -> options [i] -> len; + state -> options [i] -> timeout = 0xFFFFFFFF; + state -> options [i] -> tree = (struct tree *)0; + } /* Sanity check the lease time. */ if ((state -> offered_expiry - cur_time) < 15) @@ -1339,7 +1343,8 @@ struct lease *find_lease (packet, share, ours) a better offer, use that; otherwise, release it. */ if (ip_lease) { if (lease) { - release_lease (ip_lease); + if (packet -> packet_type == DHCPREQUEST) + release_lease (ip_lease); } else { lease = ip_lease; lease -> host = (struct host_decl *)0; @@ -1351,7 +1356,8 @@ struct lease *find_lease (packet, share, ours) the lease that matched the client identifier. */ if (uid_lease) { if (lease) { - release_lease (uid_lease); + if (packet -> packet_type == DHCPREQUEST) + release_lease (uid_lease); } else { lease = uid_lease; lease -> host = (struct host_decl *)0; @@ -1361,7 +1367,8 @@ struct lease *find_lease (packet, share, ours) /* The lease that matched the hardware address is treated likewise. */ if (hw_lease) { if (lease) { - release_lease (hw_lease); + if (packet -> packet_type == DHCPREQUEST) + release_lease (hw_lease); } else { lease = hw_lease; lease -> host = (struct host_decl *)0;