vxlan: reuse inner packet flow hash for tunnel outer header load balance
Type: fix
Several tunnels encapsulation use udp as outer header and udp src port
is set by inner header flow hash, such as gtpu, geneve, vxlan, vxlan-gbd
Since flow hash of inner header is already been calculated, keeping it
to vnet_buffere[b]->ip.flow_hash should save load-balance node work to
select ECMP uplinks.
Change-Id: I0e4e2b27178f4fcc5785e221d6d1f3e8747d0d59
Signed-off-by: Shawn Ji <xiaji@tethrnet.com>
diff --git a/src/vnet/vxlan/encap.c b/src/vnet/vxlan/encap.c
index eec460d..da890b2 100644
--- a/src/vnet/vxlan/encap.c
+++ b/src/vnet/vxlan/encap.c
@@ -287,6 +287,10 @@
udp1->checksum = 0xffff;
}
+ /* save inner packet flow_hash for load-balance node */
+ vnet_buffer (b0)->ip.flow_hash = flow_hash0;
+ vnet_buffer (b1)->ip.flow_hash = flow_hash1;
+
if (sw_if_index0 == sw_if_index1)
{
vlib_increment_combined_counter (tx_counter, thread_index,
@@ -424,6 +428,9 @@
udp0->checksum = 0xffff;
}
+ /* reuse inner packet flow_hash for load-balance node */
+ vnet_buffer (b0)->ip.flow_hash = flow_hash0;
+
vlib_increment_combined_counter (tx_counter, thread_index,
sw_if_index0, 1, len0);
pkts_encapsulated ++;