Skip to content

Commit

Permalink
Merge pull request #4447 from Yonezawa-T2/fix_gnrc_bugs
Browse files Browse the repository at this point in the history
fixes several bugs on GNRC network stack
  • Loading branch information
miri64 committed Jan 7, 2016
2 parents 6a28814 + cf35763 commit 94e4a08
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 8 deletions.
2 changes: 2 additions & 0 deletions sys/include/net/gnrc/ipv6/netif.h
Expand Up @@ -484,6 +484,8 @@ ipv6_addr_t *gnrc_ipv6_netif_find_addr(kernel_pid_t pid, const ipv6_addr_t *addr
*
* @param[in] prefix The prefix you want to search for.
*
* @pre @p out must not be NULL.
*
* @return The PID to the interface the address is registered to.
* @return KERNEL_PID_UNDEF, if no matching address can not be found on any
* interface.
Expand Down
7 changes: 7 additions & 0 deletions sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c
Expand Up @@ -163,6 +163,13 @@ void gnrc_ipv6_nc_remove(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr)
#endif
#ifdef MODULE_GNRC_SIXLOWPAN_ND_ROUTER
xtimer_remove(&entry->type_timeout);

gnrc_ipv6_netif_t *if_entry = gnrc_ipv6_netif_get(iface);

if ((if_entry != NULL) && (if_entry->rtr_adv_msg.content.ptr == (char *) entry)) {
/* cancel timer set by gnrc_ndp_rtr_sol_handle */
xtimer_remove(&if_entry->rtr_adv_timer);
}
#endif
#if defined(MODULE_GNRC_NDP_ROUTER) || defined(MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER)
xtimer_remove(&entry->rtr_adv_timer);
Expand Down
5 changes: 1 addition & 4 deletions sys/net/gnrc/network_layer/ipv6/netif/gnrc_ipv6_netif.c
Expand Up @@ -502,10 +502,7 @@ kernel_pid_t gnrc_ipv6_netif_find_by_prefix(ipv6_addr_t **out, const ipv6_addr_t
match = _find_by_prefix_unsafe(&tmp_res, ipv6_ifs + i, prefix, NULL);

if (match > best_match) {
if (out != NULL) {
*out = tmp_res;
}

*out = tmp_res;
res = ipv6_ifs[i].pid;
best_match = match;
}
Expand Down
7 changes: 4 additions & 3 deletions sys/net/gnrc/network_layer/sixlowpan/nd/gnrc_sixlowpan_nd.c
Expand Up @@ -154,10 +154,11 @@ kernel_pid_t gnrc_sixlowpan_nd_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_
if (nc_entry != NULL) {
gnrc_ipv6_netif_t *ipv6_if = gnrc_ipv6_netif_get(nc_entry->iface);
/* and interface is not 6LoWPAN */
if (!(ipv6_if->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN) ||
if (!((ipv6_if == NULL) ||
(ipv6_if->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN)) ||
/* or entry is registered */
(gnrc_ipv6_nc_get_type(nc_entry) == GNRC_IPV6_NC_TYPE_REGISTERED)) {
next_hop = dst;
(gnrc_ipv6_nc_get_type(nc_entry) == GNRC_IPV6_NC_TYPE_REGISTERED)) {
next_hop = dst;
}
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c
Expand Up @@ -430,7 +430,8 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt
case (GNRC_RPL_OPT_TARGET):
DEBUG("RPL: RPL TARGET DAO option parsed\n");
*included_opts |= ((uint32_t) 1) << GNRC_RPL_OPT_TARGET;
if_id = gnrc_ipv6_netif_find_by_prefix(NULL, &dodag->dodag_id);
ipv6_addr_t *prefix = NULL;
if_id = gnrc_ipv6_netif_find_by_prefix(&prefix, &dodag->dodag_id);
if (if_id == KERNEL_PID_UNDEF) {
DEBUG("RPL: no interface found for the configured DODAG id\n");
return false;
Expand Down
19 changes: 19 additions & 0 deletions sys/net/network_layer/fib/fib.c
Expand Up @@ -88,6 +88,14 @@ static int fib_find_entry(fib_table_t *table, uint8_t *dst, size_t dst_size,
int ret = -EHOSTUNREACH;
bool is_all_zeros_addr = true;

#if ENABLE_DEBUG
DEBUG("[fib_find_entry] dst =");
for (size_t i = 0; i < dst_size; i++) {
DEBUG(" %02x", dst[i]);
}
DEBUG("\n");
#endif

for (size_t i = 0; i < dst_size; ++i) {
if (dst[i] != 0) {
is_all_zeros_addr = false;
Expand Down Expand Up @@ -125,6 +133,7 @@ static int fib_find_entry(fib_table_t *table, uint8_t *dst, size_t dst_size,
int ret_comp = universal_address_compare(table->data.entries[i].global, dst, &match_size);
/* If we found an exact match */
if (ret_comp == 0 || (is_all_zeros_addr && match_size == 0)) {
DEBUG("[fib_find_entry] found an exact match");
entry_arr[0] = &(table->data.entries[i]);
*entry_arr_size = 1;
/* we will not find a better one so we return */
Expand All @@ -148,6 +157,16 @@ static int fib_find_entry(fib_table_t *table, uint8_t *dst, size_t dst_size,
}
}

#if ENABLE_DEBUG
if (count > 0) {
DEBUG("[fib_find_entry] found prefix on interface %d:", entry_arr[0]->iface_id);
for (size_t i = 0; i < entry_arr[0]->global->address_size; i++) {
DEBUG(" %02x", entry_arr[0]->global->address[i]);
}
DEBUG("\n");
}
#endif

*entry_arr_size = count;
return ret;
}
Expand Down

0 comments on commit 94e4a08

Please sign in to comment.