[Olsr-dev] [PATCH] [resent] quagga plugin routes additional

equinox (spam-protected)
Fri Feb 15 21:52:22 CET 2013


This patch fixes the quagga plugin ExportRoutes parameter. When this
argument is set to 'additional' the plugin wouldn't call the orignial
addroute/delroute functions. Now the original functions get called after
a successful call to the quagga addroute/delroute functions.
I also updated the docomentation which know uses the right keyword (both
vs. additional)

Signed-off-by: Christian Pointner <(spam-protected)>

---

diff --git a/lib/quagga/README_QUAGGA b/lib/quagga/README_QUAGGA
index 32bbfc8..85fa050 100644
--- a/lib/quagga/README_QUAGGA
+++ b/lib/quagga/README_QUAGGA
@@ -26,8 +26,8 @@ PlParam "Redistribute" "<protocol>"
 	isis, bgp, hsls
 	May be used more then once
 
-PlParam "ExportRoutes" "<only/both>"
-	exports olsr-routes to quagga or to both, quagga and kernel
+PlParam "ExportRoutes" "<only/additional>"
+	exports olsr-routes to quagga only, or to quagga and kernel
 	no routes are exported to quagga (normal behaviour) if not set.
 
 PlParam "LocalPref" "<true/false>"
diff --git a/lib/quagga/src/common.h b/lib/quagga/src/common.h
index b6a1a76..7696410 100644
--- a/lib/quagga/src/common.h
+++ b/lib/quagga/src/common.h
@@ -18,11 +18,14 @@
  * ------------------------------------------------------------------------- */
 
 #define OPTION_EXPORT 1
+#define OPTION_ROUTE_ADDITIONAL 2
 
 /* Zebra route types */
 #define ZEBRA_ROUTE_OLSR		11
 #define ZEBRA_ROUTE_MAX			14
 
+#include "process_routes.h"
+
 struct zebra {
   unsigned char status;
   unsigned char options;
@@ -33,6 +36,10 @@ struct zebra {
   char *sockpath;
   unsigned int port;
   unsigned char version;
+  export_route_function orig_addroute_function;
+  export_route_function orig_addroute6_function;
+  export_route_function orig_delroute_function;
+  export_route_function orig_delroute6_function;
 };
 
 extern struct zebra zebra;
diff --git a/lib/quagga/src/plugin.c b/lib/quagga/src/plugin.c
index c7784c9..1c72c76 100644
--- a/lib/quagga/src/plugin.c
+++ b/lib/quagga/src/plugin.c
@@ -65,7 +65,6 @@ zplugin_redistribute(const char *value, void *data __attribute__ ((unused)), set
 int
 zplugin_exportroutes(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused)))
 {
-
   if (!strcmp(value, "only")) {
     olsr_addroute_function = zebra_addroute;
     olsr_delroute_function = zebra_delroute;
@@ -73,11 +72,15 @@ zplugin_exportroutes(const char *value, void *data __attribute__ ((unused)), set
     olsr_delroute6_function = zebra_delroute;
     zebra.options |= OPTION_EXPORT;
   } else if (!strcmp(value, "additional")) {
+    zebra.orig_addroute_function = olsr_addroute_function;
+    zebra.orig_delroute_function = olsr_delroute_function;
+    zebra.orig_addroute6_function = olsr_addroute6_function;
+    zebra.orig_delroute6_function = olsr_delroute6_function;
     olsr_addroute_function = zebra_addroute;
     olsr_delroute_function = zebra_delroute;
     olsr_addroute6_function = zebra_addroute;
     olsr_delroute6_function = zebra_delroute;
-    zebra.options |= OPTION_EXPORT;
+    zebra.options |= OPTION_EXPORT | OPTION_ROUTE_ADDITIONAL;
   }
 
   return 0;
diff --git a/lib/quagga/src/quagga.c b/lib/quagga/src/quagga.c
index 394581c..87786f1 100644
--- a/lib/quagga/src/quagga.c
+++ b/lib/quagga/src/quagga.c
@@ -99,6 +99,8 @@ zebra_addroute(const struct rt_entry *r)
   }
 
   retval = zclient_write(zpacket_route(olsr_cnf->ip_version == AF_INET ? ZEBRA_IPV4_ROUTE_ADD : ZEBRA_IPV6_ROUTE_ADD, &route));
+  if(!retval && zebra.options & OPTION_ROUTE_ADDITIONAL)
+    retval = olsr_cnf->ip_version == AF_INET ? zebra.orig_addroute_function(r) : zebra.orig_addroute6_function(r);
 
   return retval;
 }
@@ -149,6 +151,8 @@ zebra_delroute(const struct rt_entry *r)
   }
 
   retval = zclient_write(zpacket_route(olsr_cnf->ip_version == AF_INET ? ZEBRA_IPV4_ROUTE_DELETE : ZEBRA_IPV6_ROUTE_DELETE, &route));
+  if(!retval && zebra.options & OPTION_ROUTE_ADDITIONAL)
+    retval = olsr_cnf->ip_version == AF_INET ? zebra.orig_delroute_function(r) : zebra.orig_delroute6_function(r);
 
   return retval;
 }




More information about the Olsr-dev mailing list