From 3e3eda957144b07379c8376b42cfcd1b634e1a48 Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Mon, 23 May 2011 11:39:17 -0700 Subject: [PATCH] flow: flow_hash_symmetric_l4() don't hash UDP ports. There is no reason to believe that the source and destination ports will be symmetric in a bidirectional UDP stream. This patch no longer uses them for symmetric hashing. --- lib/flow.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/flow.c b/lib/flow.c index 0a0e9f564..534a39975 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -750,10 +750,13 @@ flow_hash_symmetric_l4(const struct flow *flow, uint32_t basis) } fields.vlan_tci = flow->vlan_tci & htons(VLAN_VID_MASK); fields.eth_type = flow->dl_type; + + /* UDP source and destination port are not taken into account because they + * will not necessarily be symmetric in a bidirectional flow. */ if (fields.eth_type == htons(ETH_TYPE_IP)) { fields.ipv4_addr = flow->nw_src ^ flow->nw_dst; fields.ip_proto = flow->nw_proto; - if (fields.ip_proto == IPPROTO_TCP || fields.ip_proto == IPPROTO_UDP) { + if (fields.ip_proto == IPPROTO_TCP) { fields.tp_addr = flow->tp_src ^ flow->tp_dst; } } else if (fields.eth_type == htons(ETH_TYPE_IPV6)) { @@ -765,7 +768,7 @@ flow_hash_symmetric_l4(const struct flow *flow, uint32_t basis) ipv6_addr[i] = a[i] ^ b[i]; } fields.ip_proto = flow->nw_proto; - if (fields.ip_proto == IPPROTO_TCP || fields.ip_proto == IPPROTO_UDP) { + if (fields.ip_proto == IPPROTO_TCP) { fields.tp_addr = flow->tp_src ^ flow->tp_dst; } } -- 2.43.0