gateway: walk the gateway tree to properly cleanup
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 18 Oct 2012 09:44:27 +0000 (11:44 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 24 Oct 2012 12:17:49 +0000 (14:17 +0200)
No need to explicitly remove the tunnels, since these are
removed by the olsr_delete_gateway_entry function.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
src/gateway.c

index 993122a..cd9ee33 100644 (file)
@@ -187,15 +187,14 @@ int olsr_init_gateways(void) {
  * Cleanup gateway tunnel system
  */
 void olsr_cleanup_gateways(void) {
+  struct avl_node * avlnode = NULL;
+
   olsr_remove_ifchange_handler(smartgw_tunnel_monitor);
 
   olsr_os_cleanup_iptunnel(olsr_cnf->ip_version == AF_INET ? TUNNEL_ENDPOINT_IF : TUNNEL_ENDPOINT_IF6);
 
-  if (current_ipv4_gw) {
-    olsr_os_del_ipip_tunnel(v4gw_tunnel);
-  }
-  if (current_ipv6_gw) {
-    olsr_os_del_ipip_tunnel(v6gw_tunnel);
+  while ((avlnode = avl_walk_first(&gateway_tree))) {
+    olsr_delete_gateway_tree_entry(node2gateway(avlnode), FORCE_DELETE_GW_ENTRY, true);
   }
 
   assert(gw_handler);