From 630198f04916deb35c5b7774823ae1a5dd168a6c Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Mon, 22 May 2017 09:20:20 -0400 Subject: [PATCH] IPv6 Performance bugs - 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 --- src/plugins/ioam/lib-vxlan-gpe/ioam_transit.c | 1 - src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c | 2 +- src/vnet/dhcp/dhcp6_proxy_node.c | 9 +++--- src/vnet/fib/fib.h | 2 -- src/vnet/fib/ip6_fib.c | 39 ----------------------- src/vnet/fib/ip6_fib.h | 42 +++++++++++++++++++++++-- src/vnet/ip/ip6_forward.c | 32 +++++++++---------- src/vnet/vxlan-gpe/vxlan_gpe.c | 8 ++--- src/vpp/api/api.c | 2 -- 9 files changed, 63 insertions(+), 74 deletions(-) diff --git a/src/plugins/ioam/lib-vxlan-gpe/ioam_transit.c b/src/plugins/ioam/lib-vxlan-gpe/ioam_transit.c index f334c98321a..d90cd5e4328 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/ioam_transit.c +++ b/src/plugins/ioam/lib-vxlan-gpe/ioam_transit.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c index cfc550cd68b..8558c505a43 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_ioam.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/vnet/dhcp/dhcp6_proxy_node.c b/src/vnet/dhcp/dhcp6_proxy_node.c index de73154dddb..885313a588e 100644 --- a/src/vnet/dhcp/dhcp6_proxy_node.c +++ b/src/vnet/dhcp/dhcp6_proxy_node.c @@ -19,9 +19,9 @@ #include #include #include -#include #include #include +#include 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); } diff --git a/src/vnet/fib/fib.h b/src/vnet/fib/fib.h index 7cf1d136935..ec97c565b81 100644 --- a/src/vnet/fib/fib.h +++ b/src/vnet/fib/fib.h @@ -646,7 +646,5 @@ #include #include -#include -#include #endif diff --git a/src/vnet/fib/ip6_fib.c b/src/vnet/fib/ip6_fib.c index 4a24c2124f2..527f91146a0 100644 --- a/src/vnet/fib/ip6_fib.c +++ b/src/vnet/fib/ip6_fib.c @@ -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) diff --git a/src/vnet/fib/ip6_fib.h b/src/vnet/fib/ip6_fib.h index 2bf8ef7821c..9789da4fa97 100644 --- a/src/vnet/fib/ip6_fib.h +++ b/src/vnet/fib/ip6_fib.h @@ -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. */ diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c index 25714e48d5a..28c84d1c2ee 100644 --- a/src/vnet/ip/ip6_forward.c +++ b/src/vnet/ip/ip6_forward.c @@ -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; } diff --git a/src/vnet/vxlan-gpe/vxlan_gpe.c b/src/vnet/vxlan-gpe/vxlan_gpe.c index 2cba596f097..1e674085880 100644 --- a/src/vnet/vxlan-gpe/vxlan_gpe.c +++ b/src/vnet/vxlan-gpe/vxlan_gpe.c @@ -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) { diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c index 60eb5331f59..c1dcfb0384c 100644 --- a/src/vpp/api/api.c +++ b/src/vpp/api/api.c @@ -81,8 +81,6 @@ #include #include #include -#include -#include #include #include #include -- 2.16.6