gateway: ensure cleanup uses the reverse order of init
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 18 Oct 2012 09:40:12 +0000 (11:40 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 24 Oct 2012 12:17:49 +0000 (14:17 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
src/gateway.c

index 10e1b9f..d8c2fb2 100644 (file)
@@ -181,6 +181,10 @@ int olsr_init_gateways(void) {
  * Cleanup gateway tunnel system
  */
 void olsr_cleanup_gateways(void) {
+  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);
   }
@@ -188,14 +192,10 @@ void olsr_cleanup_gateways(void) {
     olsr_os_del_ipip_tunnel(v6gw_tunnel);
   }
 
-  olsr_remove_ifchange_handler(smartgw_tunnel_monitor);
-
   assert(gw_handler);
   gw_handler->cleanup();
   gw_handler = NULL;
 
-  olsr_os_cleanup_iptunnel(olsr_cnf->ip_version == AF_INET ? TUNNEL_ENDPOINT_IF : TUNNEL_ENDPOINT_IF6);
-
   olsr_free_cookie(gw_mem_cookie);
 }