Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/netif.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ let err_partial_write len' page =

let connect devname =
try
Random.self_init ();
let fd, devname = Tuntap.opentap ~pi:false ~devname () in
let dev = Lwt_unix.of_unix_file_descr ~blocking:true fd in
let mac = Macaddr.make_local (fun _ -> Random.int 256) in
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, a completely random MAC is a bad idea. MAC addresses are structured and we should make sure that the globally-unique/link-local and unicast/multicast bits of the OUI are set as expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI some MAC related stuff here:
https://github.com/xapi-project/xenopsd/blob/900f9ec3251fd9850a1326a3617a73639a10c01c/lib/mac.ml#L32

On Mon, May 16, 2016 at 4:31 PM, Mindy Preston notifications@github.com
wrote:

In lib/netif.ml
#24 (comment):

@@ -67,6 +67,7 @@ let err_partial_write len' page =

let connect devname =
try

  • Random.self_init ();
    let fd, devname = Tuntap.opentap ~pi:false ~devname () in
    let dev = Lwt_unix.of_unix_file_descr ~blocking:true fd in
    let mac = Macaddr.make_local (fun _ -> Random.int 256) in

On second thought, a completely random MAC is a bad idea. MAC addresses
are structured and we should make sure that the globally-unique/link-local
and unicast/multicast bits of the OUI are set as expected.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
https://github.com/mirage/mirage-net-unix/pull/24/files/b3aed3776ca65fbe6da916755292b6163d54c181#r63372705

Dave Scott

Copy link
Contributor Author

@yomimono yomimono May 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like Macaddr.make_local does the right thing here, so the patch as written should be OK: https://github.com/mirage/ocaml-ipaddr/blob/master/lib/macaddr.ml#L121

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yomimono +1, Macaddr.make_local of random bits is fine.

Expand Down