diff options
| author | Liran Schour <lirans@il.ibm.com> | 2016-07-12 09:15:40 +0300 |
|---|---|---|
| committer | Ben Pfaff <blp@ovn.org> | 2016-07-13 14:25:08 -0700 |
| commit | c09cb861c0186ce051f46a81d4bd3daa2eeae98f (patch) | |
| tree | 2c7cabc8fbef88de348a4f04e77a7ae5efcf9bd1 | |
| parent | 63a10e1e4c48c314f002112f45e4a03b0db2357c (diff) | |
| download | openvswitch-c09cb861c0186ce051f46a81d4bd3daa2eeae98f.tar.gz | |
ofproto: Fix consistent hashing
Hashing will not be consistent as long as we use for hashing the index of the
bucket in the list (for remove/insert of buckets not from/to the end of the
bucket list).
Use bucket_id for hashing instead.
Signed-off-by: Liran Schour <lirans@il.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Simon Horman <simon.horman@netronome.com>
| -rw-r--r-- | ofproto/ofproto-dpif-xlate.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 16fcea3f1..3ff7a6b66 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -1558,7 +1558,6 @@ group_best_live_bucket(const struct xlate_ctx *ctx, { struct ofputil_bucket *best_bucket = NULL; uint32_t best_score = 0; - int i = 0; struct ofputil_bucket *bucket; const struct ovs_list *buckets; @@ -1566,13 +1565,13 @@ group_best_live_bucket(const struct xlate_ctx *ctx, group_dpif_get_buckets(group, &buckets); LIST_FOR_EACH (bucket, list_node, buckets) { if (bucket_is_alive(ctx, bucket, 0)) { - uint32_t score = (hash_int(i, basis) & 0xffff) * bucket->weight; + uint32_t score = + (hash_int(bucket->bucket_id, basis) & 0xffff) * bucket->weight; if (score >= best_score) { best_bucket = bucket; best_score = score; } } - i++; } return best_bucket; |
