Skip to content

Commit

Permalink
nx-match: Fix distribution of hash function for NXM/OXM headers.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Jesse Gross <[email protected]>
  • Loading branch information
blp committed Jun 24, 2015
1 parent 885648d commit 6016cd3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/nx-match.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 6016cd3

Please sign in to comment.