Fix a small bug in etx-ff that might trigger if hello validity interval is longer...
authorHenning Rogge <hrogge@googlemail.com>
Sat, 21 Nov 2009 09:44:38 +0000 (10:44 +0100)
committerHenning Rogge <hrogge@googlemail.com>
Sat, 21 Nov 2009 09:44:38 +0000 (10:44 +0100)
src/lq_plugin_default_ff.c

index 73a9fb8..4db0d8a 100644 (file)
@@ -244,13 +244,12 @@ default_lq_ff_timer(void __attribute__ ((unused)) * context)
 
       /* keep missed hello periods in mind (round up hello interval to seconds) */
       if (tlq->missed_hellos > 1) {
-        int penalty = received * tlq->missed_hellos * link->inter->hello_etime/1000 / LQ_FF_WINDOW;
-
-        if (penalty < 0) {
+        int factor = tlq->missed_hellos * link->inter->hello_etime/1000;
+        if (factor >= LQ_FF_WINDOW) {
           received = 0;
         }
         else {
-          received -= penalty;
+          received = received - received * factor / LQ_FF_WINDOW;
         }
       }