kernel_route: olsr_os_inetgw_tunnel_route can now take the table
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 27 Nov 2012 12:33:31 +0000 (13:33 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 13 Dec 2012 12:22:50 +0000 (13:22 +0100)
as an optional parameter.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Reviewed-by: Henning Rogge <hrogge@googlemail.com>
src/bsd/dummy.c
src/gateway.c
src/kernel_routes.h
src/linux/kernel_routes_nl.c
src/win32/dummy.c

index 114d19b..e619362 100644 (file)
@@ -49,7 +49,8 @@ void olsr_os_niit_6to4_route(const struct olsr_ip_prefix *dst_v6 __attribute__ (
 }
 void olsr_os_inetgw_tunnel_route(uint32_t if_idx __attribute__ ((unused)),
     bool ipv4 __attribute__ ((unused)),
-    bool set __attribute__ ((unused))) {
+    bool set __attribute__ ((unused)),
+    uint8_t * table __attribute__ ((unused))) {
 }
 
 int olsr_os_policy_rule(int family __attribute__ ((unused)),
index 67eefb9..cf099df 100644 (file)
@@ -498,7 +498,7 @@ static void olsr_delete_gateway_tree_entry(struct gateway_entry * gw, uint8_t pr
       gw_in_list = olsr_gw_list_find(&gw_list_ipv4, gw);
       if (gw_in_list) {
         if (current_ipv4_gw && current_ipv4_gw->gw == gw) {
-          olsr_os_inetgw_tunnel_route(current_ipv4_gw->tunnel->if_index, true, false);
+          olsr_os_inetgw_tunnel_route(current_ipv4_gw->tunnel->if_index, true, false, NULL);
           current_ipv4_gw = NULL;
         }
 
@@ -515,7 +515,7 @@ static void olsr_delete_gateway_tree_entry(struct gateway_entry * gw, uint8_t pr
       gw_in_list = olsr_gw_list_find(&gw_list_ipv6, gw);
       if (gw_in_list) {
         if (current_ipv6_gw && current_ipv6_gw->gw == gw) {
-          olsr_os_inetgw_tunnel_route(current_ipv6_gw->tunnel->if_index, false, false);
+          olsr_os_inetgw_tunnel_route(current_ipv6_gw->tunnel->if_index, false, false, NULL);
           current_ipv6_gw = NULL;
         }
 
@@ -608,13 +608,13 @@ bool olsr_set_inet_gateway(union olsr_ip_addr *originator, uint64_t path_cost, b
     if (new_gw_in_list) {
       /* new gw is already in the gw list */
       assert(new_gw_in_list->tunnel);
-      olsr_os_inetgw_tunnel_route(new_gw_in_list->tunnel->if_index, true, true);
+      olsr_os_inetgw_tunnel_route(new_gw_in_list->tunnel->if_index, true, true, NULL);
       current_ipv4_gw = olsr_gw_list_update(&gw_list_ipv4, new_gw_in_list, path_cost);
     } else {
       /* new gw is not yet in the gw list */
       struct olsr_iptunnel_entry *new_v4gw_tunnel = olsr_os_add_ipip_tunnel(&new_gw->originator, true);
       if (new_v4gw_tunnel) {
-        olsr_os_inetgw_tunnel_route(new_v4gw_tunnel->if_index, true, true);
+        olsr_os_inetgw_tunnel_route(new_v4gw_tunnel->if_index, true, true, NULL);
 
         if (olsr_gw_list_full(&gw_list_ipv4)) {
           /* the list is full: remove the worst active gateway */
@@ -649,13 +649,13 @@ bool olsr_set_inet_gateway(union olsr_ip_addr *originator, uint64_t path_cost, b
     if (new_gw_in_list) {
       /* new gw is already in the gw list */
       assert(new_gw_in_list->tunnel);
-      olsr_os_inetgw_tunnel_route(new_gw_in_list->tunnel->if_index, true, true);
+      olsr_os_inetgw_tunnel_route(new_gw_in_list->tunnel->if_index, true, true, NULL);
       current_ipv6_gw = olsr_gw_list_update(&gw_list_ipv6, new_gw_in_list, path_cost);
     } else {
       /* new gw is not yet in the gw list */
          struct olsr_iptunnel_entry *new_v6gw_tunnel = olsr_os_add_ipip_tunnel(&new_gw->originator, false);
       if (new_v6gw_tunnel) {
-        olsr_os_inetgw_tunnel_route(new_v6gw_tunnel->if_index, false, true);
+        olsr_os_inetgw_tunnel_route(new_v6gw_tunnel->if_index, false, true, NULL);
 
         if (olsr_gw_list_full(&gw_list_ipv6)) {
           /* the list is full: remove the worst active gateway */
index bb4caae..c9bf9ae 100644 (file)
@@ -59,7 +59,7 @@ int rtnetlink_register_socket(int);
 
 void olsr_os_niit_4to6_route(const struct olsr_ip_prefix *dst_v4, bool set);
 void olsr_os_niit_6to4_route(const struct olsr_ip_prefix *dst_v6, bool set);
-void olsr_os_inetgw_tunnel_route(uint32_t if_idx, bool ipv4, bool set);
+void olsr_os_inetgw_tunnel_route(uint32_t if_idx, bool ipv4, bool set, uint8_t * table);
 
 int olsr_os_policy_rule(int family, int rttable, uint32_t priority, const char *if_name, bool set);
 int olsr_os_localhost_if(union olsr_ip_addr *ip, bool create);
index aac38a9..c8abaf0 100644 (file)
@@ -466,14 +466,14 @@ void olsr_os_niit_4to6_route(const struct olsr_ip_prefix *dst_v4, bool set) {
   }
 }
 
-void olsr_os_inetgw_tunnel_route(uint32_t if_idx, bool ipv4, bool set) {
+void olsr_os_inetgw_tunnel_route(uint32_t if_idx, bool ipv4, bool set, uint8_t * table) {
   const struct olsr_ip_prefix *dst;
 
   assert(olsr_cnf->ip_version == AF_INET6 || ipv4);
 
   dst = ipv4 ? &ipv4_internet_route : &ipv6_internet_route;
 
-  if (olsr_new_netlink_route(ipv4 ? AF_INET : AF_INET6, olsr_cnf->rt_table_tunnel,
+  if (olsr_new_netlink_route(ipv4 ? AF_INET : AF_INET6, table ? *table : olsr_cnf->rt_table_tunnel,
       if_idx, RT_METRIC_DEFAULT, olsr_cnf->rt_proto, NULL, NULL, dst, set, false)) {
     olsr_syslog(OLSR_LOG_ERR, ". error while %s inetgw tunnel route to %s for if %d",
         set ? "setting" : "removing", olsr_ip_prefix_to_string(dst), if_idx);
index 63d7890..3b655a6 100644 (file)
@@ -45,7 +45,8 @@ void olsr_os_niit_6to4_route(const struct olsr_ip_prefix *dst_v6 __attribute__ (
 }
 void olsr_os_inetgw_tunnel_route(uint32_t if_idx __attribute__ ((unused)),
     bool ipv4 __attribute__ ((unused)),
-    bool set __attribute__ ((unused))) {
+    bool set __attribute__ ((unused)),
+    uint8_t * table __attribute__ ((unused))) {
 }
 
 int olsr_os_policy_rule(int family __attribute__ ((unused)),