1 diff -up dhcp-4.2.0/server/dhcpv6.c.noprefixavail dhcp-4.2.0/server/dhcpv6.c
2 --- dhcp-4.2.0/server/dhcpv6.c.noprefixavail 2010-10-07 13:48:45.000000000 +0200
3 +++ dhcp-4.2.0/server/dhcpv6.c 2010-10-13 11:00:25.000000000 +0200
4 @@ -1134,7 +1134,7 @@ try_client_v6_prefix(struct iasubopt **p
5 return DHCP_R_INVALIDARG;
7 tmp_plen = (int) requested_pref->data[0];
8 - if ((tmp_plen < 3) || (tmp_plen > 128)) {
9 + if ((tmp_plen < 3) || (tmp_plen > 128) ||((int)tmp_plen != pool->units)) {
12 memcpy(&tmp_pref, requested_pref->data + 1, sizeof(tmp_pref));
13 @@ -1147,9 +1147,8 @@ try_client_v6_prefix(struct iasubopt **p
17 - if (((int)tmp_plen != pool->units) ||
18 - !ipv6_in_pool(&tmp_pref, pool)) {
19 - return ISC_R_FAILURE;
20 + if (!ipv6_in_pool(&tmp_pref, pool)) {
21 + return ISC_R_ADDRNOTAVAIL;
24 if (prefix6_exists(pool, &tmp_pref, tmp_plen)) {
25 @@ -1409,13 +1408,6 @@ lease_to_client(struct data_string *repl
26 if ((status != ISC_R_SUCCESS) &&
27 (status != ISC_R_NORESOURCES))
31 - * If any prefix cannot be given to any IA_PD, then
32 - * set the NoPrefixAvail status code.
34 - if (reply.client_resources == 0)
35 - no_resources_avail = ISC_TRUE;
39 @@ -1549,36 +1541,6 @@ lease_to_client(struct data_string *repl
40 reply.opt_state, reply.packet,
43 - } else if (no_resources_avail && (reply.ia_count == 0) &&
44 - (reply.packet->dhcpv6_msg_type == DHCPV6_SOLICIT))
46 - /* Set the NoPrefixAvail status code. */
47 - if (!set_status_code(STATUS_NoPrefixAvail,
48 - "No prefixes available for this "
49 - "interface.", reply.opt_state)) {
50 - log_error("lease_to_client: Unable to set "
51 - "NoPrefixAvail status code.");
55 - /* Rewind the cursor to the start. */
56 - reply.cursor = REPLY_OPTIONS_INDEX;
59 - * Produce an advertise that includes only:
65 - reply.buf.reply.msg_type = DHCPV6_ADVERTISE;
66 - reply.cursor += store_options6((char *)reply.buf.data +
70 - reply.opt_state, reply.packet,
75 * Having stored the client's IA's, store any options that
76 @@ -2793,16 +2755,18 @@ find_client_temporaries(struct reply_sta
79 reply_process_try_addr(struct reply_state *reply, struct iaddr *addr) {
80 - isc_result_t status = ISC_R_NORESOURCES;
81 + isc_result_t status = ISC_R_ADDRNOTAVAIL;
82 struct ipv6_pool *pool;
84 struct data_string data_addr;
86 if ((reply == NULL) || (reply->shared == NULL) ||
87 - (reply->shared->ipv6_pools == NULL) || (addr == NULL) ||
88 - (reply->lease != NULL))
89 + (addr == NULL) || (reply->lease != NULL))
90 return DHCP_R_INVALIDARG;
92 + if (reply->shared->ipv6_pools == NULL)
93 + return ISC_R_ADDRNOTAVAIL;
95 memset(&data_addr, 0, sizeof(data_addr));
96 data_addr.len = addr->len;
97 data_addr.data = addr->iabuf;
98 @@ -3314,7 +3278,9 @@ reply_process_ia_pd(struct reply_state *
99 if (status == ISC_R_CANCELED)
102 - if ((status != ISC_R_SUCCESS) && (status != ISC_R_ADDRINUSE))
103 + if ((status != ISC_R_SUCCESS) &&
104 + (status != ISC_R_ADDRINUSE) &&
105 + (status != ISC_R_ADDRNOTAVAIL))
109 @@ -3594,7 +3560,8 @@ reply_process_prefix(struct reply_state
111 /* Either error out or skip this prefix. */
112 if ((status != ISC_R_SUCCESS) &&
113 - (status != ISC_R_ADDRINUSE))
114 + (status != ISC_R_ADDRINUSE) &&
115 + (status != ISC_R_ADDRNOTAVAIL))
118 if (reply->lease == NULL) {
119 @@ -3773,16 +3740,18 @@ prefix_is_owned(struct reply_state *repl
121 reply_process_try_prefix(struct reply_state *reply,
122 struct iaddrcidrnet *pref) {
123 - isc_result_t status = ISC_R_NORESOURCES;
124 + isc_result_t status = ISC_R_ADDRNOTAVAIL;
125 struct ipv6_pool *pool;
127 struct data_string data_pref;
129 if ((reply == NULL) || (reply->shared == NULL) ||
130 - (reply->shared->ipv6_pools == NULL) || (pref == NULL) ||
131 - (reply->lease != NULL))
132 + (pref == NULL) || (reply->lease != NULL))
133 return DHCP_R_INVALIDARG;
135 + if (reply->shared->ipv6_pools == NULL)
136 + return ISC_R_ADDRNOTAVAIL;
138 memset(&data_pref, 0, sizeof(data_pref));
140 if (!buffer_allocate(&data_pref.buffer, data_pref.len, MDL)) {