]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Better control over allocated IID
authorFrancis Dupont <fdupont@isc.org>
Fri, 28 Dec 2007 09:46:42 +0000 (09:46 +0000)
committerFrancis Dupont <fdupont@isc.org>
Fri, 28 Dec 2007 09:46:42 +0000 (09:46 +0000)
RELNOTES
server/mdb6.c

index 5c85c02a71e9cb8708754a4200d6be5415c73d1b..2437f8b0448423796267288cf6b52b4ae01de8c3 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -78,6 +78,9 @@ suggested fixes to <dhcp-users@isc.org>.
 
 - Some definitions not in phase with the IANA registry were updated.
 
+- Allocated interface IDs are better controlled ('u' bit set to zero,
+  reserved IDs avoided).
+
                        Changes since 4.0.0b3
 
 - The reverse dns name for PTR updates on IPv6 addresses has been fixed to
index 524c09f3ed52db8840485646d0dad844edc9db4e..739122621d226405a6bdd68f4a5518e7ed8c654f 100644 (file)
@@ -617,8 +617,20 @@ create_address(struct in6_addr *addr,
                case 6: str[i] = (str[i] & 0x03) | (net_str[i] & 0xFC); break;
                case 7: str[i] = (str[i] & 0x01) | (net_str[i] & 0xFE); break;
        }
+       /* set the 'u' bit to zero for /64s. */
+       if (net_bits == 64)
+               str[8] &= ~0x02;
 }
 
+/* Reserved Subnet Router Anycast ::0:0:0:0. */
+static struct in6_addr rtany = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+/* Reserved Subnet Anycasts ::fdff:ffff:ffff:ff80-::fdff:ffff:ffff:ffff. */
+static struct in6_addr resany = {
+       0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80
+};
+
 /*
  * Create a lease for the given address and client duid.
  *
@@ -650,6 +662,7 @@ activate_lease6(struct ipv6_pool *pool, struct iaaddr **addr,
        struct data_string new_ds;
        struct iaaddr *iaaddr;
        isc_result_t result;
+       isc_boolean_t reserved_iid;
 
        /* 
         * Use the UID as our initial seed for the hash
@@ -672,15 +685,31 @@ activate_lease6(struct ipv6_pool *pool, struct iaaddr **addr,
                 */
                create_address(&tmp, &pool->start_addr, pool->bits, &ds);
 
+               /*
+                * Avoid reserved interface IDs.
+                * (cf. draft-krishnan-ipv6-reserved-iids-02.txt)
+                */
+               reserved_iid = ISC_FALSE;
+               if (memcmp(&tmp, &rtany, 16) == 0) {
+                       reserved_iid = ISC_TRUE;
+               }
+               if (!reserved_iid &&
+                   (memcmp(&tmp, &resany, 15) == 0) &&
+                   (tmp.s6_addr[15] & 0x80 == 0x80)) {
+                       reserved_iid = ISC_TRUE;
+               }
+
                /*
                 * If this address is not in use, we're happy with it
                 */
                test_iaaddr = NULL;
-               if (iaaddr_hash_lookup(&test_iaaddr, pool->addrs,
-                                      &tmp, sizeof(tmp), MDL) == 0) {
+               if (!reserved_iid &&
+                   (iaaddr_hash_lookup(&test_iaaddr, pool->addrs,
+                                       &tmp, sizeof(tmp), MDL) == 0)) {
                        break;
                }
-               iaaddr_dereference(&test_iaaddr, MDL);
+               if (test_iaaddr != NULL)
+                       iaaddr_dereference(&test_iaaddr, MDL);
 
                /* 
                 * Otherwise, we create a new input, adding the address