]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Tweak load balance handling.
authorTed Lemon <source@isc.org>
Thu, 31 Aug 2000 04:40:55 +0000 (04:40 +0000)
committerTed Lemon <source@isc.org>
Thu, 31 Aug 2000 04:40:55 +0000 (04:40 +0000)
server/dhcp.c

index 57ff9c3cd39a0f5e89aa6b5f5de725e6e14f5bae..6ff4ee1e75205243947a1ddb3dd04eb85dc4c2d2 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcp.c,v 1.161 2000/08/28 19:36:10 neild Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhcp.c,v 1.162 2000/08/31 04:40:55 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -293,16 +293,12 @@ void dhcprequest (packet, ms_nulltp)
                }
                if (peer -> service_state == cooperating) {
                        /* XXX */
-                       /* We have to ignore load balancing for
-                          clients with giaddr set to zero because
-                          we need to respond to clients in RENEWING
-                          state, that the other server can't hear,
-                          but not to clients in REBINDING state,
-                          which the other server _can_ hear, but
-                          we can't tell which state the client is
-                          in if it's on the local network. */
-                       if (packet -> raw -> giaddr.s_addr == 0 ||
-                           !load_balance_mine (packet, peer)) {
+                       /* If the client is in RENEWING state and sends
+                          us a DHCPREQUEST, we're going to ignore it,
+                          so it's going to have to fall back to REBINDING
+                          state before it can get a response from the
+                          other server.   Ick. */
+                       if (!load_balance_mine (packet, peer)) {
                                log_debug ("%s: load balance to peer %s",
                                           msgbuf, peer -> name);
                                goto out;
@@ -1654,19 +1650,21 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp)
                                   XXX What do we do in this case?
                                   XXX should the expiry timer on the lease
                                   XXX set tsfp and tstp to zero? */
-                               if (lease -> tsfp == 0)
+                               if (lease -> tsfp < cur_time) {
                                        lease_time = peer -> mclt;
-                               else
+                               } else {
                                        lease_time = (lease -> tsfp  - cur_time
                                                      + peer -> mclt);
+                               }
                        } else {
                                if (cur_time + lease_time > lease -> tsfp &&
-                                   lease_time > peer -> mclt / 2)
+                                   lease_time > peer -> mclt / 2) {
                                        lt -> tstp = (cur_time + lease_time +
                                                      peer -> mclt / 2);
-                               else
+                               } else { 
                                        lt -> tstp = (cur_time + lease_time +
                                                      lease_time / 2);
+                               }
                        }
 
                        lt -> cltt = cur_time;