mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-21 19:29:18 +00:00
Fix a route lifetime bug
There is a bug in the current route purge routine which would result in a route's lifetime getting decremented more than once during the same pass. This commit fixes it The bug is documented here: http://thread.gmane.org/gmane.os.contiki.devel/16209
This commit is contained in:
parent
b8f79b9da3
commit
68f59113d6
@ -62,14 +62,31 @@ rpl_purge_routes(void)
|
||||
{
|
||||
uip_ds6_route_t *r;
|
||||
|
||||
/* First pass, decrement lifetime */
|
||||
r = uip_ds6_route_list_head();
|
||||
|
||||
while(r != NULL) {
|
||||
if(r->state.lifetime <= 1) {
|
||||
if(r->state.lifetime >= 1) {
|
||||
/*
|
||||
* If a route is at lifetime == 1, set it to 0, scheduling it for
|
||||
* immediate removal below. This achieves the same as the original code,
|
||||
* which would delete lifetime <= 1
|
||||
*/
|
||||
r->state.lifetime--;
|
||||
}
|
||||
r = list_item_next(r);
|
||||
}
|
||||
|
||||
/* Second pass, remove dead routes */
|
||||
r = uip_ds6_route_list_head();
|
||||
|
||||
while(r != NULL) {
|
||||
if(r->state.lifetime < 1) {
|
||||
/* Routes with lifetime == 1 have only just been decremented from 2 to 1,
|
||||
* thus we want to keep them. Hence < and not <= */
|
||||
uip_ds6_route_rm(r);
|
||||
r = uip_ds6_route_list_head();
|
||||
} else {
|
||||
r->state.lifetime--;
|
||||
r = list_item_next(r);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user