gnrc_ipv6_nib: fix for 'holey' NIB

When there are holes in the NIB (e.g. when entries were removed)
currently the NIB crashes the system due to a failed assertion
(`DEVELHELP` needs to be activated to test this behavior).

This fixes this behavior by making the assertion a check that is always
compiled in.
This commit is contained in:
Martine Lenders 2017-11-01 19:37:43 +01:00
parent fa81932a8f
commit 72db5e48f0
2 changed files with 6 additions and 6 deletions

View File

@ -100,8 +100,9 @@ bool gnrc_ipv6_nib_ft_iter(const ipv6_addr_t *next_hop, unsigned iface,
_nib_offl_entry_t *offl = *state; _nib_offl_entry_t *offl = *state;
while ((offl = _nib_offl_iter(offl))) { while ((offl = _nib_offl_iter(offl))) {
assert((offl->mode != 0) || (offl->next_hop != NULL)); assert(offl->mode != 0);
if (((iface == 0) || (iface == _nib_onl_get_if(offl->next_hop))) && if ((offl->next_hop != NULL) &&
((iface == 0) || (iface == _nib_onl_get_if(offl->next_hop))) &&
((next_hop == NULL) || ipv6_addr_equal(&offl->next_hop->ipv6, ((next_hop == NULL) || ipv6_addr_equal(&offl->next_hop->ipv6,
next_hop))) { next_hop))) {
_nib_ft_get(offl, fte); _nib_ft_get(offl, fte);
@ -113,8 +114,8 @@ bool gnrc_ipv6_nib_ft_iter(const ipv6_addr_t *next_hop, unsigned iface,
} }
entry = *state; entry = *state;
while ((entry = _nib_drl_iter(entry))) { while ((entry = _nib_drl_iter(entry))) {
assert((entry->next_hop != NULL)); if ((entry->next_hop != NULL) &&
if (((iface == 0) || (iface == _nib_onl_get_if(entry->next_hop))) && ((iface == 0) || (iface == _nib_onl_get_if(entry->next_hop))) &&
((next_hop == NULL) || ipv6_addr_equal(&entry->next_hop->ipv6, ((next_hop == NULL) || ipv6_addr_equal(&entry->next_hop->ipv6,
next_hop))) { next_hop))) {
_nib_drl_ft_get(entry, fte); _nib_drl_ft_get(entry, fte);

View File

@ -81,8 +81,7 @@ bool gnrc_ipv6_nib_pl_iter(unsigned iface, void **state,
mutex_lock(&_nib_mutex); mutex_lock(&_nib_mutex);
while ((dst = _nib_offl_iter(dst)) != NULL) { while ((dst = _nib_offl_iter(dst)) != NULL) {
const _nib_onl_entry_t *node = dst->next_hop; const _nib_onl_entry_t *node = dst->next_hop;
assert(node != NULL); if ((node != NULL) && (dst->mode & _PL) &&
if ((dst->mode & _PL) &&
((iface == 0) || (_nib_onl_get_if(node) == iface))) { ((iface == 0) || (_nib_onl_get_if(node) == iface))) {
entry->pfx_len = dst->pfx_len; entry->pfx_len = dst->pfx_len;
ipv6_addr_set_unspecified(&entry->pfx); ipv6_addr_set_unspecified(&entry->pfx);