Commit 11344b80 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Protect expiration against clock stepping.

parent b12f084c
...@@ -247,6 +247,7 @@ check_neighbours() ...@@ -247,6 +247,7 @@ check_neighbours()
changed = update_neighbour(&neighs[i], -1, 0); changed = update_neighbour(&neighs[i], -1, 0);
if(neighs[i].reach == 0 || if(neighs[i].reach == 0 ||
neighs[i].hello_time.tv_sec > now.tv_sec || /* clock stepped */
timeval_minus_msec(&now, &neighs[i].hello_time) > 300000) { timeval_minus_msec(&now, &neighs[i].hello_time) > 300000) {
flush_neighbour(&neighs[i]); flush_neighbour(&neighs[i]);
continue; continue;
......
...@@ -636,7 +636,8 @@ expire_routes(void) ...@@ -636,7 +636,8 @@ expire_routes(void)
while(i < numroutes) { while(i < numroutes) {
struct route *route = &routes[i]; struct route *route = &routes[i];
if(route->time < now.tv_sec - route_gc_delay) { if(route->time > now.tv_sec || /* clock stepped */
route->time < now.tv_sec - route_gc_delay) {
flush_route(route); flush_route(route);
continue; continue;
} }
......
...@@ -166,6 +166,9 @@ expire_sources() ...@@ -166,6 +166,9 @@ expire_sources()
for(i = 0; i < numsrcs; i++) { for(i = 0; i < numsrcs; i++) {
if(!srcs[i].valid) if(!srcs[i].valid)
continue; continue;
if(srcs[i].time > now.tv_sec)
/* clock stepped */
srcs[i].time = now.tv_sec;
if(srcs[i].time < now.tv_sec - SOURCE_GC_TIME) if(srcs[i].time < now.tv_sec - SOURCE_GC_TIME)
continue; continue;
rc = flush_source(&srcs[i]); rc = flush_source(&srcs[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment