From: Damien Neil Date: Thu, 15 Feb 2001 21:34:08 +0000 (+0000) Subject: Changed supersede_lease() to return 1, even if the commit option is X-Git-Tag: V3-BETA-2-PATCH-18~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=15c24b882bf7241ff75fa4161d408fa2ec1dfa1a;p=thirdparty%2Fdhcp.git Changed supersede_lease() to return 1, even if the commit option is not specified. (Before, it would always return 0 if commit was not given.) Fixed up the one call to supersede_lease() which expected the old behavior. Added a check to supersede_lease() to return an error if the pimmediate flag is given, and commit is not. (You should never be sending information on an uncommitted lease to a peer.) Separated the failover queue update (the propogate flag) test from the commit test in supersede_lease(), so that you can now enqueue an update on an uncommitted lease. --- diff --git a/server/dhcp.c b/server/dhcp.c index c3c88ea9d..799c8b755 100644 --- a/server/dhcp.c +++ b/server/dhcp.c @@ -43,7 +43,7 @@ #ifndef lint static char copyright[] = -"$Id: dhcp.c,v 1.181 2001/02/12 21:00:02 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dhcp.c,v 1.182 2001/02/15 21:34:08 neild Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -2058,9 +2058,8 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp) and we can't write the lease, don't ACK it (or BOOTREPLY it) either. */ - if (!(supersede_lease (lease, lt, !offer || offer == DHCPACK, - offer == DHCPACK, offer == DHCPACK) - || (offer && offer != DHCPACK))) { + if (!supersede_lease (lease, lt, !offer || offer == DHCPACK, + offer == DHCPACK, offer == DHCPACK)) { log_info ("%s: database update failed", msg); free_lease_state (state, MDL); static_lease_dereference (lease, MDL); diff --git a/server/mdb.c b/server/mdb.c index eb6414f0d..87f57a945 100644 --- a/server/mdb.c +++ b/server/mdb.c @@ -43,7 +43,7 @@ #ifndef lint static char copyright[] = -"$Id: mdb.c,v 1.52 2001/02/12 21:09:21 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n"; +"$Id: mdb.c,v 1.53 2001/02/15 21:34:07 neild Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -775,6 +775,14 @@ int supersede_lease (comp, lease, commit, propogate, pimmediate) struct lease *lp, **lq, *prev; TIME lp_next_state; +#if defined (FAILOVER_PROTOCOL) + /* We must commit leases before sending updates regarding them + to failover peers. It is, therefore, an error to set pimmediate + and not commit. */ + if (pimmediate && !commit) + return 0; +#endif + /* If there is no sample lease, just do the move. */ if (!lease) goto just_move_it; @@ -1047,14 +1055,21 @@ int supersede_lease (comp, lease, commit, propogate, pimmediate) (tvunref_t)pool_dereference); } - /* Return zero if we didn't commit the lease to permanent storage; - nonzero if we did. */ - return commit && write_lease (comp) && commit_leases () + if (commit) { + if (!write_lease (comp)) + return 0; + if (!commit_leases ()) + return 0; + } + #if defined (FAILOVER_PROTOCOL) - && (!propogate || - dhcp_failover_queue_update (comp, pimmediate)) + if (propogate) { + if (!dhcp_failover_queue_update (comp, pimmediate)) + return 0; + } #endif - ; + + return 1; } void process_state_transition (struct lease *lease)