summaryrefslogtreecommitdiff
path: root/lib/odp-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/odp-util.c')
-rw-r--r--lib/odp-util.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/odp-util.c b/lib/odp-util.c
index d6cb9e62a..122572415 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -6435,11 +6435,20 @@ odp_key_to_dp_packet(const struct nlattr *key, size_t key_len,
}
}
-uint32_t
-odp_flow_key_hash(const struct nlattr *key, size_t key_len)
+/* Places the hash of the 'key_len' bytes starting at 'key' into '*hash'.
+ * Generated value has format of random UUID. */
+void
+odp_flow_key_hash(const void *key, size_t key_len, ovs_u128 *hash)
{
- BUILD_ASSERT_DECL(!(NLA_ALIGNTO % sizeof(uint32_t)));
- return hash_bytes32(ALIGNED_CAST(const uint32_t *, key), key_len, 0);
+ static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
+ static uint32_t secret;
+
+ if (ovsthread_once_start(&once)) {
+ secret = random_uint32();
+ ovsthread_once_done(&once);
+ }
+ hash_bytes128(key, key_len, secret, hash);
+ uuid_set_bits_v4((struct uuid *)hash);
}
static void