Skip to content

Conversation

@yomimono
Copy link
Contributor

Fixes #23 .

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.

@yomimono
Copy link
Contributor Author

(who's got two thumbs and no merge rights for this repository? this guy)

@avsm
Copy link
Member

avsm commented May 17, 2016

look again, young padawan, search inside your merge rights and spot the mutable force

@yomimono yomimono merged commit 74e260c into mirage:master May 17, 2016
@yomimono yomimono deleted the self-init-random branch October 24, 2016 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants