sgw: safer checking against LINK_COST_BROKEN and ROUTE_COST_BROKEN
authorFerry Huberts <ferry.huberts@pelagic.nl>
Sat, 9 Apr 2016 21:37:35 +0000 (23:37 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 11 Apr 2016 10:38:29 +0000 (12:38 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
src/gateway.c
src/gateway_default_handler.c

index 506c84e..92295bb 100644 (file)
@@ -1398,11 +1398,11 @@ void olsr_trigger_gatewayloss_check(void) {
 
   if (current_ipv4_gw && current_ipv4_gw->gw) {
     struct tc_entry *tc = olsr_lookup_tc_entry(&current_ipv4_gw->gw->originator);
-    ipv4 = (tc == NULL || tc->path_cost == ROUTE_COST_BROKEN);
+    ipv4 = (tc == NULL || tc->path_cost >= ROUTE_COST_BROKEN);
   }
   if (current_ipv6_gw && current_ipv6_gw->gw) {
     struct tc_entry *tc = olsr_lookup_tc_entry(&current_ipv6_gw->gw->originator);
-    ipv6 = (tc == NULL || tc->path_cost == ROUTE_COST_BROKEN);
+    ipv6 = (tc == NULL || tc->path_cost >= ROUTE_COST_BROKEN);
   }
 
   if (ipv4 || ipv6) {
index b07075f..6599ec6 100644 (file)
@@ -250,7 +250,7 @@ static int64_t gw_default_getcosts(struct gateway_entry *gw) {
 
   tc = olsr_lookup_tc_entry(&gw->originator);
 
-  if (!tc || (tc->path_cost == ROUTE_COST_BROKEN) || (!gw->uplink || !gw->downlink)) {
+  if (!tc || (tc->path_cost >= ROUTE_COST_BROKEN) || (!gw->uplink || !gw->downlink)) {
     /* gateways should not exist without tc entry */
     /* do not consider nodes with an infinite ETX */
     /* do not consider nodes without bandwidth or with a uni-directional link */