Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/network_layer/fib: corrected handling of all 0 addresses #2783

Merged
merged 1 commit into from
Jun 2, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion sys/net/network_layer/fib/fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ static int fib_find_entry(uint8_t *dst, size_t dst_size,
size_t prefix_size = 0;
size_t match_size = dst_size;
int ret = -EHOSTUNREACH;
bool is_all_zeros_addr = true;

for(size_t i = 0; i < dst_size; ++i) {
if (dst[i] != 0) {
is_all_zeros_addr = false;
break;
}
}

for (size_t i = 0; i < FIB_MAX_FIB_TABLE_ENTRIES; ++i) {

Expand Down Expand Up @@ -133,7 +141,8 @@ static int fib_find_entry(uint8_t *dst, size_t dst_size,
(universal_address_compare(fib_table[i].global, dst, &match_size) == 0)) {

/* If we found an exact match */
if (match_size == dst_size) {
if (match_size == dst_size
|| (is_all_zeros_addr && match_size == 0)) {
entry_arr[0] = &(fib_table[i]);
*entry_arr_size = 1;
/* we will not find a better one so we return */
Expand Down