Skip to content

Commit 68adb36

Browse files
author
Juha Heiskanen
committed
Neighbor cache update
Remove now only gargabe collected neighbours. Change-Id: I013571fb024f1baca1cec6f3edbe91b7a4142666
1 parent 8cdd961 commit 68adb36

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

source/ipv6_stack/ipv6_routing_table.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,15 @@ ipv6_neighbour_t *ipv6_neighbour_lookup_or_create(ipv6_neighbour_cache_t *cache,
303303
{
304304
uint_fast16_t count = 0;
305305
ipv6_neighbour_t *entry = NULL;
306+
ipv6_neighbour_t *garbage_possible_entry = NULL;
306307

307308
ns_list_foreach(ipv6_neighbour_t, cur, &cache->list) {
308-
count++;
309+
310+
if (cur->type == IP_NEIGHBOUR_GARBAGE_COLLECTIBLE) {
311+
garbage_possible_entry = cur;
312+
count++;
313+
}
314+
309315
if (addr_ipv6_equal(cur->ip_address, address)) {
310316
if (cur != ns_list_get_first(&cache->list)) {
311317
ns_list_remove(&cache->list, cur);
@@ -315,9 +321,9 @@ ipv6_neighbour_t *ipv6_neighbour_lookup_or_create(ipv6_neighbour_cache_t *cache,
315321
}
316322
}
317323

318-
if (count >= neighbour_cache_config.max_entries) {
319-
entry = ns_list_get_last(&cache->list);
320-
ipv6_neighbour_entry_remove(cache, entry);
324+
if (count >= neighbour_cache_config.max_entries && garbage_possible_entry) {
325+
//Remove Last storaged IP_NEIGHBOUR_GARBAGE_COLLECTIBLE type entry
326+
ipv6_neighbour_entry_remove(cache, garbage_possible_entry);
321327
}
322328

323329
// Allocate new - note we have a basic size, plus enough for the LL address,

0 commit comments

Comments
 (0)