flow: flow_hash_symmetric_l4() don't hash UDP ports.
authorEthan Jackson <ethan@nicira.com>
Mon, 23 May 2011 18:39:17 +0000 (11:39 -0700)
committerEthan Jackson <ethan@nicira.com>
Mon, 23 May 2011 20:21:14 +0000 (13:21 -0700)
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

index 0a0e9f564a0adefade186f6b8d4098449a4e3ad6..534a39975d19e23d8485666a6bfcb8bd3c95e326 100644 (file)
@@ -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;
         }
     }