This patch sacrifices a few bits of hash quality from the 128-bit unique
flow identifiers to make the UFIDs RFC4122-conformant as per the version 4
(random) UUID spec. Given that the 128-bit space is already quite large,
this should not affect the spread of UFIDs in any meaningful way for
hashing.
Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
#include "tnl-arp-cache.h"
#include "tnl-ports.h"
#include "util.h"
+#include "uuid.h"
#include "valgrind.h"
#include "openvswitch/vlog.h"
ovsthread_once_done(&once);
}
hash_bytes128(key, key_len, secret, hash);
+ uuid_set_bits_v4((struct uuid *)hash);
}
/* Deletes all flows from 'dpif'. Returns 0 if successful, otherwise a
/* AES output is exactly 16 bytes, so we encrypt directly into 'uuid'. */
aes128_encrypt(&key, copy, uuid);
+ uuid_set_bits_v4(uuid);
+}
+
+void
+uuid_set_bits_v4(struct uuid *uuid)
+{
/* Set bits to indicate a random UUID. See RFC 4122 section 4.4. */
uuid->parts[2] &= ~0xc0000000;
uuid->parts[2] |= 0x80000000;
int uuid_compare_3way(const struct uuid *, const struct uuid *);
bool uuid_from_string(struct uuid *, const char *);
bool uuid_from_string_prefix(struct uuid *, const char *);
+void uuid_set_bits_v4(struct uuid *);
#endif /* uuid.h */