]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Don't be so eager to respond to DHCPREQUEST messages with failover.
authorTed Lemon <source@isc.org>
Wed, 3 May 2000 06:29:15 +0000 (06:29 +0000)
committerTed Lemon <source@isc.org>
Wed, 3 May 2000 06:29:15 +0000 (06:29 +0000)
server/dhcp.c

index 57774932c93a957f6bd8b17e9d8e26e8cb4c8391..40cce9b69514006896126b824981a71a1c5c2569 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhcp.c,v 1.145 2000/05/02 00:00:08 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhcp.c,v 1.146 2000/05/03 06:29:15 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -154,21 +154,11 @@ void dhcpdiscover (packet, ms_nulltp)
        }
 
 #if defined (FAILOVER_PROTOCOL)
-       log_info ("lease -> pool = %lx\n", (unsigned long)lease -> pool);
-       if (lease -> pool) {
-               log_info ("lease -> pool -> failover_peer = %lx\n",
-                         (unsigned long)(lease -> pool -> failover_peer));
-
-               if (lease -> pool -> failover_peer)
-                       log_info ("lease -> pool -> failover_peer -> hba =%lx",
-                                 (unsigned long)(lease -> pool
-                                                 -> failover_peer -> hba));
-       }
-
        /* Do load balancing if configured. */
        if (lease -> pool &&
            lease -> pool -> failover_peer &&
-           lease -> pool -> failover_peer -> hba) {
+           lease -> pool -> failover_peer -> hba &&
+           lease -> pool -> failover_peer -> my_state == normal) {
                if (!load_balance_mine (packet,
                                        lease -> pool -> failover_peer))
                        return;
@@ -329,6 +319,35 @@ void dhcprequest (packet, ms_nulltp)
                }
        }
 
+#if defined (FAILOVER_PROTOCOL)
+       /* If we found a lease, but it belongs to a failover peer, and
+          the client is in the SELECTING state, ignore the request -
+          it's not ours. */
+       if (lease && (lease -> flags & PEER_IS_OWNER) &&
+           lookup_option (&dhcp_universe, packet -> options,
+                          DHO_DHCP_SERVER_IDENTIFIER)) {
+               log_info ("%s: ignored (not for me)", msgbuf);
+               return;
+       }
+
+       /* If we found a lease, but it belongs to a failover peer, and
+          we are communicating with that peer, drop it.    This really
+          shouldn't happen - if the peer is up, it should have renewed
+          the client while the client was in the RENEWING state.   However,
+          there are cases where the client won't be able to get unicast
+          packets to its server, but will be able to get broadcast packets
+          to its server, so for now I'm taking that possibility into
+          account, although this should be revisited later.  Oh, also if
+          the client comes up in the REBINDING state, we'll see it here,
+          and shouldn't respond until its server has had a chance at it. */
+       if (lease && (lease -> flags & PEER_IS_OWNER) &&
+           lease -> pool && lease -> pool -> failover_peer &&
+           lease -> pool -> failover_peer -> my_state == normal) {
+               log_info ("%s: ignored (not for me)", msgbuf);
+               return;
+       }
+#endif /* FAILOVER_PROTOCOL */
+
        /* If the address the client asked for is ours, but it wasn't
            available for the client, NAK it. */
        if (!lease && ours) {