From 4ec36c5535849a4e456ed99b57968d54d5e03b62 Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Tue, 31 Mar 2020 09:21:29 -0400 Subject: fib: midchain adjacency optimisations Type: improvement - inline some common encap fixup functions into the midchain rewrite node so we don't incur the cost of the virtual function call - change the copy 'guess' from ethernet_header (which will never happen) to an ip4 header - add adj-midchain-tx to multiarch sources - don't run adj-midchain-tx as a feature, instead put this node as the adj's next and at the end of the feature arc. - cache the feature arc config index (to save the cache miss going to fetch it) - don't check if features are enabled when taking the arc (since we know they are) the last two changes will also benefit normal adjacencies taking the arc (i.e. for NAT, ACLs, etc) for IPSec: - don't run esp_encrypt as a feature, instead when required insert this node into the adj's next and into the end of the feature arc. this implies that encrypt is always 'the last feature' run, which is symmetric with decrypt always being the first. - esp_encrpyt for tunnels has adj-midchain-tx as next node Change-Id: Ida0af56a704302cf2d7797ded5f118a781e8acb7 Signed-off-by: Neale Ranns --- src/vnet/feature/feature.c | 29 +++++++++++++++++++++++++++++ src/vnet/feature/feature.h | 20 ++++++++++++++++++++ 2 files changed, 49 insertions(+) (limited to 'src/vnet/feature') diff --git a/src/vnet/feature/feature.c b/src/vnet/feature/feature.c index 0f0bfeb11d2..4a5127db6ac 100644 --- a/src/vnet/feature/feature.c +++ b/src/vnet/feature/feature.c @@ -321,6 +321,35 @@ vnet_feature_enable_disable (const char *arc_name, const char *node_name, n_feature_config_bytes); } +int +vnet_feature_modify_end_node (u8 arc_index, + u32 sw_if_index, u32 end_node_index) +{ + vnet_feature_main_t *fm = &feature_main; + vnet_feature_config_main_t *cm; + u32 ci; + + if (arc_index == (u8) ~ 0) + return VNET_API_ERROR_INVALID_VALUE; + + if (end_node_index == ~0) + return VNET_API_ERROR_INVALID_VALUE_2; + + cm = &fm->feature_config_mains[arc_index]; + vec_validate_init_empty (cm->config_index_by_sw_if_index, sw_if_index, ~0); + ci = cm->config_index_by_sw_if_index[sw_if_index]; + + ci = vnet_config_modify_end_node (vlib_get_main (), &cm->config_main, + ci, end_node_index); + + if (ci == ~0) + return 0; + + cm->config_index_by_sw_if_index[sw_if_index] = ci; + + return 0; +} + static int feature_cmp (void *a1, void *a2) { diff --git a/src/vnet/feature/feature.h b/src/vnet/feature/feature.h index cd016735aca..4d568a512a8 100644 --- a/src/vnet/feature/feature.h +++ b/src/vnet/feature/feature.h @@ -219,6 +219,9 @@ vnet_feature_enable_disable (const char *arc_name, const char *node_name, void *feature_config, u32 n_feature_config_bytes); +int +vnet_feature_modify_end_node (u8 arc_index, u32 sw_if_index, u32 node_index); + static_always_inline u32 vnet_get_feature_count (u8 arc, u32 sw_if_index) { @@ -278,6 +281,23 @@ vnet_feature_arc_start_with_data (u8 arc, u32 sw_if_index, u32 * next, return 0; } +static_always_inline void * +vnet_feature_arc_start_w_cfg_index (u8 arc, + u32 sw_if_index, + u32 * next, + vlib_buffer_t * b, u32 cfg_index) +{ + vnet_feature_main_t *fm = &feature_main; + vnet_feature_config_main_t *cm; + cm = &fm->feature_config_mains[arc]; + + vnet_buffer (b)->feature_arc_index = arc; + b->current_config_index = cfg_index; + + return vnet_get_config_data (&cm->config_main, &b->current_config_index, + next, 0); +} + static_always_inline void vnet_feature_arc_start (u8 arc, u32 sw_if_index, u32 * next0, vlib_buffer_t * b0) -- cgit 1.2.3-korg