[ovs-dev] [PATCH] datapath: Fix tunnel source port selection for mega flow

Andy Zhou azhou at nicira.com
Tue Jul 2 22:58:19 UTC 2013


Tunnel source port selection was based on hash value cached in the
flow. This no longer works with mega flow, since all flows matching
a mega flow will be transmitted with the same tunnel source port.

This patch computes the tunnel source port at run time based on each
incoming packet. Packets belong to the same micro flow would still get
the same source port, but multiple micro flows hitting the same mega flow
can get different source ports.

Packets injected from the usespace will be assigned to the same
source port as if they are forwarded in the kernel.

Bug #18216

Signed-off-by: Andy Zhou <azhou at nicira.com>
---
 datapath/tunnel.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/datapath/tunnel.c b/datapath/tunnel.c
index 9102786..18c3622 100644
--- a/datapath/tunnel.c
+++ b/datapath/tunnel.c
@@ -186,7 +186,9 @@ u16 ovs_tnl_get_src_port(struct sk_buff *skb)
 	int low;
 	int high;
 	unsigned int range;
-	u32 hash = OVS_CB(skb)->flow->hash;
+	struct sw_flow_key *pkt_key = OVS_CB(skb)->pkt_key;
+	u32 hash = jhash2((const u32 *)pkt_key,
+			0, sizeof(*pkt_key) / sizeof(u32));
 
 	inet_get_local_port_range(&low, &high);
 	range = (high - low) + 1;
-- 
1.7.9.5




More information about the dev mailing list