summaryrefslogtreecommitdiffstats
path: root/vnet/vnet/dpo/lookup_dpo.c
diff options
context:
space:
mode:
Diffstat (limited to 'vnet/vnet/dpo/lookup_dpo.c')
-rw-r--r--vnet/vnet/dpo/lookup_dpo.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/vnet/vnet/dpo/lookup_dpo.c b/vnet/vnet/dpo/lookup_dpo.c
index 0bfc0651a63..6e3f0792d07 100644
--- a/vnet/vnet/dpo/lookup_dpo.c
+++ b/vnet/vnet/dpo/lookup_dpo.c
@@ -292,12 +292,10 @@ lookup_dpo_ip4_inline (vlib_main_t * vm,
vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
- /* while (n_left_from >= 4 && n_left_to_next >= 2) */
- /* } */
-
while (n_left_from > 0 && n_left_to_next > 0)
{
- u32 bi0, lkdi0, lbi0, fib_index0, next0;
+ u32 bi0, lkdi0, lbi0, fib_index0, next0, hash_c0;
+ flow_hash_config_t flow_hash_config0;
const ip4_address_t *input_addr;
const load_balance_t *lb0;
const lookup_dpo_t * lkd0;
@@ -349,7 +347,20 @@ lookup_dpo_ip4_inline (vlib_main_t * vm,
/* do lookup */
ip4_src_fib_lookup_one (fib_index0, input_addr, &lbi0);
lb0 = load_balance_get(lbi0);
- dpo0 = load_balance_get_bucket_i(lb0, 0);
+
+ /* Use flow hash to compute multipath adjacency. */
+ hash_c0 = vnet_buffer (b0)->ip.flow_hash = 0;
+
+ if (PREDICT_FALSE (lb0->lb_n_buckets > 1))
+ {
+ flow_hash_config0 = lb0->lb_hash_config;
+ hash_c0 = vnet_buffer (b0)->ip.flow_hash =
+ ip4_compute_flow_hash (ip0, flow_hash_config0);
+ }
+
+ dpo0 = load_balance_get_bucket_i(lb0,
+ (hash_c0 &
+ (lb0->lb_n_buckets_minus_1)));
next0 = dpo0->dpoi_next_node;
vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
@@ -462,13 +473,10 @@ lookup_dpo_ip6_inline (vlib_main_t * vm,
vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
- /* while (n_left_from >= 4 && n_left_to_next >= 2) */
- /* { */
- /* } */
-
while (n_left_from > 0 && n_left_to_next > 0)
{
- u32 bi0, lkdi0, lbi0, fib_index0, next0;
+ u32 bi0, lkdi0, lbi0, fib_index0, next0, hash_c0;
+ flow_hash_config_t flow_hash_config0;
const ip6_address_t *input_addr0;
const load_balance_t *lb0;
const lookup_dpo_t * lkd0;
@@ -508,7 +516,20 @@ lookup_dpo_ip6_inline (vlib_main_t * vm,
fib_index0,
input_addr0);
lb0 = load_balance_get(lbi0);
- dpo0 = load_balance_get_bucket_i(lb0, 0);
+
+ /* Use flow hash to compute multipath adjacency. */
+ hash_c0 = vnet_buffer (b0)->ip.flow_hash = 0;
+
+ if (PREDICT_FALSE (lb0->lb_n_buckets > 1))
+ {
+ flow_hash_config0 = lb0->lb_hash_config;
+ hash_c0 = vnet_buffer (b0)->ip.flow_hash =
+ ip6_compute_flow_hash (ip0, flow_hash_config0);
+ }
+
+ dpo0 = load_balance_get_bucket_i(lb0,
+ (hash_c0 &
+ (lb0->lb_n_buckets_minus_1)));
next0 = dpo0->dpoi_next_node;
vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;