]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- Fix a bug where the first host declaration with a hardware address
authorTed Lemon <source@isc.org>
Sun, 9 Jul 2000 07:00:06 +0000 (07:00 +0000)
committerTed Lemon <source@isc.org>
Sun, 9 Jul 2000 07:00:06 +0000 (07:00 +0000)
  wasn't being entered into the database.

server/mdb.c

index 4c51b00da70992506dd5e760cb8b62c2cd96a29e..a6d2e42811d86c71776ba402e529f6bc5efc7cda 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: mdb.c,v 1.39 2000/07/06 22:40:27 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: mdb.c,v 1.40 2000/07/09 07:00:06 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -124,25 +124,22 @@ isc_result_t enter_host (hd, dynamicp, commit)
                } else {
                        /* If there isn't already a host decl matching this
                           address, add it to the hash table. */
-                       if (!host_hash_lookup (&hp, host_hw_addr_hash,
-                                              hd -> interface.hbuf,
-                                              hd -> interface.hlen, MDL)) {
-                               host_hash_add (host_hw_addr_hash,
-                                              hd -> interface.hbuf,
-                                              hd -> interface.hlen,
-                                              hd, MDL);
-                       }
+                       host_hash_lookup (&hp, host_hw_addr_hash,
+                                         hd -> interface.hbuf,
+                                         hd -> interface.hlen, MDL);
+               }
+               if (!hp)
+                       host_hash_add (host_hw_addr_hash, hd -> interface.hbuf,
+                                      hd -> interface.hlen, hd, MDL);
+               else {
+                       /* If there was already a host declaration for
+                          this hardware address, add this one to the
+                          end of the list. */
+                       for (np = hp; np -> n_ipaddr; np = np -> n_ipaddr)
+                               ;
+                       host_reference (&np -> n_ipaddr, hd, MDL);
+                       host_dereference (&hp, MDL);
                }
-       }
-
-       /* If there was already a host declaration for this hardware
-          address, add this one to the end of the list. */
-
-       if (hp) {
-               for (np = hp; np -> n_ipaddr; np = np -> n_ipaddr)
-                       ;
-               host_reference (&np -> n_ipaddr, hd, MDL);
-               host_dereference (&hp, MDL);
        }
 
        /* See if there's a statement that sets the client identifier.