gateway: setup and clear table specific default routes in/for multi-gateway mode
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 4 Dec 2012 12:22:56 +0000 (13:22 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 13 Dec 2012 12:23:43 +0000 (13:23 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Reviewed-by: Henning Rogge <hrogge@googlemail.com>
src/gateway.c

index 566c70b..9b20481 100644 (file)
@@ -648,6 +648,10 @@ static void olsr_delete_gateway_tree_entry(struct gateway_entry * gw, uint8_t pr
         }
 
         if (gw_in_list->tunnel) {
+          struct interfaceName * ifn = find_interfaceName(gw_in_list->gw);
+          if (ifn) {
+            olsr_os_inetgw_tunnel_route(gw_in_list->tunnel->if_index, true, false, &ifn->mark);
+          }
           olsr_os_del_ipip_tunnel(gw_in_list->tunnel);
           set_unused_iptunnel_name(gw_in_list->gw);
           gw_in_list->tunnel = NULL;
@@ -666,6 +670,10 @@ static void olsr_delete_gateway_tree_entry(struct gateway_entry * gw, uint8_t pr
         }
 
         if (gw_in_list->tunnel) {
+          struct interfaceName * ifn = find_interfaceName(gw_in_list->gw);
+          if (ifn) {
+            olsr_os_inetgw_tunnel_route(gw_in_list->tunnel->if_index, false, false, &ifn->mark);
+          }
           olsr_os_del_ipip_tunnel(gw_in_list->tunnel);
           set_unused_iptunnel_name(gw_in_list->gw);
           gw_in_list->tunnel = NULL;
@@ -769,6 +777,10 @@ bool olsr_set_inet_gateway(union olsr_ip_addr *originator, uint64_t path_cost, b
         assert(worst);
 
         if (worst->tunnel) {
+          struct interfaceName * ifn = find_interfaceName(worst->gw);
+          if (ifn) {
+            olsr_os_inetgw_tunnel_route(worst->tunnel->if_index, true, false, &ifn->mark);
+          }
           olsr_os_del_ipip_tunnel(worst->tunnel);
           set_unused_iptunnel_name(worst->gw);
           worst->tunnel = NULL;
@@ -780,6 +792,9 @@ bool olsr_set_inet_gateway(union olsr_ip_addr *originator, uint64_t path_cost, b
       get_unused_iptunnel_name(new_gw, name, &interfaceName);
       new_v4gw_tunnel = olsr_os_add_ipip_tunnel(&new_gw->originator, true, name);
       if (new_v4gw_tunnel) {
+        if (interfaceName) {
+          olsr_os_inetgw_tunnel_route(new_v4gw_tunnel->if_index, true, true, &interfaceName->mark);
+        }
         olsr_os_inetgw_tunnel_route(new_v4gw_tunnel->if_index, true, true, NULL);
 
         new_gw_in_list = olsr_cookie_malloc(gw_container_entry_mem_cookie);
@@ -817,6 +832,10 @@ bool olsr_set_inet_gateway(union olsr_ip_addr *originator, uint64_t path_cost, b
         assert(worst);
 
         if (worst->tunnel) {
+          struct interfaceName * ifn = find_interfaceName(worst->gw);
+          if (ifn) {
+            olsr_os_inetgw_tunnel_route(worst->tunnel->if_index, false, false, &ifn->mark);
+          }
           olsr_os_del_ipip_tunnel(worst->tunnel);
           set_unused_iptunnel_name(worst->gw);
           worst->tunnel = NULL;
@@ -828,6 +847,9 @@ bool olsr_set_inet_gateway(union olsr_ip_addr *originator, uint64_t path_cost, b
       get_unused_iptunnel_name(new_gw, name, &interfaceName);
       new_v6gw_tunnel = olsr_os_add_ipip_tunnel(&new_gw->originator, false, name);
       if (new_v6gw_tunnel) {
+        if (interfaceName) {
+          olsr_os_inetgw_tunnel_route(new_v6gw_tunnel->if_index, false, true, &interfaceName->mark);
+        }
         olsr_os_inetgw_tunnel_route(new_v6gw_tunnel->if_index, false, true, NULL);
 
         new_gw_in_list = olsr_cookie_malloc(gw_container_entry_mem_cookie);