From 5bc6241b420ba5ce0ff40f9456f0b8215d34f3fb Mon Sep 17 00:00:00 2001 From: Andy Zhou Date: Tue, 2 Jul 2013 15:58:19 -0700 Subject: [PATCH] datapath: Fix tunnel source port selection for mega flow 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 Signed-off-by: Jesse Gross --- datapath/tunnel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/datapath/tunnel.c b/datapath/tunnel.c index 910278686..ef46a69de 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, + sizeof(*pkt_key) / sizeof(u32), 0); inet_get_local_port_range(&low, &high); range = (high - low) + 1; -- 2.43.0