Trigger gateway reselection when ETX becomes infinite
authorHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 24 Feb 2010 11:56:53 +0000 (12:56 +0100)
committerHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 24 Feb 2010 11:56:53 +0000 (12:56 +0100)
src/gateway.c
src/gateway.h
src/gateway_default_handler.c
src/olsr_spf.c

index 2132845..410b560 100644 (file)
@@ -153,6 +153,29 @@ olsr_trigger_inetgw_selection(bool ipv4, bool ipv6) {
   return ((ipv4 && current_ipv4_gw == NULL) || (ipv6 && current_ipv6_gw == NULL)) ? -1 : 0;
 }
 
+/**
+ * Triggers a check if the one of the gateways have been lost
+ * through ETX = infinity
+ */
+void olsr_trigger_gatewayloss_check(void) {
+  struct tc_entry *tc;
+  bool ipv4 = false, ipv6 = false;
+  if (current_ipv4_gw) {
+    tc = olsr_lookup_tc_entry(&current_ipv4_gw->originator);
+    if (tc == NULL || tc->path_cost == ROUTE_COST_BROKEN) {
+      ipv4 = true;
+    }
+  }
+  if (current_ipv6_gw) {
+    tc = olsr_lookup_tc_entry(&current_ipv6_gw->originator);
+    if (tc == NULL || tc->path_cost == ROUTE_COST_BROKEN) {
+      ipv6 = true;
+    }
+  }
+  if (ipv4 || ipv6) {
+    olsr_trigger_inetgw_selection(ipv4, ipv6);
+  }
+}
 /**
  * Set a new gateway handler. Do only call this once during startup from
  * a plugin to overwrite the default handler.
index 8724c78..9f554f1 100644 (file)
@@ -69,6 +69,7 @@ int olsr_init_gateways(void);
 void olsr_cleanup_gateways(void);
 void olsr_trigger_inetgw_startup(void);
 int olsr_trigger_inetgw_selection(bool ipv4, bool ipv6);
+void olsr_trigger_gatewayloss_check(void);
 
 struct gateway_entry *olsr_find_gateway_entry(union olsr_ip_addr *originator);
 void olsr_update_gateway_entry(union olsr_ip_addr *originator, union olsr_ip_addr *mask, int prefixlen, uint16_t seqno);
index cbb47da..d484d73 100644 (file)
@@ -11,6 +11,7 @@
 #include "scheduler.h"
 #include "tc_set.h"
 #include "log.h"
+#include "lq_plugin.h"
 
 #include "assert.h"
 
@@ -43,8 +44,8 @@ static void gw_default_choose_gateway(void) {
   struct gateway_entry *gw;
   bool dual;
 
-  cost_ipv4 = UINT32_MAX;
-  cost_ipv6 = UINT32_MAX;
+  cost_ipv4 = ROUTE_COST_BROKEN;
+  cost_ipv6 = ROUTE_COST_BROKEN;
 
   inet_ipv4 = NULL;
   inet_ipv6 = NULL;
index 760c62b..1836455 100644 (file)
@@ -66,6 +66,7 @@
 #include "olsr_spf.h"
 #include "net_olsr.h"
 #include "lq_plugin.h"
+#include "gateway.h"
 
 struct timer_entry *spf_backoff_timer = NULL;
 
@@ -484,6 +485,9 @@ olsr_calculate_routing_table(void)
     }
   }
 
+  /* check gateway tunnels */
+  olsr_trigger_gatewayloss_check();
+
   /* Update the RIB based on the new SPF results */
 
   olsr_update_rib_routes();