From: Ben Pfaff Date: Tue, 23 Dec 2008 23:03:37 +0000 (-0800) Subject: Make flow_hash() use hash_lookup3(), for speed and hash quality. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8359ea154cb5e0b932e30f60edb5897dbc381c92;p=openvswitch Make flow_hash() use hash_lookup3(), for speed and hash quality. --- diff --git a/lib/flow.c b/lib/flow.c index 5fddf1fe..8b05b0a5 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -227,8 +227,11 @@ flow_compare(const struct flow *a, const struct flow *b) return memcmp(a, b, sizeof *a); } -unsigned long int -flow_hash(const struct flow *flow, uint32_t basis) +size_t +flow_hash(const struct flow *flow, uint32_t basis) { - return hash_fnv(flow, sizeof *flow, basis); + BUILD_ASSERT_DECL(!(sizeof *flow % sizeof(uint32_t))); + return hash_lookup3((const uint32_t *) flow, + sizeof *flow / sizeof(uint32_t), basis); } + diff --git a/lib/flow.h b/lib/flow.h index 0a952f9b..1d7becf3 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -56,11 +56,11 @@ struct flow { uint8_t nw_proto; /* IP protocol. */ uint8_t reserved; /* Pad to 32-bit alignment. */ }; -BUILD_ASSERT_DECL(sizeof (struct flow) == 32); +BUILD_ASSERT_DECL(sizeof(struct flow) == 32); int flow_extract(struct ofpbuf *, uint16_t in_port, struct flow *); void flow_print(FILE *, const struct flow *); int flow_compare(const struct flow *, const struct flow *); -unsigned long int flow_hash(const struct flow *, uint32_t basis); +size_t flow_hash(const struct flow *, uint32_t basis); #endif /* flow.h */