diff -Nur olsrd-0.5.3.orig/lib/quagga/src/olsrd_plugin.c olsrd-0.5.3/lib/quagga/src/olsrd_plugin.c
--- olsrd-0.5.3.orig/lib/quagga/src/olsrd_plugin.c	2007-09-04 16:04:21.000000000 +0200
+++ olsrd-0.5.3/lib/quagga/src/olsrd_plugin.c	2007-09-04 16:04:21.000000000 +0200
@@ -35,6 +35,22 @@
 static void __attribute__ ((destructor)) my_fini(void);
 static void redist_hna (void);
 
+static olsr_route_function orig_addroute_function;
+static olsr_route_function orig_delroute_function;
+
+int hook_addroute(struct rt_entry *entry)
+{
+	int ret = zebra_add_olsr_v4_route(entry);
+	if (NULL != orig_addroute_function) return orig_addroute_function(entry);
+	return ret;
+}
+
+int hook_delroute(struct rt_entry *entry)
+{
+	int ret = zebra_del_olsr_v4_route(entry);
+	if (NULL != orig_delroute_function) return orig_delroute_function(entry);
+	return ret;
+}
 
 int olsrd_plugin_interface_version() {
   return PLUGIN_INTERFACE_VERSION;
@@ -56,18 +72,18 @@
   }
   else if(!strcmp(key, "ExportRoutes")) {
     if (!strcmp(value, "only")) {
-      if (!olsr_addroute_remove_function(&olsr_ioctl_add_route, AF_INET))
-	puts ("AIII, could not remove the kernel route exporter");
-      if (!olsr_delroute_remove_function(&olsr_ioctl_del_route, AF_INET))
-	puts ("AIII, could not remove the kernel route deleter");
-      olsr_addroute_add_function(&zebra_add_olsr_v4_route, AF_INET);
-      olsr_delroute_add_function(&zebra_del_olsr_v4_route, AF_INET);
+      orig_addroute_function = NULL;
+      orig_delroute_function = NULL;
+      olsr_addroute_function = zebra_add_olsr_v4_route;
+      olsr_delroute_function = zebra_del_olsr_v4_route;
       zebra_export_routes(1);
       return 1;
     }
     else if (!strcmp(value, "additional")) {
-      olsr_addroute_add_function(&zebra_add_olsr_v4_route, AF_INET);
-      olsr_delroute_add_function(&zebra_del_olsr_v4_route, AF_INET);
+      orig_addroute_function = olsr_addroute_function;
+      orig_delroute_function = olsr_delroute_function;
+      olsr_addroute_function = zebra_add_olsr_v4_route;
+      olsr_delroute_function = zebra_del_olsr_v4_route;
       zebra_export_routes(1);
       return 1;
     }
diff -Nur olsrd-0.5.3.orig/src/process_routes.c olsrd-0.5.3/src/process_routes.c
--- olsrd-0.5.3.orig/src/process_routes.c	2007-09-04 16:04:21.000000000 +0200
+++ olsrd-0.5.3/src/process_routes.c	2007-09-04 16:04:21.000000000 +0200
@@ -4,7 +4,7 @@
  * All rights reserved.
  *
  * export_route_entry interface added by Immo 'FaUl Wehrenberg 
- * <immo@chaostreff-dortmund.de>
+ * <immo@chaostreff-dortmund.de> and reworked by sven-ola 2007
  *
  * Redistribution and use in source and binary forms, with or without 
  * modification, are permitted provided that the following conditions 
@@ -53,162 +53,22 @@
 #define strerror(x) StrError(x)
 #endif
 
-struct export_route_entry
-{
-  olsr_u8_t type;       /* AF_INET/AF_INET6 */
-  int (*function)(struct rt_entry*);
-  struct export_route_entry *next;
-};
-
-
-static struct export_route_entry *add_routes;
-static struct export_route_entry *del_routes;
-
-
-struct rt_entry old_routes[HASHSIZE];
-struct rt_entry old_hna[HASHSIZE];
-
-void 
-olsr_addroute_add_function(int (*function)(struct rt_entry*), olsr_u8_t type) 
-{
-  struct export_route_entry *tmp;
-  tmp = olsr_malloc(sizeof *tmp, "olsr_addroute_add_function");
-  tmp->type = type;
-  tmp->function = function;
-  tmp->next = add_routes;
-  add_routes = tmp;
-}
-
-void 
-olsr_delroute_add_function(int (*function) (struct rt_entry*), olsr_u8_t type)
-{
-  struct export_route_entry *tmp;
-  tmp = olsr_malloc(sizeof *tmp, "olsr_delroute_add_function");
-  tmp->type = type;
-  tmp->function = function;
-  tmp->next = del_routes;
-  del_routes = tmp;
-}
-
-
-int 
-olsr_addroute_remove_function(int (*function) (struct rt_entry*), olsr_u8_t type)
-{
-  struct export_route_entry *tmp, *prev = NULL /* Make compiler happy */; 
-  tmp = add_routes;
-  while (tmp) 
-    {
-      if (function == tmp->function && type == tmp->type) 
-	{
-	  if (tmp == add_routes) 
-	    {
-	      add_routes = add_routes->next;
-	      free (tmp);
-	      return 1;
-	    }
-	  else 
-	    {
-	      prev->next = tmp->next;
-	      free (tmp);
-	      return 1;
-	    }
-	}
-      prev = tmp;
-      tmp = tmp->next;
-    }
-  return 0;
-}
-
-int
-olsr_delroute_remove_function(int (*function) (struct rt_entry*), olsr_u8_t type)
-{
-  struct export_route_entry *tmp, *prev = NULL /* Make compiler happy */;
-  tmp = del_routes;
-  while (tmp) 
-    {
-      if (function == tmp->function && type == tmp->type) 
-	{
-	  if (tmp == del_routes) 
-	    {
-	      del_routes = del_routes->next;
-	      free (tmp);
-	      return 1;
-	    }
-	  else 
-	    {
-	      prev->next = tmp->next;
-	      free (tmp);
-	      return 1; 
-	    }
-	}
-      prev = tmp;
-      tmp = tmp->next;
-    }
-  return 0;
-}
+olsr_route_function olsr_addroute_function;
+olsr_route_function olsr_addroute6_function;
+olsr_route_function olsr_delroute_function;
+olsr_route_function olsr_delroute6_function;
 
 void 
 olsr_init_export_route(void)
 {
-  olsr_addroute_add_function(&olsr_ioctl_add_route, AF_INET);
-  olsr_addroute_add_function(&olsr_ioctl_add_route6, AF_INET6);
-  olsr_delroute_add_function(&olsr_ioctl_del_route, AF_INET);
-  olsr_delroute_add_function(&olsr_ioctl_del_route6, AF_INET6);
-}
-
-int
-olsr_export_add_route (struct rt_entry *e) 
-{
-  int retval = 0;
-  struct export_route_entry *tmp;
-  for (tmp = add_routes; tmp; tmp = tmp->next)
-    {
-      if (tmp->type == AF_INET)
-	retval = tmp->function(e);
-    }
-  return retval;
-}
-
-int
-olsr_export_add_route6 (struct rt_entry *e) 
-{
-  int retval = 0;
-  struct export_route_entry *tmp;
-  for (tmp = add_routes; tmp; tmp = tmp->next)
-    {
-      if (tmp->type == AF_INET6)
-	retval = tmp->function(e);
-    }
-  return retval;
-}
-
-int
-olsr_export_del_route (struct rt_entry *e) 
-{
-  int retval = 0;
-  struct export_route_entry *tmp;
-  for (tmp = del_routes; tmp; tmp = tmp->next)
-    {
-      if (tmp->type == AF_INET)
-	retval = tmp->function(e);
-    }
-  return retval;
-}
-
-int
-olsr_export_del_route6 (struct rt_entry *e) 
-{
-  int retval = 0;
-  struct export_route_entry *tmp;
-  for (tmp = del_routes; tmp; tmp = tmp->next)
-    {
-      if (tmp->type == AF_INET6)
-	retval = tmp->function(e);
-    }
-  return retval;
+	olsr_addroute_function = olsr_ioctl_add_route;
+	olsr_addroute6_function = olsr_ioctl_add_route6;
+	olsr_delroute_function = olsr_ioctl_del_route;
+	olsr_delroute6_function = olsr_ioctl_del_route6;
 }
 
-
+struct rt_entry old_routes[HASHSIZE];
+struct rt_entry old_hna[HASHSIZE];
 
 int
 olsr_init_old_table(void)
@@ -484,12 +344,9 @@
 #endif
 		    if(!olsr_cnf->host_emul)
 		      {
-			if(olsr_cnf->ip_version == AF_INET)
-			  error = olsr_export_del_route(destination_ptr->destination);
-			else
-			  error = olsr_export_del_route6(destination_ptr->destination);
-			
-			if(error < 0)
+			if(0 > (error = (olsr_cnf->ip_version == AF_INET ?
+				olsr_delroute_function(destination_ptr->destination) :
+				olsr_delroute6_function(destination_ptr->destination))))
 			  {
                             const char * const err_msg = strerror(errno);
 			    OLSR_PRINTF(1, "Delete route(%s):%s\n", olsr_ip_to_string(&destination_ptr->destination->rt_dst), err_msg);
@@ -571,12 +428,9 @@
 			  
 		if(!olsr_cnf->host_emul)
 		  {
-		    if(olsr_cnf->ip_version == AF_INET)
-		      error=olsr_export_add_route(destination_kernel->destination);
-		    else
-		      error=olsr_export_add_route6(destination_kernel->destination);
-		    
-		    if(error < 0)
+		    if(0 > (error = (olsr_cnf->ip_version == AF_INET ?
+			olsr_addroute_function(destination_kernel->destination) :
+			olsr_addroute6_function(destination_kernel->destination))))
 		      {
                         const char * const err_msg = strerror(errno);
 			OLSR_PRINTF(1, "Add route(%s): %s\n", olsr_ip_to_string(&destination_kernel->destination->rt_dst), err_msg);
diff -Nur olsrd-0.5.3.orig/src/process_routes.h olsrd-0.5.3/src/process_routes.h
--- olsrd-0.5.3.orig/src/process_routes.h	2007-01-31 13:36:50.000000000 +0100
+++ olsrd-0.5.3/src/process_routes.h	2007-09-04 16:04:21.000000000 +0200
@@ -50,33 +50,15 @@
 extern struct rt_entry old_routes[HASHSIZE];
 extern struct rt_entry old_hna[HASHSIZE];
 
-void
-olsr_init_export_route(void);
+typedef int (*olsr_route_function)(struct rt_entry*);
 
-void
-olsr_addroute_add_function(int (*)(struct rt_entry*), olsr_u8_t);
-
-int
-olsr_addroute_remove_function(int (*)(struct rt_entry*), olsr_u8_t);
+extern olsr_route_function olsr_addroute_function;
+extern olsr_route_function olsr_addroute6_function;
+extern olsr_route_function olsr_delroute_function;
+extern olsr_route_function olsr_delroute6_function;
 
 void
-olsr_delroute_add_function(int (*)(struct rt_entry*), olsr_u8_t);
-
-int
-olsr_delroute_remove_function(int (*)(struct rt_entry*), olsr_u8_t);
-
-int
-olsr_export_add_route (struct rt_entry*); 
-
-int
-olsr_export_del_route (struct rt_entry*); 
-
-int
-olsr_export_add_route6 (struct rt_entry*); 
-
-int
-olsr_export_del_route6 (struct rt_entry*); 
-
+olsr_init_export_route(void);
 
 int
 olsr_init_old_table(void);
