ATF_TC_BODY(iaaddr_basic, tc) { struct iasubopt *iaaddr; struct iasubopt *iaaddr_copy; /* set up dhcp globals */ dhcp_context_create(); /* and other common arguments */ iaaddr = NULL; iaaddr_copy = NULL; /* tests */ if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_allocate() %s:%d", MDL); } if (iaaddr->state != FTS_FREE) { atf_tc_fail("ERROR: bad state %s:%d", MDL); } if (iaaddr->heap_index != -1) { atf_tc_fail("ERROR: bad heap_index %s:%d", MDL); } if (iasubopt_reference(&iaaddr_copy, iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_reference() %s:%d", MDL); } if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_reference() %s:%d", MDL); } if (iasubopt_dereference(&iaaddr_copy, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_reference() %s:%d", MDL); } }
ATF_TC_BODY(iaaddr_negative, tc) { struct iasubopt *iaaddr; struct iasubopt *iaaddr_copy; /* set up dhcp globals */ dhcp_context_create(); /* tests */ /* bogus allocate arguments */ if (iasubopt_allocate(NULL, MDL) != DHCP_R_INVALIDARG) { atf_tc_fail("ERROR: iasubopt_allocate() %s:%d", MDL); } iaaddr = (struct iasubopt *)1; if (iasubopt_allocate(&iaaddr, MDL) != DHCP_R_INVALIDARG) { atf_tc_fail("ERROR: iasubopt_allocate() %s:%d", MDL); } /* bogus reference arguments */ iaaddr = NULL; if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_allocate() %s:%d", MDL); } if (iasubopt_reference(NULL, iaaddr, MDL) != DHCP_R_INVALIDARG) { atf_tc_fail("ERROR: iasubopt_reference() %s:%d", MDL); } iaaddr_copy = (struct iasubopt *)1; if (iasubopt_reference(&iaaddr_copy, iaaddr, MDL) != DHCP_R_INVALIDARG) { atf_tc_fail("ERROR: iasubopt_reference() %s:%d", MDL); } iaaddr_copy = NULL; if (iasubopt_reference(&iaaddr_copy, NULL, MDL) != DHCP_R_INVALIDARG) { atf_tc_fail("ERROR: iasubopt_reference() %s:%d", MDL); } if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_reference() %s:%d", MDL); } /* bogus dereference arguments */ if (iasubopt_dereference(NULL, MDL) != DHCP_R_INVALIDARG) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } iaaddr = NULL; if (iasubopt_dereference(&iaaddr, MDL) != DHCP_R_INVALIDARG) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } }
ATF_TC_BODY(ia_na_basic, tc) { uint32_t iaid; struct ia_xx *ia_na; struct ia_xx *ia_na_copy; struct iasubopt *iaaddr; /* set up dhcp globals */ dhcp_context_create(); /* and other common arguments */ iaid = 666; ia_na = NULL; ia_na_copy = NULL; iaaddr = NULL; /* tests */ if (ia_allocate(&ia_na, iaid, "TestDUID", 8, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ia_allocate() %s:%d", MDL); } if (memcmp(ia_na->iaid_duid.data, &iaid, sizeof(iaid)) != 0) { atf_tc_fail("ERROR: bad IAID_DUID %s:%d", MDL); } if (memcmp(ia_na->iaid_duid.data+sizeof(iaid), "TestDUID", 8) != 0) { atf_tc_fail("ERROR: bad IAID_DUID %s:%d", MDL); } if (ia_na->num_iasubopt != 0) { atf_tc_fail("ERROR: bad num_iasubopt %s:%d", MDL); } if (ia_reference(&ia_na_copy, ia_na, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ia_reference() %s:%d", MDL); } if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_allocate() %s:%d", MDL); } if (ia_add_iasubopt(ia_na, iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ia_add_iasubopt() %s:%d", MDL); } ia_remove_iasubopt(ia_na, iaaddr, MDL); if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_reference() %s:%d", MDL); } if (ia_dereference(&ia_na, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ia_dereference() %s:%d", MDL); } if (ia_dereference(&ia_na_copy, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ia_dereference() %s:%d", MDL); } }
/* * Process a by-address lease query. */ static int process_lq_by_address(struct lq6_state *lq) { struct packet *packet = lq->packet; struct option_cache *oc; struct ipv6_pool *pool = NULL; struct data_string data; struct in6_addr addr; struct iasubopt *iaaddr = NULL; struct option_state *opt_state = NULL; u_int32_t lifetime; unsigned opt_cursor; int ret_val = 0; /* * Get the IAADDR. */ oc = lookup_option(&dhcpv6_universe, lq->query_opts, D6O_IAADDR); if (oc == NULL) { if (!set_error(lq, STATUS_MalformedQuery, "No OPTION_IAADDR.")) { log_error("process_lq_by_address: unable " "to set MalformedQuery status code."); return 0; } return 1; } memset(&data, 0, sizeof(data)); if (!evaluate_option_cache(&data, packet, NULL, NULL, lq->query_opts, NULL, &global_scope, oc, MDL) || (data.len < IAADDR_OFFSET)) { log_error("process_lq_by_address: error evaluating IAADDR."); goto exit; } memcpy(&addr, data.data, sizeof(addr)); data_string_forget(&data, MDL); /* * Find the lease. * Note the RFC 5007 says to use the link-address to find the link * or the ia-aadr when it is :: but in any case the ia-addr has * to be on the link, so we ignore the link-address here. */ if (find_ipv6_pool(&pool, D6O_IA_NA, &addr) != ISC_R_SUCCESS) { if (!set_error(lq, STATUS_NotConfigured, "Address not in a pool.")) { log_error("process_lq_by_address: unable " "to set NotConfigured status code."); goto exit; } ret_val = 1; goto exit; } if (iasubopt_hash_lookup(&iaaddr, pool->leases, &addr, sizeof(addr), MDL) == 0) { ret_val = 1; goto exit; } if ((iaaddr == NULL) || (iaaddr->state != FTS_ACTIVE) || (iaaddr->ia == NULL) || (iaaddr->ia->iaid_duid.len <= 4)) { ret_val = 1; goto exit; } /* * Build the client-data option (with client-id, ia-addr and clt-time). */ if (!option_state_allocate(&opt_state, MDL)) { log_error("process_lq_by_address: " "no memory for option state."); goto exit; } data_string_copy(&data, &iaaddr->ia->iaid_duid, MDL); data.data += 4; data.len -= 4; if (!save_option_buffer(&dhcpv6_universe, opt_state, NULL, (unsigned char *)data.data, data.len, D6O_CLIENTID, 0)) { log_error("process_lq_by_address: error saving client ID."); goto exit; } data_string_forget(&data, MDL); data.len = IAADDR_OFFSET; if (!buffer_allocate(&data.buffer, data.len, MDL)) { log_error("process_lq_by_address: no memory for ia-addr."); goto exit; } data.data = data.buffer->data; memcpy(data.buffer->data, &iaaddr->addr, 16); lifetime = iaaddr->prefer; putULong(data.buffer->data + 16, lifetime); lifetime = iaaddr->valid; putULong(data.buffer->data + 20, lifetime); if (!save_option_buffer(&dhcpv6_universe, opt_state, NULL, (unsigned char *)data.data, data.len, D6O_IAADDR, 0)) { log_error("process_lq_by_address: error saving ia-addr."); goto exit; } data_string_forget(&data, MDL); lifetime = htonl(iaaddr->ia->cltt); if (!save_option_buffer(&dhcpv6_universe, opt_state, NULL, (unsigned char *)&lifetime, 4, D6O_CLT_TIME, 0)) { log_error("process_lq_by_address: error saving clt time."); goto exit; } /* * Store the client-data option. */ opt_cursor = lq->cursor; putUShort(lq->buf.data + lq->cursor, (unsigned)D6O_CLIENT_DATA); lq->cursor += 2; /* Skip option length. */ lq->cursor += 2; lq->cursor += store_options6((char *)lq->buf.data + lq->cursor, sizeof(lq->buf) - lq->cursor, opt_state, lq->packet, required_opt_CLIENT_DATA, NULL); /* Reset the length. */ putUShort(lq->buf.data + opt_cursor + 2, lq->cursor - (opt_cursor + 4)); /* Done. */ ret_val = 1; exit: if (data.data != NULL) data_string_forget(&data, MDL); if (pool != NULL) ipv6_pool_dereference(&pool, MDL); if (iaaddr != NULL) iasubopt_dereference(&iaaddr, MDL); if (opt_state != NULL) option_state_dereference(&opt_state, MDL); return ret_val; }
ATF_TC_BODY(small_pool, tc) { struct in6_addr addr; struct ipv6_pool *pool; struct iasubopt *iaaddr; char *uid; struct data_string ds; unsigned int attempts; /* set up dhcp globals */ dhcp_context_create(); /* and other common arguments */ inet_pton(AF_INET6, "1:2:3:4::", &addr); addr.s6_addr[14] = 0x81; uid = "client0"; memset(&ds, 0, sizeof(ds)); ds.len = strlen(uid); if (!buffer_allocate(&ds.buffer, ds.len, MDL)) { atf_tc_fail("Out of memory"); } ds.data = ds.buffer->data; memcpy((char *)ds.data, uid, ds.len); pool = NULL; iaaddr = NULL; /* tests */ if (ipv6_pool_allocate(&pool, D6O_IA_NA, &addr, 127, 128, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ipv6_pool_allocate() %s:%d", MDL); } if (create_lease6(pool, &iaaddr, &attempts, &ds, 42) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: create_lease6() %s:%d", MDL); } if (renew_lease6(pool, iaaddr) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: renew_lease6() %s:%d", MDL); } if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } if (create_lease6(pool, &iaaddr, &attempts, &ds, 11) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: create_lease6() %s:%d", MDL); } if (renew_lease6(pool, iaaddr) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: renew_lease6() %s:%d", MDL); } if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } if (create_lease6(pool, &iaaddr, &attempts, &ds, 11) != ISC_R_NORESOURCES) { atf_tc_fail("ERROR: create_lease6() %s:%d", MDL); } if (ipv6_pool_dereference(&pool, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ipv6_pool_dereference() %s:%d", MDL); } }
ATF_TC_BODY(expire_order_reduce, tc) { struct iasubopt *iaaddr1, *iaaddr2; struct ipv6_pool *pool; struct in6_addr addr; char *uid; struct data_string ds; struct iasubopt *expired_iaaddr; unsigned int attempts; /* set up dhcp globals */ dhcp_context_create(); /* and other common arguments */ inet_pton(AF_INET6, "1:2:3:4::", &addr); uid = "client0"; memset(&ds, 0, sizeof(ds)); ds.len = strlen(uid); if (!buffer_allocate(&ds.buffer, ds.len, MDL)) { atf_tc_fail("Out of memory"); } ds.data = ds.buffer->data; memcpy((char *)ds.data, uid, ds.len); pool = NULL; iaaddr1 = NULL; iaaddr2 = NULL; expired_iaaddr = NULL; /* * Add two leases iaaddr1 with expire time of 200 * and iaaddr2 with expire time of 300. Then update * iaaddr2 to expire in 100 instead. This should cause * iaaddr2 to move with the hash list. */ /* create pool and add iaaddr1 and iaaddr2 */ if (ipv6_pool_allocate(&pool, D6O_IA_NA, &addr, 64, 128, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ipv6_pool_allocate() %s:%d", MDL); } if (create_lease6(pool, &iaaddr1, &attempts, &ds, 200) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: create_lease6() %s:%d", MDL); } if (renew_lease6(pool, iaaddr1) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: renew_lease6() %s:%d", MDL); } if (create_lease6(pool, &iaaddr2, &attempts, &ds, 300) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: create_lease6() %s:%d", MDL); } if (renew_lease6(pool, iaaddr2) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: renew_lease6() %s:%d", MDL); } /* verify pool */ if (pool->num_active != 2) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } /* reduce lease for iaaddr2 */ iaaddr2->soft_lifetime_end_time = 100; if (renew_lease6(pool, iaaddr2) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: renew_lease6() %s:%d", MDL); } /* expire a lease, it should be iaaddr2 with an expire time of 100 */ if (expire_lease6(&expired_iaaddr, pool, 1000) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: expire_lease6() %s:%d", MDL); } if (expired_iaaddr == NULL) { atf_tc_fail("ERROR: should have expired a lease %s:%d", MDL); } if (expired_iaaddr != iaaddr2) { atf_tc_fail("Error: incorrect lease expired %s:%d", MDL); } if (expired_iaaddr->hard_lifetime_end_time != 100) { atf_tc_fail("ERROR: bad hard_lifetime_end_time %s:%d", MDL); } if (iasubopt_dereference(&expired_iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } /* expire a lease, it should be iaaddr1 with an expire time of 200 */ if (expire_lease6(&expired_iaaddr, pool, 1000) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: expire_lease6() %s:%d", MDL); } if (expired_iaaddr == NULL) { atf_tc_fail("ERROR: should have expired a lease %s:%d", MDL); } if (expired_iaaddr != iaaddr1) { atf_tc_fail("Error: incorrect lease expired %s:%d", MDL); } if (expired_iaaddr->hard_lifetime_end_time != 200) { atf_tc_fail("ERROR: bad hard_lifetime_end_time %s:%d", MDL); } if (iasubopt_dereference(&expired_iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } /* cleanup */ if (iasubopt_dereference(&iaaddr1, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } if (iasubopt_dereference(&iaaddr2, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } if (ipv6_pool_dereference(&pool, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ipv6_pool_dereference() %s:%d", MDL); } }
ATF_TC_BODY(expire_order, tc) { struct iasubopt *iaaddr; struct ipv6_pool *pool; struct in6_addr addr; int i; char *uid; struct data_string ds; struct iasubopt *expired_iaaddr; unsigned int attempts; /* set up dhcp globals */ dhcp_context_create(); /* and other common arguments */ inet_pton(AF_INET6, "1:2:3:4::", &addr); uid = "client0"; memset(&ds, 0, sizeof(ds)); ds.len = strlen(uid); if (!buffer_allocate(&ds.buffer, ds.len, MDL)) { atf_tc_fail("Out of memory"); } ds.data = ds.buffer->data; memcpy((char *)ds.data, uid, ds.len); iaaddr = NULL; expired_iaaddr = NULL; /* tests */ pool = NULL; if (ipv6_pool_allocate(&pool, D6O_IA_NA, &addr, 64, 128, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ipv6_pool_allocate() %s:%d", MDL); } for (i=10; i<100; i+=10) { if (create_lease6(pool, &iaaddr, &attempts, &ds, i) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: create_lease6() %s:%d", MDL); } if (renew_lease6(pool, iaaddr) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: renew_lease6() %s:%d", MDL); } if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } if (pool->num_active != (i / 10)) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } } if (pool->num_active != 9) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } for (i=10; i<100; i+=10) { if (expire_lease6(&expired_iaaddr, pool, 1000) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: expire_lease6() %s:%d", MDL); } if (expired_iaaddr == NULL) { atf_tc_fail("ERROR: should have expired a lease %s:%d", MDL); } if (pool->num_active != (9 - (i / 10))) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } if (expired_iaaddr->hard_lifetime_end_time != i) { atf_tc_fail("ERROR: bad hard_lifetime_end_time %s:%d", MDL); } if (iasubopt_dereference(&expired_iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } } if (pool->num_active != 0) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } expired_iaaddr = NULL; if (expire_lease6(&expired_iaaddr, pool, 1000) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: expire_lease6() %s:%d", MDL); } if (ipv6_pool_dereference(&pool, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ipv6_pool_dereference() %s:%d", MDL); } }
ATF_TC_BODY(ipv6_pool_basic, tc) { struct iasubopt *iaaddr; struct in6_addr addr; struct ipv6_pool *pool; struct ipv6_pool *pool_copy; char addr_buf[INET6_ADDRSTRLEN]; char *uid; struct data_string ds; struct iasubopt *expired_iaaddr; unsigned int attempts; /* set up dhcp globals */ dhcp_context_create(); /* and other common arguments */ inet_pton(AF_INET6, "1:2:3:4::", &addr); uid = "client0"; memset(&ds, 0, sizeof(ds)); ds.len = strlen(uid); if (!buffer_allocate(&ds.buffer, ds.len, MDL)) { atf_tc_fail("Out of memory"); } ds.data = ds.buffer->data; memcpy((char *)ds.data, uid, ds.len); /* tests */ /* allocate, reference */ pool = NULL; if (ipv6_pool_allocate(&pool, D6O_IA_NA, &addr, 64, 128, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ipv6_pool_allocate() %s:%d", MDL); } if (pool->num_active != 0) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } if (pool->bits != 64) { atf_tc_fail("ERROR: bad bits %s:%d", MDL); } inet_ntop(AF_INET6, &pool->start_addr, addr_buf, sizeof(addr_buf)); if (strcmp(inet_ntop(AF_INET6, &pool->start_addr, addr_buf, sizeof(addr_buf)), "1:2:3:4::") != 0) { atf_tc_fail("ERROR: bad start_addr %s:%d", MDL); } pool_copy = NULL; if (ipv6_pool_reference(&pool_copy, pool, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ipv6_pool_reference() %s:%d", MDL); } /* create_lease6, renew_lease6, expire_lease6 */ iaaddr = NULL; if (create_lease6(pool, &iaaddr, &attempts, &ds, 1) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: create_lease6() %s:%d", MDL); } if (pool->num_inactive != 1) { atf_tc_fail("ERROR: bad num_inactive %s:%d", MDL); } if (renew_lease6(pool, iaaddr) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: renew_lease6() %s:%d", MDL); } if (pool->num_active != 1) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } expired_iaaddr = NULL; if (expire_lease6(&expired_iaaddr, pool, 0) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: expire_lease6() %s:%d", MDL); } if (expired_iaaddr != NULL) { atf_tc_fail("ERROR: should not have expired a lease %s:%d", MDL); } if (pool->num_active != 1) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } if (expire_lease6(&expired_iaaddr, pool, 1000) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: expire_lease6() %s:%d", MDL); } if (expired_iaaddr == NULL) { atf_tc_fail("ERROR: should have expired a lease %s:%d", MDL); } if (iasubopt_dereference(&expired_iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } if (pool->num_active != 0) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } /* release_lease6, decline_lease6 */ if (create_lease6(pool, &iaaddr, &attempts, &ds, 1) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: create_lease6() %s:%d", MDL); } if (renew_lease6(pool, iaaddr) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: renew_lease6() %s:%d", MDL); } if (pool->num_active != 1) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } if (release_lease6(pool, iaaddr) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: decline_lease6() %s:%d", MDL); } if (pool->num_active != 0) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } if (create_lease6(pool, &iaaddr, &attempts, &ds, 1) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: create_lease6() %s:%d", MDL); } if (renew_lease6(pool, iaaddr) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: renew_lease6() %s:%d", MDL); } if (pool->num_active != 1) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } if (decline_lease6(pool, iaaddr) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: decline_lease6() %s:%d", MDL); } if (pool->num_active != 1) { atf_tc_fail("ERROR: bad num_active %s:%d", MDL); } if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_dereference() %s:%d", MDL); } /* dereference */ if (ipv6_pool_dereference(&pool, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ipv6_pool_reference() %s:%d", MDL); } if (ipv6_pool_dereference(&pool_copy, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ipv6_pool_reference() %s:%d", MDL); } }
ATF_TC_BODY(ia_na_manyaddrs, tc) { uint32_t iaid; struct ia_xx *ia_na; struct iasubopt *iaaddr; int i; /* set up dhcp globals */ dhcp_context_create(); /* tests */ /* lots of iaaddr that we delete */ iaid = 666; ia_na = NULL; if (ia_allocate(&ia_na, iaid, "TestDUID", 8, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ia_allocate() %s:%d", MDL); } for (i=0; i<100; i++) { iaaddr = NULL; if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_allocate() %s:%d", MDL); } if (ia_add_iasubopt(ia_na, iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ia_add_iasubopt() %s:%d", MDL); } if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_reference() %s:%d", MDL); } } #if 0 for (i=0; i<100; i++) { iaaddr = ia_na->iasubopt[random() % ia_na->num_iasubopt]; ia_remove_iasubopt(ia_na, iaaddr, MDL); /* TODO: valgrind reports problem here: Invalid read of size 8 * Address 0x51e6258 is 56 bytes inside a block of size 88 free'd */ } #endif if (ia_dereference(&ia_na, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ia_dereference() %s:%d", MDL); } /* lots of iaaddr, let dereference cleanup */ iaid = 666; ia_na = NULL; if (ia_allocate(&ia_na, iaid, "TestDUID", 8, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ia_allocate() %s:%d", MDL); } for (i=0; i<100; i++) { iaaddr = NULL; if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_allocate() %s:%d", MDL); } if (ia_add_iasubopt(ia_na, iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ia_add_iasubopt() %s:%d", MDL); } if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: iasubopt_reference() %s:%d", MDL); } } if (ia_dereference(&ia_na, MDL) != ISC_R_SUCCESS) { atf_tc_fail("ERROR: ia_dereference() %s:%d", MDL); } }