[PATCH 1/2] UUID: set multicast bit in pseudo-random MAC address

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Andrew Morton <akpm@...>
Cc: <linux-kernel@...>, <Valdis.Kletnieks@...>
Date: Saturday, October 20, 2007 - 3:58 pm

Fix a bug in the current random UUID generator:

Section 4.1.6 of RFC 4122 states regarding the "NodeID" of a UUID:
:  For systems with no IEEE address, a randomly or pseudo-randomly
:  generated value may be used; see Section 4.5.  The multicast bit must
:  be set in such addresses, in order that they will never conflict with
:  addresses obtained from network cards. 

So up to now it was just pure ("random") luck if this bit was set or not.
This tiny patch sets the bit explicitely.

Signed-off-by: Helge Deller <deller@gmx.de>
CC:  Valdis.Kletnieks@vt.edu

 random.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1157,6 +1158,8 @@ void generate_random_uuid(unsigned char uuid_out[16])
 	uuid_out[6] = (uuid_out[6] & 0x0F) | 0x40;
 	/* Set the UUID variant to DCE */
 	uuid_out[8] = (uuid_out[8] & 0x3F) | 0x80;
+	/* Set multicast bit to avoid conflicts with NIC MAC addresses */
+	uuid_out[10] |= 0x80;
 }
 
 EXPORT_SYMBOL(generate_random_uuid);
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/2] Time-based RFC 4122 UUID generator, Helge Deller, (Sat Oct 20, 3:39 pm)
[PATCH 1/2] UUID: set multicast bit in pseudo-random MAC add..., Helge Deller, (Sat Oct 20, 3:58 pm)
[PATCH 2/2] UUID: Time-based RFC 4122 UUID generator, Helge Deller, (Sat Oct 20, 4:00 pm)