geneve: Remove one bucket load-balance objects 18/29918/2
authorNeale Ranns <nranns@cisco.com>
Thu, 12 Nov 2020 16:53:51 +0000 (16:53 +0000)
committerOle Tr�an <otroan@employees.org>
Tue, 17 Nov 2020 12:26:40 +0000 (12:26 +0000)
Type: improvement

geneve uses the UDP source port for the flow hash to get load-balancing
over multiple paths to the tunnel destination. However, if there is only
one path, then we can elide the LB object, contributed by the resolving
FIB entry, from the dasta path.

Signed-off-by: Neale Ranns <nranns@cisco.com>
Change-Id: I13a1bedc307a474d258a757bc1bae28564798730

src/plugins/geneve/geneve.c

index f991af9..2c6f1ff 100644 (file)
@@ -150,6 +150,18 @@ geneve_tunnel_restack_dpo (geneve_tunnel_t * t)
     FIB_FORW_CHAIN_TYPE_UNICAST_IP4 : FIB_FORW_CHAIN_TYPE_UNICAST_IP6;
 
   fib_entry_contribute_forwarding (t->fib_entry_index, forw_type, &dpo);
+
+  /* geneve uses the flow hash as the udp source port
+   * hence the packet's hash is unknown at this time.
+   * However, we can still skip single bucket load balance dpo's */
+  while (DPO_LOAD_BALANCE == dpo.dpoi_type)
+    {
+      load_balance_t *lb = load_balance_get (dpo.dpoi_index);
+      if (lb->lb_n_buckets > 1)
+       break;
+
+      dpo_copy (&dpo, load_balance_get_bucket_i (lb, 0));
+    }
   dpo_stack_from_node (encap_index, &t->next_dpo, &dpo);
   dpo_reset (&dpo);
 }