]> xenbits.xensource.com Git - xenclient/toolstack.git/commitdiff
Ensure generated ethernet addresses are unicast and locally-administered. Fix from...
authorPrashanth Mundkur <prashanth.mundkur@citrix.com>
Sat, 20 Jun 2009 00:02:40 +0000 (17:02 -0700)
committerPrashanth Mundkur <prashanth.mundkur@citrix.com>
Sat, 20 Jun 2009 00:02:40 +0000 (17:02 -0700)
xenvm/vmconfig.ml

index ddeeded4fcf148961c08500e214fbcd6009b8646..9405da8572378e8f774d87d31dc8906489fab9c0 100644 (file)
@@ -137,6 +137,11 @@ let config_nic_of_string vm_uuid s =
                        let s = String.create 2 in
                        s.[0] <- c1; s.[1] <- c2; s
                        in
+               let unicast_local h =
+                       let v = int_of_string ("0x" ^ (List.hd h)) in
+                       let n = sprintf "%02x" (0x2 lor (v land 0xfe)) in
+                       n :: (List.tl h)
+                       in
                let vector =
                        (if nic_id = -1 then [] else [ string_of_int nic_id ]) @
                        (match nic_model with None -> [] | Some x -> [ x ]) @
@@ -144,7 +149,7 @@ let config_nic_of_string vm_uuid s =
                        in
                let digest = Digest.to_hex (Digest.string (String.concat " " vector)) in
                let hexs = List.map (fun i -> s_of_c digest.[i] digest.[i + 12]) [ 0; 2; 1; 7; 6; 4 ] in
-               String.concat ":" hexs
+               String.concat ":" (unicast_local hexs)
                in
        let is_valid_mac s =
                let x = String.split ':' s in