diff options
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/dpo/lookup_dpo.c | 51 | ||||
-rw-r--r-- | src/vnet/fib/ip4_fib.h | 44 | ||||
-rw-r--r-- | src/vnet/ip/ip4_forward.c | 32 | ||||
-rw-r--r-- | src/vnet/ip/ip4_forward.h | 59 |
4 files changed, 61 insertions, 125 deletions
diff --git a/src/vnet/dpo/lookup_dpo.c b/src/vnet/dpo/lookup_dpo.c index 3f34cefe0c4..9ce94eebe5c 100644 --- a/src/vnet/dpo/lookup_dpo.c +++ b/src/vnet/dpo/lookup_dpo.c @@ -268,50 +268,6 @@ lookup_dpo_unlock (dpo_id_t *dpo) } } -always_inline void -ip4_src_fib_lookup_one (u32 src_fib_index0, - const ip4_address_t * addr0, - u32 * src_adj_index0) -{ - ip4_fib_mtrie_leaf_t leaf0; - ip4_fib_mtrie_t * mtrie0; - - mtrie0 = &ip4_fib_get (src_fib_index0)->mtrie; - - leaf0 = ip4_fib_mtrie_lookup_step_one (mtrie0, addr0); - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, addr0, 2); - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, addr0, 3); - - src_adj_index0[0] = ip4_fib_mtrie_leaf_get_adj_index (leaf0); -} - -always_inline void -ip4_src_fib_lookup_two (u32 src_fib_index0, - u32 src_fib_index1, - const ip4_address_t * addr0, - const ip4_address_t * addr1, - u32 * src_adj_index0, - u32 * src_adj_index1) -{ - ip4_fib_mtrie_leaf_t leaf0, leaf1; - ip4_fib_mtrie_t * mtrie0, * mtrie1; - - mtrie0 = &ip4_fib_get (src_fib_index0)->mtrie; - mtrie1 = &ip4_fib_get (src_fib_index1)->mtrie; - - leaf0 = ip4_fib_mtrie_lookup_step_one (mtrie0, addr0); - leaf1 = ip4_fib_mtrie_lookup_step_one (mtrie1, addr1); - - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, addr0, 2); - leaf1 = ip4_fib_mtrie_lookup_step (mtrie1, leaf1, addr1, 2); - - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, addr0, 3); - leaf1 = ip4_fib_mtrie_lookup_step (mtrie1, leaf1, addr1, 3); - - src_adj_index0[0] = ip4_fib_mtrie_leaf_get_adj_index (leaf0); - src_adj_index1[0] = ip4_fib_mtrie_leaf_get_adj_index (leaf1); -} - /** * @brief Lookup trace data */ @@ -435,9 +391,8 @@ lookup_dpo_ip4_inline (vlib_main_t * vm, } /* do lookup */ - ip4_src_fib_lookup_two (fib_index0, fib_index1, - input_addr0, input_addr1, - &lbi0, &lbi1); + ip4_fib_forwarding_lookup_x2 (fib_index0, fib_index1, input_addr0, + input_addr1, &lbi0, &lbi1); lb0 = load_balance_get(lbi0); lb1 = load_balance_get(lbi1); @@ -573,7 +528,7 @@ lookup_dpo_ip4_inline (vlib_main_t * vm, } /* do lookup */ - ip4_src_fib_lookup_one (fib_index0, input_addr, &lbi0); + lbi0 = ip4_fib_forwarding_lookup (fib_index0, input_addr); lb0 = load_balance_get(lbi0); vnet_buffer(b0)->sw_if_index[VLIB_TX] = fib_index0; diff --git a/src/vnet/fib/ip4_fib.h b/src/vnet/fib/ip4_fib.h index 7d17baf2545..dc41eb8163f 100644 --- a/src/vnet/fib/ip4_fib.h +++ b/src/vnet/fib/ip4_fib.h @@ -197,5 +197,47 @@ ip4_fib_forwarding_lookup_x2 (u32 fib_index0, *lb1 = ip4_fib_mtrie_leaf_get_adj_index(leaf[1]); } -#endif +static_always_inline void +ip4_fib_forwarding_lookup_x4 (u32 fib_index0, + u32 fib_index1, + u32 fib_index2, + u32 fib_index3, + const ip4_address_t * addr0, + const ip4_address_t * addr1, + const ip4_address_t * addr2, + const ip4_address_t * addr3, + index_t *lb0, + index_t *lb1, + index_t *lb2, + index_t *lb3) +{ + ip4_fib_mtrie_leaf_t leaf[4]; + ip4_fib_mtrie_t * mtrie[4]; + + mtrie[0] = &ip4_fib_get(fib_index0)->mtrie; + mtrie[1] = &ip4_fib_get(fib_index1)->mtrie; + mtrie[2] = &ip4_fib_get(fib_index2)->mtrie; + mtrie[3] = &ip4_fib_get(fib_index3)->mtrie; + + leaf[0] = ip4_fib_mtrie_lookup_step_one (mtrie[0], addr0); + leaf[1] = ip4_fib_mtrie_lookup_step_one (mtrie[1], addr1); + leaf[2] = ip4_fib_mtrie_lookup_step_one (mtrie[2], addr2); + leaf[3] = ip4_fib_mtrie_lookup_step_one (mtrie[3], addr3); + + leaf[0] = ip4_fib_mtrie_lookup_step (mtrie[0], leaf[0], addr0, 2); + leaf[1] = ip4_fib_mtrie_lookup_step (mtrie[1], leaf[1], addr1, 2); + leaf[2] = ip4_fib_mtrie_lookup_step (mtrie[2], leaf[2], addr2, 2); + leaf[3] = ip4_fib_mtrie_lookup_step (mtrie[3], leaf[3], addr3, 2); + + leaf[0] = ip4_fib_mtrie_lookup_step (mtrie[0], leaf[0], addr0, 3); + leaf[1] = ip4_fib_mtrie_lookup_step (mtrie[1], leaf[1], addr1, 3); + leaf[2] = ip4_fib_mtrie_lookup_step (mtrie[2], leaf[2], addr2, 3); + leaf[3] = ip4_fib_mtrie_lookup_step (mtrie[3], leaf[3], addr3, 3); + + *lb0 = ip4_fib_mtrie_leaf_get_adj_index(leaf[0]); + *lb1 = ip4_fib_mtrie_leaf_get_adj_index(leaf[1]); + *lb2 = ip4_fib_mtrie_leaf_get_adj_index(leaf[2]); + *lb3 = ip4_fib_mtrie_leaf_get_adj_index(leaf[3]); +} +#endif diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index be381718312..ea67005176f 100644 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -1517,8 +1517,6 @@ static inline void ip4_local_check_src (vlib_buffer_t * b, ip4_header_t * ip0, ip4_local_last_check_t * last_check, u8 * error0) { - ip4_fib_mtrie_leaf_t leaf0; - ip4_fib_mtrie_t *mtrie0; const dpo_id_t *dpo0; load_balance_t *lb0; u32 lbi0; @@ -1536,11 +1534,8 @@ ip4_local_check_src (vlib_buffer_t * b, ip4_header_t * ip0, if (PREDICT_TRUE (last_check->src.as_u32 != ip0->src_address.as_u32) || last_check->first) { - mtrie0 = &ip4_fib_get (vnet_buffer (b)->ip.fib_index)->mtrie; - leaf0 = ip4_fib_mtrie_lookup_step_one (mtrie0, &ip0->src_address); - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, &ip0->src_address, 2); - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, &ip0->src_address, 3); - lbi0 = ip4_fib_mtrie_leaf_get_adj_index (leaf0); + lbi0 = ip4_fib_forwarding_lookup (vnet_buffer (b)->ip.fib_index, + &ip0->src_address); vnet_buffer (b)->ip.adj_index[VLIB_RX] = vnet_buffer (b)->ip.adj_index[VLIB_TX]; @@ -1586,8 +1581,6 @@ static inline void ip4_local_check_src_x2 (vlib_buffer_t ** b, ip4_header_t ** ip, ip4_local_last_check_t * last_check, u8 * error) { - ip4_fib_mtrie_leaf_t leaf[2]; - ip4_fib_mtrie_t *mtrie[2]; const dpo_id_t *dpo[2]; load_balance_t *lb[2]; u32 not_last_hit; @@ -1615,24 +1608,9 @@ ip4_local_check_src_x2 (vlib_buffer_t ** b, ip4_header_t ** ip, */ if (PREDICT_TRUE (not_last_hit)) { - mtrie[0] = &ip4_fib_get (vnet_buffer (b[0])->ip.fib_index)->mtrie; - mtrie[1] = &ip4_fib_get (vnet_buffer (b[1])->ip.fib_index)->mtrie; - - leaf[0] = ip4_fib_mtrie_lookup_step_one (mtrie[0], &ip[0]->src_address); - leaf[1] = ip4_fib_mtrie_lookup_step_one (mtrie[1], &ip[1]->src_address); - - leaf[0] = ip4_fib_mtrie_lookup_step (mtrie[0], leaf[0], - &ip[0]->src_address, 2); - leaf[1] = ip4_fib_mtrie_lookup_step (mtrie[1], leaf[1], - &ip[1]->src_address, 2); - - leaf[0] = ip4_fib_mtrie_lookup_step (mtrie[0], leaf[0], - &ip[0]->src_address, 3); - leaf[1] = ip4_fib_mtrie_lookup_step (mtrie[1], leaf[1], - &ip[1]->src_address, 3); - - lbi[0] = ip4_fib_mtrie_leaf_get_adj_index (leaf[0]); - lbi[1] = ip4_fib_mtrie_leaf_get_adj_index (leaf[1]); + ip4_fib_forwarding_lookup_x2 ( + vnet_buffer (b[0])->ip.fib_index, vnet_buffer (b[1])->ip.fib_index, + &ip[0]->src_address, &ip[1]->src_address, &lbi[0], &lbi[1]); vnet_buffer (b[0])->ip.adj_index[VLIB_RX] = vnet_buffer (b[0])->ip.adj_index[VLIB_TX]; diff --git a/src/vnet/ip/ip4_forward.h b/src/vnet/ip/ip4_forward.h index 8779d2ded6b..54150d4dab4 100644 --- a/src/vnet/ip/ip4_forward.h +++ b/src/vnet/ip/ip4_forward.h @@ -74,8 +74,6 @@ ip4_lookup_inline (vlib_main_t * vm, { 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 *dst_addr0, *dst_addr1, *dst_addr2, *dst_addr3; u32 lb_index0, lb_index1, lb_index2, lb_index3; flow_hash_config_t flow_hash_config0, flow_hash_config1; @@ -112,30 +110,11 @@ ip4_lookup_inline (vlib_main_t * vm, 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, dst_addr0); - leaf1 = ip4_fib_mtrie_lookup_step_one (mtrie1, dst_addr1); - leaf2 = ip4_fib_mtrie_lookup_step_one (mtrie2, dst_addr2); - leaf3 = ip4_fib_mtrie_lookup_step_one (mtrie3, dst_addr3); - - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, dst_addr0, 2); - leaf1 = ip4_fib_mtrie_lookup_step (mtrie1, leaf1, dst_addr1, 2); - leaf2 = ip4_fib_mtrie_lookup_step (mtrie2, leaf2, dst_addr2, 2); - leaf3 = ip4_fib_mtrie_lookup_step (mtrie3, leaf3, dst_addr3, 2); - - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, dst_addr0, 3); - leaf1 = ip4_fib_mtrie_lookup_step (mtrie1, leaf1, dst_addr1, 3); - leaf2 = ip4_fib_mtrie_lookup_step (mtrie2, leaf2, dst_addr2, 3); - leaf3 = ip4_fib_mtrie_lookup_step (mtrie3, leaf3, dst_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, + dst_addr0, dst_addr1, dst_addr2, dst_addr3, &lb_index0, &lb_index1, + &lb_index2, &lb_index3); ASSERT (lb_index0 && lb_index1 && lb_index2 && lb_index3); lb0 = load_balance_get (lb_index0); @@ -245,8 +224,6 @@ ip4_lookup_inline (vlib_main_t * vm, { 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 *dst_addr0, *dst_addr1; u32 lb_index0, lb_index1; flow_hash_config_t flow_hash_config0, flow_hash_config1; @@ -271,20 +248,9 @@ ip4_lookup_inline (vlib_main_t * vm, 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, dst_addr0); - leaf1 = ip4_fib_mtrie_lookup_step_one (mtrie1, dst_addr1); - - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, dst_addr0, 2); - leaf1 = ip4_fib_mtrie_lookup_step (mtrie1, leaf1, dst_addr1, 2); - - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, dst_addr0, 3); - leaf1 = ip4_fib_mtrie_lookup_step (mtrie1, leaf1, dst_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, + dst_addr0, dst_addr1, &lb_index0, &lb_index1); ASSERT (lb_index0 && lb_index1); lb0 = load_balance_get (lb_index0); @@ -348,8 +314,6 @@ ip4_lookup_inline (vlib_main_t * vm, { ip4_header_t *ip0; const load_balance_t *lb0; - ip4_fib_mtrie_t *mtrie0; - ip4_fib_mtrie_leaf_t leaf0; ip4_address_t *dst_addr0; u32 lbi0; flow_hash_config_t flow_hash_config0; @@ -360,11 +324,8 @@ ip4_lookup_inline (vlib_main_t * vm, 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, dst_addr0); - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, dst_addr0, 2); - leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, dst_addr0, 3); - lbi0 = ip4_fib_mtrie_leaf_get_adj_index (leaf0); + lbi0 = ip4_fib_forwarding_lookup (vnet_buffer (b[0])->ip.fib_index, + dst_addr0); ASSERT (lbi0); lb0 = load_balance_get (lbi0); |