nx-match: Fix distribution of hash function for NXM/OXM headers.
authorBen Pfaff <blp@nicira.com>
Wed, 24 Jun 2015 18:17:12 +0000 (11:17 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 24 Jun 2015 18:24:34 +0000 (11:24 -0700)
NXM/OXM headers as represented in this file are 64-bit long and the low
bits are essentially constant (almost always 0) so using hash_int(),
which takes an uint32_t, is going to be a useless hash function.  This
commit fixes the problem.

Found by inspection.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
lib/nx-match.c

index 21f291c..0560370 100644 (file)
@@ -1893,7 +1893,7 @@ nxm_init(void)
         for (struct nxm_field_index *nfi = all_nxm_fields;
              nfi < &all_nxm_fields[ARRAY_SIZE(all_nxm_fields)]; nfi++) {
             hmap_insert(&nxm_header_map, &nfi->header_node,
-                        hash_int(nfi->nf.header, 0));
+                        hash_uint64(nfi->nf.header));
             hmap_insert(&nxm_name_map, &nfi->name_node,
                         hash_string(nfi->nf.name, 0));
             list_push_back(&nxm_mf_map[nfi->nf.id], &nfi->mf_node);
@@ -1912,7 +1912,7 @@ nxm_field_by_header(uint64_t header)
         header = nxm_make_exact_header(header);
     }
 
-    HMAP_FOR_EACH_IN_BUCKET (nfi, header_node, hash_int(header, 0),
+    HMAP_FOR_EACH_IN_BUCKET (nfi, header_node, hash_uint64(header),
                              &nxm_header_map) {
         if (header == nfi->nf.header) {
             return &nfi->nf;