[Olsr-users] PATCH: 0.5.6 (and probably others) make dyn gw "interval" plugin parameter work

Eric Malkowski (spam-protected)
Tue Sep 2 02:37:12 CEST 2008


The default interval for pings for the dyn_gw plugin is 5 seconds set by 
static variable.
My first try to use this (and my first try w/ OLSR in fact!) setting 
interval to 30 seconds yielded continuous pings.

I tracked it down to the fact that the plugin_parameter array in 
olsrd_dyn_gw.c was using it's own set_plugin_double handler when the 
check_interval parameter is actually an int.  When the int passed in is 
converted w/ set_plugin_double (at least on my setup that is compiled 
against uclibc 0.9.29) to set the check_interval integer parameter, the 
conversion must be coming out as 0 or negative. 

The following patch fixes this.  Even if this isn't a problem on a glibc 
setup, the integer plugin parameter handler should be used for dyn gw's 
"interval" as it's more correct since it's the number of whole seconds 
between pings, not a floating point number (the nanosleep used to 
implement it wants a struct timespec and the number of seconds is 
integer and nanoseconds is set to 0L in the code).

Also -- if the set_plugin_double helper function which I believe is code 
that is local to the dyn gw plugin becomes dead code w/ the patch below, 
it can be removed.

With the patch applied I can leave the default and get 5 seconds ping 
interval or set it to 10 seconds and see a 10 second interval instead of 
continuous pings.

The ping approach is a technique I've implemented with scripts in the 
past for injecting or removing default routes from OSPF setups using 
zebra/quagga.  The only thing I did different that might by nice in the 
dyn gw plugin would be to round-robin through the list of "peers" that 
get pinged so the first guy on the list doesn't take all the ICMP 
traffic most of the time -- round robin for both cases of internet link 
considered down and internet link considered up.

diff -urNp olsrd-0.5.6-orig/lib/dyn_gw/src/olsrd_dyn_gw.c 
olsrd-0.5.6-dyn-gw-patch/lib/dyn_gw/src/olsrd_dyn_gw.c
--- olsrd-0.5.6-orig/lib/dyn_gw/src/olsrd_dyn_gw.c    2008-09-01 
20:11:10.000000000 -0400
+++ olsrd-0.5.6-dyn-gw-patch/lib/dyn_gw/src/olsrd_dyn_gw.c    2008-09-01 
20:11:55.000000000 -0400
@@ -206,7 +206,7 @@ static int set_plugin_hna(const char *va
 }
 
 static const struct olsrd_plugin_parameters plugin_parameters[] = {
-    { .name = "interval", .set_plugin_parameter = &set_plugin_double, 
.data = &check_interval },
+    { .name = "interval", .set_plugin_parameter = &set_plugin_int, 
.data = &check_interval },
     { .name = "ping",     .set_plugin_parameter = &set_plugin_ping,   
.data = NULL },
     { .name = "hna",      .set_plugin_parameter = &set_plugin_hna,    
.data = NULL },
 };
diff -urNp olsrd-0.5.6-orig/lib/dyn_gw/src/olsrd_dyn_gw.h 
olsrd-0.5.6-dyn-gw-patch/lib/dyn_gw/src/olsrd_dyn_gw.h
--- olsrd-0.5.6-orig/lib/dyn_gw/src/olsrd_dyn_gw.h    2008-09-01 
20:11:16.000000000 -0400
+++ olsrd-0.5.6-dyn-gw-patch/lib/dyn_gw/src/olsrd_dyn_gw.h    2008-09-01 
20:12:07.000000000 -0400
@@ -43,6 +43,7 @@
 #define _OLSRD_PLUGIN_TEST
 
 #include "olsrd_plugin.h"
+#include "plugin_util.h"
 
 #define INET_NET       0
 #define INET_PREFIX    0





More information about the Olsr-users mailing list