IPv6 Performance bugs 27/6827/3
authorNeale Ranns <nranns@cisco.com>
Mon, 22 May 2017 13:20:20 +0000 (09:20 -0400)
committerDamjan Marion <dmarion.lists@gmail.com>
Wed, 24 May 2017 19:48:43 +0000 (19:48 +0000)
- inline the FIB lookup function; this requires access to the bihash, so for files that use more than one type this casues problems. those files that include ip6_fib.h unnecessarily have been updated
- better use of the feature arcs. ip6-lookup and interface-output are now sentinels (end-node-index in the cm speak) rather than enabled features.

Change-Id: I9d1375fee63f7dbb2d327da6124d8e60b63367ec
Signed-off-by: Neale Ranns <nranns@cisco.com>
src/plugins/ioam/lib-vxlan-gpe/ioam_transit.c
src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c
src/vnet/dhcp/dhcp6_proxy_node.c
src/vnet/fib/fib.h
src/vnet/fib/ip6_fib.c
src/vnet/fib/ip6_fib.h
src/vnet/ip/ip6_forward.c
src/vnet/vxlan-gpe/vxlan_gpe.c
src/vpp/api/api.c

index f334c98..d90cd5e 100644 (file)
@@ -22,7 +22,6 @@
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam_packet.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam_util.h>
-#include <vnet/fib/ip6_fib.h>
 #include <vnet/fib/ip4_fib.h>
 #include <vnet/fib/fib_entry.h>
 
index cfc550c..8558c50 100644 (file)
@@ -16,7 +16,7 @@
 #include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
 #include <vnet/ip/format.h>
 #include <ioam/lib-vxlan-gpe/vxlan_gpe_ioam.h>
-#include <vnet/fib/ip6_fib.h>
+#include <vnet/dpo/load_balance.h>
 #include <vnet/fib/ip4_fib.h>
 #include <vnet/fib/fib_entry.h>
 
index de73154..885313a 100644 (file)
@@ -19,9 +19,9 @@
 #include <vnet/pg/pg.h>
 #include <vnet/dhcp/dhcp_proxy.h>
 #include <vnet/dhcp/dhcp6_packet.h>
-#include <vnet/fib/ip6_fib.h>
 #include <vnet/mfib/mfib_table.h>
 #include <vnet/mfib/ip6_mfib.h>
+#include <vnet/fib/fib.h>
 
 static char * dhcpv6_proxy_error_strings[] = {
 #define dhcpv6_proxy_error(n,s) s,
@@ -966,7 +966,7 @@ static u8 *
 format_dhcp6_proxy_server (u8 * s, va_list * args)
 {
   dhcp_proxy_t * proxy = va_arg (*args, dhcp_proxy_t *);
-  ip6_fib_t *server_fib;
+  fib_table_t *server_fib;
   dhcp_server_t *server;
   ip6_mfib_t *rx_fib;
 
@@ -985,9 +985,10 @@ format_dhcp6_proxy_server (u8 * s, va_list * args)
 
   vec_foreach(server, proxy->dhcp_servers)
   {
-      server_fib = ip6_fib_get(server->server_fib_index);
+      server_fib = fib_table_get(server->server_fib_index,
+                                 FIB_PROTOCOL_IP6);
       s = format (s, "%u,%U  ",
-                  server_fib->table_id,
+                  server_fib->ft_table_id,
                   format_ip46_address, &server->dhcp_server, IP46_TYPE_ANY);
   }
 
index 7cf1d13..ec97c56 100644 (file)
 
 #include <vnet/fib/fib_table.h>
 #include <vnet/fib/fib_entry.h>
-#include <vnet/fib/ip4_fib.h>
-#include <vnet/fib/ip6_fib.h>
 
 #endif
index 4a24c21..527f911 100644 (file)
@@ -341,45 +341,6 @@ ip6_fib_table_entry_insert (u32 fib_index,
     compute_prefix_lengths_in_search_order (table);
 }
 
-u32 
-ip6_fib_table_fwding_lookup (ip6_main_t * im,
-                             u32 fib_index,
-                             const ip6_address_t * dst)
-{
-    const ip6_fib_table_instance_t *table;
-    int i, len;
-    int rv;
-    BVT(clib_bihash_kv) kv, value;
-    u64 fib;
-
-    table = &ip6_main.ip6_table[IP6_FIB_TABLE_FWDING];
-    len = vec_len (table->prefix_lengths_in_search_order);
-
-    kv.key[0] = dst->as_u64[0];
-    kv.key[1] = dst->as_u64[1];
-    fib = ((u64)((fib_index))<<32);
-
-    for (i = 0; i < len; i++)
-    {
-       int dst_address_length = table->prefix_lengths_in_search_order[i];
-       ip6_address_t * mask = &ip6_main.fib_masks[dst_address_length];
-      
-       ASSERT(dst_address_length >= 0 && dst_address_length <= 128);
-       //As lengths are decreasing, masks are increasingly specific.
-       kv.key[0] &= mask->as_u64[0];
-       kv.key[1] &= mask->as_u64[1];
-       kv.key[2] = fib | dst_address_length;
-      
-       rv = BV(clib_bihash_search_inline_2)(&table->ip6_hash, &kv, &value);
-       if (rv == 0)
-           return value.value;
-    }
-
-    /* default route is always present */
-    ASSERT(0);
-    return 0;
-}
-
 u32 ip6_fib_table_fwding_lookup_with_if_index (ip6_main_t * im,
                                               u32 sw_if_index,
                                               const ip6_address_t * dst)
index 2bf8ef7..9789da4 100644 (file)
@@ -53,9 +53,6 @@ extern void ip6_fib_table_fwding_dpo_remove(u32 fib_index,
 u32 ip6_fib_table_fwding_lookup_with_if_index(ip6_main_t * im,
                                              u32 sw_if_index,
                                              const ip6_address_t * dst);
-u32 ip6_fib_table_fwding_lookup(ip6_main_t * im,
-                               u32 fib_index,
-                               const ip6_address_t * dst);
 
 /**
  * @brief Walk all entries in a FIB table
@@ -66,6 +63,45 @@ extern void ip6_fib_table_walk(u32 fib_index,
                                fib_table_walk_fn_t fn,
                                void *ctx);
 
+always_inline u32
+ip6_fib_table_fwding_lookup (ip6_main_t * im,
+                             u32 fib_index,
+                             const ip6_address_t * dst)
+{
+    const ip6_fib_table_instance_t *table;
+    int i, len;
+    int rv;
+    BVT(clib_bihash_kv) kv, value;
+    u64 fib;
+
+    table = &ip6_main.ip6_table[IP6_FIB_TABLE_FWDING];
+    len = vec_len (table->prefix_lengths_in_search_order);
+
+    kv.key[0] = dst->as_u64[0];
+    kv.key[1] = dst->as_u64[1];
+    fib = ((u64)((fib_index))<<32);
+
+    for (i = 0; i < len; i++)
+    {
+       int dst_address_length = table->prefix_lengths_in_search_order[i];
+       ip6_address_t * mask = &ip6_main.fib_masks[dst_address_length];
+
+       ASSERT(dst_address_length >= 0 && dst_address_length <= 128);
+       //As lengths are decreasing, masks are increasingly specific.
+       kv.key[0] &= mask->as_u64[0];
+       kv.key[1] &= mask->as_u64[1];
+       kv.key[2] = fib | dst_address_length;
+
+       rv = BV(clib_bihash_search_inline_2)(&table->ip6_hash, &kv, &value);
+       if (rv == 0)
+           return value.value;
+    }
+
+    /* default route is always present */
+    ASSERT(0);
+    return 0;
+}
+
 /**
  * @brief return the DPO that the LB stacks on.
  */
index 25714e4..28c84d1 100644 (file)
@@ -444,12 +444,11 @@ ip6_sw_interface_enable_disable (u32 sw_if_index, u32 is_enable)
        return;
     }
 
-  vnet_feature_enable_disable ("ip6-unicast", "ip6-lookup", sw_if_index,
-                              is_enable, 0, 0);
-
-  vnet_feature_enable_disable ("ip6-multicast", "ip6-mfib-forward-lookup",
-                              sw_if_index, is_enable, 0, 0);
+  vnet_feature_enable_disable ("ip6-unicast", "ip6-drop", sw_if_index,
+                              !is_enable, 0, 0);
 
+  vnet_feature_enable_disable ("ip6-multicast", "ip6-drop", sw_if_index,
+                              !is_enable, 0, 0);
 }
 
 /* get first interface address */
@@ -624,17 +623,17 @@ VNET_FEATURE_INIT (ip6_vxlan_bypass, static) =
   .runs_before = VNET_FEATURES ("ip6-lookup"),
 };
 
-VNET_FEATURE_INIT (ip6_lookup, static) =
+VNET_FEATURE_INIT (ip6_drop, static) =
 {
   .arc_name = "ip6-unicast",
-  .node_name = "ip6-lookup",
-  .runs_before = VNET_FEATURES ("ip6-drop"),
+  .node_name = "ip6-drop",
+  .runs_before = VNET_FEATURES ("ip6-lookup"),
 };
 
-VNET_FEATURE_INIT (ip6_drop, static) =
+VNET_FEATURE_INIT (ip6_lookup, static) =
 {
   .arc_name = "ip6-unicast",
-  .node_name = "ip6-drop",
+  .node_name = "ip6-lookup",
   .runs_before = 0,  /*last feature*/
 };
 
@@ -652,15 +651,15 @@ VNET_FEATURE_INIT (ip6_vpath_mc, static) = {
   .runs_before = VNET_FEATURES ("ip6-mfib-forward-lookup"),
 };
 
-VNET_FEATURE_INIT (ip6_mc_lookup, static) = {
+VNET_FEATURE_INIT (ip6_drop_mc, static) = {
   .arc_name = "ip6-multicast",
-  .node_name = "ip6-mfib-forward-lookup",
-  .runs_before = VNET_FEATURES ("ip6-drop"),
+  .node_name = "ip6-drop",
+  .runs_before = VNET_FEATURES ("ip6-mfib-forward-lookup"),
 };
 
-VNET_FEATURE_INIT (ip6_drop_mc, static) = {
+VNET_FEATURE_INIT (ip6_mc_lookup, static) = {
   .arc_name = "ip6-multicast",
-  .node_name = "ip6-drop",
+  .node_name = "ip6-mfib-forward-lookup",
   .runs_before = 0, /* last feature */
 };
 
@@ -699,9 +698,6 @@ ip6_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
   vnet_feature_enable_disable ("ip6-multicast", "ip6-drop", sw_if_index,
                               is_add, 0, 0);
 
-  vnet_feature_enable_disable ("ip6-output", "interface-output", sw_if_index,
-                              is_add, 0, 0);
-
   return /* no error */ 0;
 }
 
index 2cba596..1e67408 100644 (file)
@@ -490,9 +490,9 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm,
     else if (unformat (line_input, "encap-vrf-id %d", &tmp))
       {
         if (ipv6_set)
-          encap_fib_index = ip6_fib_index_from_table_id (tmp);
+          encap_fib_index = fib_table_find (FIB_PROTOCOL_IP6, tmp);
         else
-          encap_fib_index =  ip4_fib_index_from_table_id (tmp);
+          encap_fib_index = fib_table_find (FIB_PROTOCOL_IP4, tmp);
 
         if (encap_fib_index == ~0)
           {
@@ -503,9 +503,9 @@ vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm,
     else if (unformat (line_input, "decap-vrf-id %d", &tmp))
       {
         if (ipv6_set)
-          decap_fib_index = ip6_fib_index_from_table_id (tmp);
+          decap_fib_index = fib_table_find (FIB_PROTOCOL_IP6, tmp);
         else
-          decap_fib_index = ip4_fib_index_from_table_id (tmp);
+          decap_fib_index = fib_table_find (FIB_PROTOCOL_IP4, tmp);
 
         if (decap_fib_index == ~0)
           {
index 60eb533..c1dcfb0 100644 (file)
@@ -81,8 +81,6 @@
 #include <vnet/l2/l2_bd.h>
 #include <vpp/api/vpe_msg_enum.h>
 #include <vnet/span/span.h>
-#include <vnet/fib/ip6_fib.h>
-#include <vnet/fib/ip4_fib.h>
 #include <vnet/fib/fib_api.h>
 #include <vnet/dpo/drop_dpo.h>
 #include <vnet/dpo/receive_dpo.h>