[Olsr-dev] [PATCH v1 3/5] sgw: immediately remove sgw HNAs with zero bandwidth

Ferry Huberts (spam-protected)
Fri May 8 10:12:39 CEST 2015


From: Ferry Huberts <(spam-protected)>

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 src/gateway.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/gateway.c b/src/gateway.c
index 0e67876..82c9095 100644
--- a/src/gateway.c
+++ b/src/gateway.c
@@ -1094,14 +1094,14 @@ void olsr_update_gateway_entry(union olsr_ip_addr *originator, union olsr_ip_add
 
   /* keep new HNA seqno */
   gw->seqno = seqno;
+  gw->uplink = 0;
+  gw->downlink = 0;
+  gw->path_cost = INT64_MAX;
 
   ptr = hna_mask_to_hna_pointer(mask, prefixlen);
   if ((ptr[GW_HNA_FLAGS] & GW_HNA_FLAG_LINKSPEED) != 0) {
     gw->uplink = deserialize_gw_speed(ptr[GW_HNA_UPLINK]);
     gw->downlink = deserialize_gw_speed(ptr[GW_HNA_DOWNLINK]);
-  } else {
-    gw->uplink = 0;
-    gw->downlink = 0;
   }
 
   gw->ipv4 = (ptr[GW_HNA_FLAGS] & GW_HNA_FLAG_IPV4) != 0;
@@ -1124,6 +1124,11 @@ void olsr_update_gateway_entry(union olsr_ip_addr *originator, union olsr_ip_add
     }
   }
 
+  if (!gw->uplink || !gw->downlink) {
+    olsr_delete_gateway_tree_entry(gw, FORCE_DELETE_GW_ENTRY, true);
+    return;
+  }
+
   /* stop cleanup timer if necessary */
   if (gw->cleanup_timer) {
     olsr_stop_timer(gw->cleanup_timer);
-- 
2.1.0





More information about the Olsr-dev mailing list