diff --git a/elements/ip/ip_route_core.cc b/elements/ip/ip_route_core.cc index 26374df..1d41446 100644 --- a/elements/ip/ip_route_core.cc +++ b/elements/ip/ip_route_core.cc @@ -47,7 +47,7 @@ int nba::ipv4route::load_rib_from_file( uint32_t addr = ntohl(inet_addr(str_addr)); uint16_t len = atoi(str_len); - add_route(tables, addr, len, rand() % 65536); + add_route(tables, addr, len, rand() % 65532 + 1); } fclose(fp); return 0; diff --git a/src/lib/offloadtask.cc b/src/lib/offloadtask.cc index 99d2717..6b3ad47 100644 --- a/src/lib/offloadtask.cc +++ b/src/lib/offloadtask.cc @@ -131,6 +131,7 @@ void OffloadTask::prepare_read_buffer() for (PacketBatch *batch : batches) { struct datablock_tracker *t = &batch->datablock_states[dbid]; tie(t->in_size, t->in_count) = db->calc_read_buffer_size(batch); + // Now aligned_item_sizes has valid values. if (t->in_size > 0 && t->in_count > 0) { cctx->alloc_input_buffer(io_base, t->in_size, t->host_in_ptr, t->dev_in_ptr); diff --git a/tests/test_ipv4route.cc b/tests/test_ipv4route.cc index a00c028..a01114e 100644 --- a/tests/test_ipv4route.cc +++ b/tests/test_ipv4route.cc @@ -97,10 +97,6 @@ TEST_P(IPLookupCUDAMatchTest, SinglePacket) { ntohl(inet_addr(ip1)), &cpu_results[0]); ipv4route::direct_lookup(tbl24_h, tbllong_h, ntohl(inet_addr(ip2)), &cpu_results[1]); - printf("converted ipaddr 1: 0x%08x\n", ntohl(inet_addr(ip1))); - printf("result 1: 0x%04x\n", cpu_results[0]); - printf("converted ipaddr 2: 0x%08x\n", ntohl(inet_addr(ip2))); - printf("result 2: 0x%04x\n", cpu_results[1]); EXPECT_NE(0, cpu_results[0]); EXPECT_NE(0, cpu_results[1]); @@ -193,7 +189,7 @@ TEST_P(IPLookupCUDAMatchTest, SinglePacket) { &checkbits_d, &tbl24_d, &tbllong_d }; - ASSERT_EQ(cudaSuccess, cudaLaunchKernel(k, dim3(num_batches), dim3(256), + ASSERT_EQ(cudaSuccess, cudaLaunchKernel(k, dim3(1), dim3(256), raw_args, 1024, 0)); ASSERT_EQ(cudaSuccess, cudaDeviceSynchronize()); ASSERT_EQ(cudaSuccess, cudaMemcpy(output_buffer, output_buffer_d, @@ -209,6 +205,13 @@ TEST_P(IPLookupCUDAMatchTest, SinglePacket) { free(datablocks[1]); free(input_buffer); free(output_buffer); + ASSERT_EQ(cudaSuccess, cudaFree(input_buffer_d)); + ASSERT_EQ(cudaSuccess, cudaFree(output_buffer_d)); + ASSERT_EQ(cudaSuccess, cudaFree(batch_ids_d)); + ASSERT_EQ(cudaSuccess, cudaFree(item_ids_d)); + ASSERT_EQ(cudaSuccess, cudaFree(db_ipv4_dest_addrs_d)); + ASSERT_EQ(cudaSuccess, cudaFree(db_ipv4_lookup_results_d)); + ASSERT_EQ(cudaSuccess, cudaFree(datablocks_d)); } TEST_P(IPLookupCUDAMatchTest, Batch) {