diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c b/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c index acea7db365034db6d474c4feb649b70be66579d1..fe9121913974fff8c0d6724792ad498d5e03a5ad 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c @@ -146,13 +146,18 @@ static inline _nib_onl_entry_t *_cache_out_onl_entry(const ipv6_addr_t *addr, res->mode = _NC; } /* requeue if not garbage collectible at the moment or queueing - * newly created NCE */ + * newly created NCE or in case entry becomes garbage collectible + * again */ clist_rpush(&_next_removable, (clist_node_t *)tmp); if (res == NULL) { /* no new entry created yet, get next entry in FIFO */ tmp = (_nib_onl_entry_t *)clist_lpop(&_next_removable); } - } while ((tmp != first) && (res != NULL)); + } while ((tmp != first) && (res == NULL)); + if (res == NULL) { + /* we did not find any removable entry => requeue current one */ + clist_rpush(&_next_removable, (clist_node_t *)tmp); + } return res; }