From 1efebb132ce201bd94c458c67f7383fc29d39bf7 Mon Sep 17 00:00:00 2001
From: Srini Seetharaman <srini.seetharaman@gmail.com>
Date: Thu, 14 Aug 2014 21:56:24 -0700
Subject: [PATCH] Changing hash used for selecting bucket to pay attention to
 L2, L3 and L4 fields, instead of just the dl_dst field.

Signed-off-by: Srini Seetharaman <srini.seetharaman@gmail.com>
---
 ofproto/ofproto-dpif-xlate.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 4aedb59..be16092 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -2739,10 +2739,24 @@ xlate_select_group(struct xlate_ctx *ctx, struct group_dpif *group)
     struct ofputil_bucket *bucket;
     uint32_t basis;
 
-    basis = hash_mac(ctx->xin->flow.dl_dst, 0, 0);
+    /* Hashing based on all L2, L3 and L4 fields
+     */
+    basis = flow_hash_symmetric_l4(&ctx->xin->flow, 0);
     bucket = group_best_live_bucket(ctx, group, basis);
     if (bucket) {
+        /* Since flow_hash_symmetric_l4() looks at all fields,
+         * we require matching on all fields used for the hash.
+         */
         memset(&wc->masks.dl_dst, 0xff, sizeof wc->masks.dl_dst);
+        memset(&wc->masks.dl_src, 0xff, sizeof wc->masks.dl_src);
+        memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
+        memset(&wc->masks.nw_dst, 0xff, sizeof wc->masks.nw_dst);
+        memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto);
+        memset(&wc->masks.nw_src, 0xff, sizeof wc->masks.nw_src);
+        memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst);
+        memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src);
+        memset(&wc->masks.vlan_tci, 0xff, sizeof wc->masks.vlan_tci);
+
         xlate_group_bucket(ctx, bucket);
         xlate_group_stats(ctx, group, bucket);
     }
-- 
1.9.1

