diff options
Diffstat (limited to 'hicn-plugin/src/data_input_node.c')
-rw-r--r-- | hicn-plugin/src/data_input_node.c | 409 |
1 files changed, 218 insertions, 191 deletions
diff --git a/hicn-plugin/src/data_input_node.c b/hicn-plugin/src/data_input_node.c index 8d20f54a6..a91f9156d 100644 --- a/hicn-plugin/src/data_input_node.c +++ b/hicn-plugin/src/data_input_node.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Cisco and/or its affiliates. + * Copyright (c) 2021 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -16,8 +16,8 @@ #include <vnet/vnet.h> #include <vnet/ip/ip.h> #include <vnet/fib/ip6_fib.h> -#include <vnet/fib/fib_table.h> /* for FIB table and entry creation */ -#include <vnet/fib/fib_entry.h> /* for FIB table and entry creation */ +#include <vnet/fib/fib_table.h> /* for FIB table and entry creation */ +#include <vnet/fib/fib_entry.h> /* for FIB table and entry creation */ #include <vnet/fib/ip4_fib.h> #include <vnet/dpo/load_balance.h> @@ -61,7 +61,7 @@ vlib_node_registration_t hicn_data_input_ip6_node; vlib_node_registration_t hicn_data_input_ip4_node; static __clib_unused u8 * -format_hicn_data_input_trace (u8 * s, va_list * args) +format_hicn_data_input_trace (u8 *s, va_list *args) { CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); @@ -69,22 +69,59 @@ format_hicn_data_input_trace (u8 * s, va_list * args) u32 indent = format_get_indent (s); u8 isv6 = (u8) va_arg (*args, int); - s = - format (s, "%U hicn_data_input%s: sw_if_index %d next-index %d", - format_white_space, indent, isv6 ? "_ip6" : "_ip4", - t->sw_if_index, t->next_index); + s = format (s, "%U hicn_data_input%s: sw_if_index %d next-index %d", + format_white_space, indent, isv6 ? "_ip6" : "_ip4", + t->sw_if_index, t->next_index); return s; } +static void +hicn_data_input_set_adj_index (vlib_buffer_t *b, + const ip46_address_t *dst_addr, + const hicn_dpo_ctx_t *dpo_ctx) +{ + CLIB_UNUSED (u8 set) = 0; + u32 *adj_index = &vnet_buffer (b)->ip.adj_index[VLIB_RX]; + + if (*adj_index != ADJ_INDEX_INVALID) + { + return; + } + + for (u8 pos = 0; pos < dpo_ctx->entry_count; pos++) + { + hicn_face_t *face = hicn_dpoi_get_from_idx (dpo_ctx->next_hops[pos]); + assert (face); + + if (ip46_address_cmp (&(face->nat_addr), dst_addr) == 0) + { + *adj_index = face->dpo.dpoi_index; + set = 1; + break; + } + } + + ASSERT (set == 1); +} + static uword -hicn_data_input_ip6_fn (vlib_main_t * vm, - vlib_node_runtime_t * node, vlib_frame_t * frame) +hicn_data_input_ip6_fn (vlib_main_t *vm, vlib_node_runtime_t *node, + vlib_frame_t *frame) { ip6_main_t *im = &ip6_main; vlib_combined_counter_main_t *cm = &load_balance_main.lbm_to_counters; u32 n_left_from, n_left_to_next, *from, *to_next; ip_lookup_next_t next; u32 thread_index = vm->thread_index; + vlib_buffer_t *p0, *p1; + u32 pi0, pi1, lbi0, lbi1, wrong_next; + ip_lookup_next_t next0, next1; + ip6_header_t *ip0, *ip1; + ip6_address_t *src_addr0, *src_addr1; + ip46_address_t dst_addr0, dst_addr1; + const dpo_id_t *dpo0, *dpo1; + const load_balance_t *lb0, *lb1; + hicn_buffer_t *hicnb0, *hicnb1; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -96,14 +133,6 @@ hicn_data_input_ip6_fn (vlib_main_t * vm, while (n_left_from >= 4 && n_left_to_next >= 2) { - vlib_buffer_t *p0, *p1; - u32 pi0, pi1, lbi0, lbi1, wrong_next; - ip_lookup_next_t next0, next1; - ip6_header_t *ip0, *ip1; - ip6_address_t *src_addr0, *src_addr1; - const dpo_id_t *dpo0, *dpo1; - const load_balance_t *lb0, *lb1; - /* Prefetch next iteration. */ { vlib_buffer_t *p2, *p3; @@ -123,12 +152,18 @@ hicn_data_input_ip6_fn (vlib_main_t * vm, p0 = vlib_get_buffer (vm, pi0); p1 = vlib_get_buffer (vm, pi1); + hicnb0 = hicn_get_buffer (p0); + hicnb1 = hicn_get_buffer (p1); + ip0 = vlib_buffer_get_current (p0); ip1 = vlib_buffer_get_current (p1); src_addr0 = &ip0->src_address; src_addr1 = &ip1->src_address; + ip46_address_set_ip6 (&dst_addr0, &ip0->dst_address); + ip46_address_set_ip6 (&dst_addr1, &ip1->dst_address); + ip_lookup_set_buffer_fib_index (im->fib_index_by_sw_if_index, p0); ip_lookup_set_buffer_fib_index (im->fib_index_by_sw_if_index, p1); @@ -146,19 +181,29 @@ hicn_data_input_ip6_fn (vlib_main_t * vm, vnet_buffer (p0)->ip.flow_hash = vnet_buffer (p1)->ip.flow_hash = 0; - //No vpp loadbalancing. Missing header file to exploit it + // No vpp loadbalancing. Missing header file to exploit it dpo0 = load_balance_get_bucket_i (lb0, 0); dpo1 = load_balance_get_bucket_i (lb1, 0); if (dpo_is_hicn (dpo0)) - next0 = HICN_DATA_INPUT_IP6_NEXT_FACE; + { + next0 = (ip_lookup_next_t) HICN_DATA_INPUT_IP6_NEXT_FACE; + hicnb0->dpo_ctx_id = dpo0->dpoi_index; + hicn_data_input_set_adj_index ( + p0, &dst_addr0, hicn_strategy_dpo_ctx_get (dpo0->dpoi_index)); + } else - next0 = HICN_DATA_INPUT_IP6_NEXT_IP6_LOCAL; + next0 = (ip_lookup_next_t) HICN_DATA_INPUT_IP6_NEXT_IP6_LOCAL; if (dpo_is_hicn (dpo1)) - next1 = HICN_DATA_INPUT_IP6_NEXT_FACE; + { + next1 = (ip_lookup_next_t) HICN_DATA_INPUT_IP6_NEXT_FACE; + hicnb1->dpo_ctx_id = dpo1->dpoi_index; + hicn_data_input_set_adj_index ( + p1, &dst_addr1, hicn_strategy_dpo_ctx_get (dpo1->dpoi_index)); + } else - next1 = HICN_DATA_INPUT_IP6_NEXT_IP6_LOCAL; + next1 = (ip_lookup_next_t) HICN_DATA_INPUT_IP6_NEXT_IP6_LOCAL; if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) && (p0->flags & VLIB_BUFFER_IS_TRACED)) @@ -180,11 +225,10 @@ hicn_data_input_ip6_fn (vlib_main_t * vm, t->isv6 = 1; } - - vlib_increment_combined_counter - (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); - vlib_increment_combined_counter - (cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1)); + vlib_increment_combined_counter ( + cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); + vlib_increment_combined_counter ( + cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1)); from += 2; to_next += 2; @@ -236,15 +280,19 @@ hicn_data_input_ip6_fn (vlib_main_t * vm, u32 pi0, lbi0; ip_lookup_next_t next0; load_balance_t *lb0; + hicn_buffer_t *hicnb0; ip6_address_t *src_addr0; + ip46_address_t dst_addr0; const dpo_id_t *dpo0; pi0 = from[0]; to_next[0] = pi0; p0 = vlib_get_buffer (vm, pi0); + hicnb0 = hicn_get_buffer (p0); ip0 = vlib_buffer_get_current (p0); src_addr0 = &ip0->src_address; + ip46_address_set_ip6 (&dst_addr0, &ip0->dst_address); ip_lookup_set_buffer_fib_index (im->fib_index_by_sw_if_index, p0); lbi0 = ip6_fib_table_fwding_lookup (vnet_buffer (p0)->ip.fib_index, src_addr0); @@ -253,13 +301,18 @@ hicn_data_input_ip6_fn (vlib_main_t * vm, ASSERT (lb0->lb_n_buckets > 0); ASSERT (is_pow2 (lb0->lb_n_buckets)); - //No vpp loadbalancing. Missing header file to exploit it + // No vpp loadbalancing. Missing header file to exploit it dpo0 = load_balance_get_bucket_i (lb0, 0); if (dpo_is_hicn (dpo0)) - next0 = HICN_DATA_INPUT_IP6_NEXT_FACE; + { + next0 = (ip_lookup_next_t) HICN_DATA_INPUT_IP6_NEXT_FACE; + hicn_data_input_set_adj_index ( + p0, &dst_addr0, hicn_strategy_dpo_ctx_get (dpo0->dpoi_index)); + hicnb0->dpo_ctx_id = dpo0->dpoi_index; + } else - next0 = HICN_DATA_INPUT_IP6_NEXT_IP6_LOCAL; + next0 = (ip_lookup_next_t) HICN_DATA_INPUT_IP6_NEXT_IP6_LOCAL; if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) && (p0->flags & VLIB_BUFFER_IS_TRACED)) @@ -271,8 +324,8 @@ hicn_data_input_ip6_fn (vlib_main_t * vm, t->isv6 = 1; } - vlib_increment_combined_counter - (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); + vlib_increment_combined_counter ( + cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0)); from += 1; to_next += 1; @@ -297,39 +350,29 @@ hicn_data_input_ip6_fn (vlib_main_t * vm, return frame->n_vectors; } -/* *INDENT-OFF* */ -VLIB_REGISTER_NODE(hicn_data_input_ip6) = - { - .function = hicn_data_input_ip6_fn, - .name = "hicn-data-input-ip6", - .vector_size = sizeof(u32), - .format_trace = format_hicn_data_input_trace, - .type = VLIB_NODE_TYPE_INTERNAL, - .n_errors = ARRAY_LEN(hicn_data_input_error_strings), - .error_strings = hicn_data_input_error_strings, - .n_next_nodes = HICN_DATA_INPUT_IP6_N_NEXT, - .next_nodes = - { - [HICN_DATA_INPUT_IP6_NEXT_FACE] = "hicn6-face-input", - [HICN_DATA_INPUT_IP6_NEXT_IP6_LOCAL] = "ip6-local-end-of-arc" - }, - }; -/* *INDENT-ON* */ - -/* *INDENT-OFF* */ -VNET_FEATURE_INIT(hicn_data_input_ip6_arc, static)= - { - .arc_name = "ip6-local", - .node_name = "hicn-data-input-ip6", - .runs_before = VNET_FEATURES("ip6-local-end-of-arc"), - }; -/* *INDENT-ON* */ - +VLIB_REGISTER_NODE (hicn_data_input_ip6) = { + .function = hicn_data_input_ip6_fn, + .name = "hicn-data-input-ip6", + .vector_size = sizeof (u32), + .format_trace = format_hicn_data_input_trace, + .type = VLIB_NODE_TYPE_INTERNAL, + .n_errors = ARRAY_LEN (hicn_data_input_error_strings), + .error_strings = hicn_data_input_error_strings, + .n_next_nodes = HICN_DATA_INPUT_IP6_N_NEXT, + .next_nodes = { [HICN_DATA_INPUT_IP6_NEXT_FACE] = "hicn6-face-input", + [HICN_DATA_INPUT_IP6_NEXT_IP6_LOCAL] = + "ip6-local-end-of-arc" }, +}; +VNET_FEATURE_INIT (hicn_data_input_ip6_arc, static) = { + .arc_name = "ip6-local", + .node_name = "hicn-data-input-ip6", + .runs_before = VNET_FEATURES ("ip6-local-end-of-arc") +}; always_inline uword -hicn_data_input_ip4_fn (vlib_main_t * vm, - vlib_node_runtime_t * node, vlib_frame_t * frame) +hicn_data_input_ip4_fn (vlib_main_t *vm, vlib_node_runtime_t *node, + vlib_frame_t *frame) { ip4_main_t *im = &ip4_main; vlib_combined_counter_main_t *cm = &load_balance_main.lbm_to_counters; @@ -338,6 +381,13 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, vlib_buffer_t *bufs[VLIB_FRAME_SIZE]; vlib_buffer_t **b = bufs; u16 nexts[VLIB_FRAME_SIZE], *next; + ip4_header_t *ip0, *ip1, *ip2, *ip3; + const load_balance_t *lb0, *lb1, *lb2, *lb3; + ip4_address_t *src_addr0, *src_addr1, *src_addr2, *src_addr3; + ip46_address_t dst_addr0, dst_addr1, dst_addr2, dst_addr3; + u32 lb_index0, lb_index1, lb_index2, lb_index3; + const dpo_id_t *dpo0, *dpo1, *dpo2, *dpo3; + hicn_buffer_t *hicnb0, *hicnb1, *hicnb2, *hicnb3; from = vlib_frame_vector_args (frame); n_left = frame->n_vectors; @@ -347,14 +397,6 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, #if (CLIB_N_PREFETCHES >= 8) while (n_left >= 4) { - ip4_header_t *ip0, *ip1, *ip2, *ip3; - const load_balance_t *lb0, *lb1, *lb2, *lb3; - ip4_fib_mtrie_t *mtrie0, *mtrie1, *mtrie2, *mtrie3; - ip4_fib_mtrie_leaf_t leaf0, leaf1, leaf2, leaf3; - ip4_address_t *src_addr0, *src_addr1, *src_addr2, *src_addr3; - u32 lb_index0, lb_index1, lb_index2, lb_index3; - const dpo_id_t *dpo0, *dpo1, *dpo2, *dpo3; - /* Prefetch next iteration. */ if (n_left >= 8) { @@ -374,40 +416,31 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, ip2 = vlib_buffer_get_current (b[2]); ip3 = vlib_buffer_get_current (b[3]); + hicnb0 = hicn_get_buffer (b[0]); + hicnb1 = hicn_get_buffer (b[1]); + hicnb2 = hicn_get_buffer (b[2]); + hicnb3 = hicn_get_buffer (b[3]); + src_addr0 = &ip0->src_address; src_addr1 = &ip1->src_address; src_addr2 = &ip2->src_address; src_addr3 = &ip3->src_address; + ip46_address_set_ip4 (&dst_addr0, &ip0->dst_address); + ip46_address_set_ip4 (&dst_addr1, &ip1->dst_address); + ip46_address_set_ip4 (&dst_addr2, &ip2->dst_address); + ip46_address_set_ip4 (&dst_addr3, &ip3->dst_address); + ip_lookup_set_buffer_fib_index (im->fib_index_by_sw_if_index, b[0]); ip_lookup_set_buffer_fib_index (im->fib_index_by_sw_if_index, b[1]); ip_lookup_set_buffer_fib_index (im->fib_index_by_sw_if_index, b[2]); ip_lookup_set_buffer_fib_index (im->fib_index_by_sw_if_index, b[3]); - mtrie0 = &ip4_fib_get (vnet_buffer (b[0])->ip.fib_index)->mtrie; - mtrie1 = &ip4_fib_get (vnet_buffer (b[1])->ip.fib_index)->mtrie; - mtrie2 = &ip4_fib_get (vnet_buffer (b[2])->ip.fib_index)->mtrie; - mtrie3 = &ip4_fib_get (vnet_buffer (b[3])->ip.fib_index)->mtrie; - - leaf0 = ip4_fib_mtrie_lookup_step_one (mtrie0, src_addr0); - leaf1 = ip4_fib_mtrie_lookup_step_one (mtrie1, src_addr1); - leaf2 = ip4_fib_mtrie_lookup_step_one (mtrie2, src_addr2); - leaf3 = ip4_fib_mtrie_lookup_step_one (mtrie3, src_addr3); - - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, src_addr0, 2); - leaf1 = ip4_fib_mtrie_lookup_step (mtrie1, leaf1, src_addr1, 2); - leaf2 = ip4_fib_mtrie_lookup_step (mtrie2, leaf2, src_addr2, 2); - leaf3 = ip4_fib_mtrie_lookup_step (mtrie3, leaf3, src_addr3, 2); - - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, src_addr0, 3); - leaf1 = ip4_fib_mtrie_lookup_step (mtrie1, leaf1, src_addr1, 3); - leaf2 = ip4_fib_mtrie_lookup_step (mtrie2, leaf2, src_addr2, 3); - leaf3 = ip4_fib_mtrie_lookup_step (mtrie3, leaf3, src_addr3, 3); - - lb_index0 = ip4_fib_mtrie_leaf_get_adj_index (leaf0); - lb_index1 = ip4_fib_mtrie_leaf_get_adj_index (leaf1); - lb_index2 = ip4_fib_mtrie_leaf_get_adj_index (leaf2); - lb_index3 = ip4_fib_mtrie_leaf_get_adj_index (leaf3); + ip4_fib_forwarding_lookup_x4 ( + vnet_buffer (b[0])->ip.fib_index, vnet_buffer (b[1])->ip.fib_index, + vnet_buffer (b[2])->ip.fib_index, vnet_buffer (b[3])->ip.fib_index, + src_addr0, src_addr1, src_addr2, src_addr3, &lb_index0, &lb_index1, + &lb_index2, &lb_index3); ASSERT (lb_index0 && lb_index1 && lb_index2 && lb_index3); lb0 = load_balance_get (lb_index0); @@ -430,26 +463,45 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, dpo3 = load_balance_get_bucket_i (lb3, 0); if (dpo_is_hicn (dpo0)) - next[0] = HICN_DATA_INPUT_IP4_NEXT_FACE; + { + next[0] = (ip_lookup_next_t) HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; + hicnb0->dpo_ctx_id = dpo0->dpoi_index; + hicn_data_input_set_adj_index ( + b[0], &dst_addr0, hicn_strategy_dpo_ctx_get (dpo0->dpoi_index)); + } else next[0] = HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; if (dpo_is_hicn (dpo1)) - next[1] = HICN_DATA_INPUT_IP4_NEXT_FACE; + { + next[1] = (ip_lookup_next_t) HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; + hicnb1->dpo_ctx_id = dpo1->dpoi_index; + hicn_data_input_set_adj_index ( + b[1], &dst_addr1, hicn_strategy_dpo_ctx_get (dpo1->dpoi_index)); + } else next[1] = HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; if (dpo_is_hicn (dpo2)) - next[2] = HICN_DATA_INPUT_IP4_NEXT_FACE; + { + next[2] = (ip_lookup_next_t) HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; + hicnb2->dpo_ctx_id = dpo2->dpoi_index; + hicn_data_input_set_adj_index ( + b[2], &dst_addr2, hicn_strategy_dpo_ctx_get (dpo2->dpoi_index)); + } else next[2] = HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; if (dpo_is_hicn (dpo3)) - next[3] = HICN_DATA_INPUT_IP4_NEXT_FACE; + { + next[3] = (ip_lookup_next_t) HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; + hicnb3->dpo_ctx_id = dpo3->dpoi_index; + hicn_data_input_set_adj_index ( + b[3], &dst_addr3, hicn_strategy_dpo_ctx_get (dpo3->dpoi_index)); + } else next[3] = HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; - if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) && (b[0]->flags & VLIB_BUFFER_IS_TRACED)) { @@ -490,18 +542,14 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, t->isv6 = 0; } - vlib_increment_combined_counter - (cm, thread_index, lb_index0, 1, - vlib_buffer_length_in_chain (vm, b[0])); - vlib_increment_combined_counter - (cm, thread_index, lb_index1, 1, - vlib_buffer_length_in_chain (vm, b[1])); - vlib_increment_combined_counter - (cm, thread_index, lb_index2, 1, - vlib_buffer_length_in_chain (vm, b[2])); - vlib_increment_combined_counter - (cm, thread_index, lb_index3, 1, - vlib_buffer_length_in_chain (vm, b[3])); + vlib_increment_combined_counter (cm, thread_index, lb_index0, 1, + vlib_buffer_length_in_chain (vm, b[0])); + vlib_increment_combined_counter (cm, thread_index, lb_index1, 1, + vlib_buffer_length_in_chain (vm, b[1])); + vlib_increment_combined_counter (cm, thread_index, lb_index2, 1, + vlib_buffer_length_in_chain (vm, b[2])); + vlib_increment_combined_counter (cm, thread_index, lb_index3, 1, + vlib_buffer_length_in_chain (vm, b[3])); b += 4; next += 4; @@ -510,16 +558,6 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, #elif (CLIB_N_PREFETCHES >= 4) while (n_left >= 4) { - ip4_header_t *ip0, *ip1; - const load_balance_t *lb0, *lb1; - ip4_fib_mtrie_t *mtrie0, *mtrie1; - ip4_fib_mtrie_leaf_t leaf0, leaf1; - ip4_address_t *src_addr0, *src_addr1; - u32 lb_index0, lb_index1; - flow_hash_config_t flow_hash_config0, flow_hash_config1; - u32 hash_c0, hash_c1; - const dpo_id_t *dpo0, *dpo1; - /* Prefetch next iteration. */ { vlib_prefetch_buffer_header (b[2], LOAD); @@ -532,26 +570,21 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, ip0 = vlib_buffer_get_current (b[0]); ip1 = vlib_buffer_get_current (b[1]); + hicnb0 = hicn_get_buffer (b[0]); + hicnb1 = hicn_get_buffer (b[1]); + src_addr0 = &ip0->src_address; src_addr1 = &ip1->src_address; + ip46_address_set_ip4 (&dst_addr0, &ip0->dst_address); + ip46_address_set_ip4 (&dst_addr1, &ip1->dst_address); + ip_lookup_set_buffer_fib_index (im->fib_index_by_sw_if_index, b[0]); ip_lookup_set_buffer_fib_index (im->fib_index_by_sw_if_index, b[1]); - mtrie0 = &ip4_fib_get (vnet_buffer (b[0])->ip.fib_index)->mtrie; - mtrie1 = &ip4_fib_get (vnet_buffer (b[1])->ip.fib_index)->mtrie; - - leaf0 = ip4_fib_mtrie_lookup_step_one (mtrie0, src_addr0); - leaf1 = ip4_fib_mtrie_lookup_step_one (mtrie1, src_addr1); - - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, src_addr0, 2); - leaf1 = ip4_fib_mtrie_lookup_step (mtrie1, leaf1, src_addr1, 2); - - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, src_addr0, 3); - leaf1 = ip4_fib_mtrie_lookup_step (mtrie1, leaf1, src_addr1, 3); - - lb_index0 = ip4_fib_mtrie_leaf_get_adj_index (leaf0); - lb_index1 = ip4_fib_mtrie_leaf_get_adj_index (leaf1); + ip4_fib_forwarding_lookup_x2 ( + vnet_buffer (b[0])->ip.fib_index, vnet_buffer (b[1])->ip.fib_index, + src_addr0, src_addr1, &lb_index0, &lb_index1); ASSERT (lb_index0 && lb_index1); lb0 = load_balance_get (lb_index0); @@ -566,12 +599,22 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, dpo1 = load_balance_get_bucket_i (lb1, 0); if (dpo_is_hicn (dpo0)) - next[0] = HICN_DATA_INPUT_IP4_NEXT_FACE; + { + next[0] = (ip_lookup_next_t) HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; + hicnb0->dpo_ctx_id = dpo0->dpoi_index; + hicn_data_input_set_adj_index ( + b[0], &dst_addr0, hicn_strategy_dpo_ctx_get (dpo0->dpoi_index)); + } else next[0] = HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; if (dpo_is_hicn (dpo1)) - next[1] = HICN_DATA_INPUT_IP4_NEXT_FACE; + { + next[1] = (ip_lookup_next_t) HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; + hicnb1->dpo_ctx_id = dpo1->dpoi_index; + hicn_data_input_set_adj_index ( + b[1], &dst_addr1, hicn_strategy_dpo_ctx_get (dpo1->dpoi_index)); + } else next[1] = HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; @@ -595,13 +638,10 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, t->isv6 = 0; } - - vlib_increment_combined_counter - (cm, thread_index, lb_index0, 1, - vlib_buffer_length_in_chain (vm, b[0])); - vlib_increment_combined_counter - (cm, thread_index, lb_index1, 1, - vlib_buffer_length_in_chain (vm, b[1])); + vlib_increment_combined_counter (cm, thread_index, lb_index0, 1, + vlib_buffer_length_in_chain (vm, b[0])); + vlib_increment_combined_counter (cm, thread_index, lb_index1, 1, + vlib_buffer_length_in_chain (vm, b[1])); b += 2; next += 2; @@ -610,26 +650,17 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, #endif while (n_left > 0) { - ip4_header_t *ip0; - const load_balance_t *lb0; - ip4_fib_mtrie_t *mtrie0; - ip4_fib_mtrie_leaf_t leaf0; - ip4_address_t *src_addr0; - u32 lbi0; - const dpo_id_t *dpo0; - ip0 = vlib_buffer_get_current (b[0]); + hicnb0 = hicn_get_buffer (b[0]); src_addr0 = &ip0->src_address; + ip46_address_set_ip4 (&dst_addr0, &ip0->dst_address); ip_lookup_set_buffer_fib_index (im->fib_index_by_sw_if_index, b[0]); - mtrie0 = &ip4_fib_get (vnet_buffer (b[0])->ip.fib_index)->mtrie; - leaf0 = ip4_fib_mtrie_lookup_step_one (mtrie0, src_addr0); - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, src_addr0, 2); - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, src_addr0, 3); - lbi0 = ip4_fib_mtrie_leaf_get_adj_index (leaf0); + lb_index0 = ip4_fib_forwarding_lookup (vnet_buffer (b[0])->ip.fib_index, + src_addr0); - ASSERT (lbi0); - lb0 = load_balance_get (lbi0); + ASSERT (lb_index0); + lb0 = load_balance_get (lb_index0); ASSERT (lb0->lb_n_buckets > 0); ASSERT (is_pow2 (lb0->lb_n_buckets)); @@ -637,7 +668,12 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, dpo0 = load_balance_get_bucket_i (lb0, 0); if (dpo_is_hicn (dpo0)) - next[0] = HICN_DATA_INPUT_IP4_NEXT_FACE; + { + next[0] = (ip_lookup_next_t) HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; + hicnb0->dpo_ctx_id = dpo0->dpoi_index; + hicn_data_input_set_adj_index ( + b[0], &dst_addr0, hicn_strategy_dpo_ctx_get (dpo0->dpoi_index)); + } else next[0] = HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL; @@ -651,9 +687,8 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, t->isv6 = 0; } - vlib_increment_combined_counter (cm, thread_index, lbi0, 1, - vlib_buffer_length_in_chain (vm, - b[0])); + vlib_increment_combined_counter (cm, thread_index, lb_index0, 1, + vlib_buffer_length_in_chain (vm, b[0])); b += 1; next += 1; @@ -668,30 +703,22 @@ hicn_data_input_ip4_fn (vlib_main_t * vm, return frame->n_vectors; } -/* *INDENT-OFF* */ -VLIB_REGISTER_NODE(hicn_data_input_ip4) = - { - .function = hicn_data_input_ip4_fn, - .name = "hicn-data-input-ip4", - .vector_size = sizeof(u32), - .format_trace = format_hicn_data_input_trace, - .type = VLIB_NODE_TYPE_INTERNAL, - .n_errors = ARRAY_LEN(hicn_data_input_error_strings), - .error_strings = hicn_data_input_error_strings, - .n_next_nodes = HICN_DATA_INPUT_IP4_N_NEXT, - .next_nodes = - { - [HICN_DATA_INPUT_IP4_NEXT_FACE] = "hicn4-face-input", - [HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL] = "ip4-local-end-of-arc" - }, - }; -/* *INDENT-ON* */ - -/* *INDENT-OFF* */ -VNET_FEATURE_INIT(hicn_data_input_ip4_arc, static)= - { - .arc_name = "ip4-local", - .node_name = "hicn-data-input-ip4", - .runs_before = VNET_FEATURES("ip4-local-end-of-arc"), - }; -/* *INDENT-ON* */ +VLIB_REGISTER_NODE (hicn_data_input_ip4) = { + .function = hicn_data_input_ip4_fn, + .name = "hicn-data-input-ip4", + .vector_size = sizeof (u32), + .format_trace = format_hicn_data_input_trace, + .type = VLIB_NODE_TYPE_INTERNAL, + .n_errors = ARRAY_LEN (hicn_data_input_error_strings), + .error_strings = hicn_data_input_error_strings, + .n_next_nodes = HICN_DATA_INPUT_IP4_N_NEXT, + .next_nodes = { [HICN_DATA_INPUT_IP4_NEXT_FACE] = "hicn4-face-input", + [HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL] = + "ip4-local-end-of-arc" }, +}; + +VNET_FEATURE_INIT (hicn_data_input_ip4_arc, static) = { + .arc_name = "ip4-local", + .node_name = "hicn-data-input-ip4", + .runs_before = VNET_FEATURES ("ip4-local-end-of-arc"), +};
\ No newline at end of file |