Skip to content

Commit

Permalink
refs #27, #6: Ensure IPv4 random nexthop to be non-zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed Feb 24, 2016
1 parent 85ed37d commit 607c50e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion elements/ip/ip_route_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/lib/offloadtask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 8 additions & 5 deletions tests/test_ipv4route.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down

0 comments on commit 607c50e

Please sign in to comment.