]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Changed supersede_lease() to return 1, even if the commit option is
authorDamien Neil <source@isc.org>
Thu, 15 Feb 2001 21:34:08 +0000 (21:34 +0000)
committerDamien Neil <source@isc.org>
Thu, 15 Feb 2001 21:34:08 +0000 (21:34 +0000)
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.

server/dhcp.c
server/mdb.c

index c3c88ea9d27375f0a826d1b02ab4212a72fa7a49..799c8b7550c063f9453a29572537d2e86f55379a 100644 (file)
@@ -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);
index eb6414f0d941a2ffe10176823d6f5d0c35aba738..87f57a94592b8bee6b1449614ed551cc532beda5 100644 (file)
@@ -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)