From 7fcc2ab5d68c927ff310b5ce6321e9c52dc05bd8 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 12 Feb 2019 12:06:04 +0100 Subject: [PATCH 1/2] gnrc_ipv6_nib: fix iteration conditions for cache-out --- sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 acea7db365..c730fdb825 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c @@ -152,7 +152,11 @@ static inline _nib_onl_entry_t *_cache_out_onl_entry(const ipv6_addr_t *addr, /* 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; } From 877217663e8a61ff1764525601f79ad590984868 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 12 Feb 2019 12:06:31 +0100 Subject: [PATCH 2/2] gnrc_ipv6_nib: add clarification to comment in cache-out When working on the previous commit I was unsure if a garbage-collectible entry should remain in the list, so I added this comment so I don't have to wonder about this in the future ;-). --- sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 c730fdb825..fe91219139 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c @@ -146,7 +146,8 @@ 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 */