From owner-freebsd-virtualization@FreeBSD.ORG Tue Nov 5 22:18:34 2013 Return-Path: Delivered-To: freebsd-virtualization@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 41A8B74C; Tue, 5 Nov 2013 22:18:34 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mho-02-ewr.mailhop.org (mho-02-ewr.mailhop.org [204.13.248.72]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 158552B76; Tue, 5 Nov 2013 22:18:33 +0000 (UTC) Received: from c-24-8-230-52.hsd1.co.comcast.net ([24.8.230.52] helo=damnhippie.dyndns.org) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1VdoxE-0009E9-T6; Tue, 05 Nov 2013 22:18:33 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id rA5MITwD062380; Tue, 5 Nov 2013 15:18:30 -0700 (MST) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 24.8.230.52 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX1+L3V4L71c3Q2PQ9Ds8/kEn Subject: Re: how is the MAC for tap(4) computed? From: Ian Lepore To: John-Mark Gurney In-Reply-To: <20131105182435.GT73243@funkthat.com> References: <20131104170955.GH63947@dan.emsphone.com> <20131105182435.GT73243@funkthat.com> Content-Type: text/plain; charset="us-ascii" Date: Tue, 05 Nov 2013 15:18:29 -0700 Message-ID: <1383689909.31172.169.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: FreeBSD Stable List , Dan Nelson , "illoai@gmail.com" , "freebsd-virtualization@freebsd.org" X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Nov 2013 22:18:34 -0000 On Tue, 2013-11-05 at 10:24 -0800, John-Mark Gurney wrote: > illoai@gmail.com wrote this message on Mon, Nov 04, 2013 at 16:08 -0500: > > On 4 November 2013 12:09, Dan Nelson wrote: > > > In the last episode (Nov 04), Aryeh Friedman said: > > >> There seems to be a very high rate of MAC address collisions when tap is > > >> running on different machines.... is there anyway to make the selection > > >> of MAC more random > > > > > > It looks like it's generated based on the number of ticks since boot, plus > > > the unit number of the tap device: > > > > > > http://fxr.watson.org/fxr/source/net/if_tap.c#L434 > > > > > > So if you have devices created on boot on a bunch of machines, chances are > > > high that you'll get conflicts. Maybe instead of using the 'ticks' value, > > > kern.hostid could be used instead? That has much better randomness than > > > 'ticks'. > > > > With physical interfaces you can use something like > > ifconfig ath0 ether 00:2d:44:88:ff:00 > > (assuming the device & the driver support changing MAC > > addresses) > > > > I've never tried it with a virtual interface, but it should work if the > > device supports it. > > But remeber when choosing an address like that, that you set the second > low bit of the first octect to one to designate that it's a locally > administered address... > > See wikipedia for more info: > https://en.wikipedia.org/wiki/MAC_address#Address_details > Several ethernet drivers for embedded systems have logic to cook up a random address (probably it should be commonized somewhere) in which they set the first 3 bytes to 'b','s','d' and the low bytes to a random number. The nifty thing about the value 62:73:64 (beside that it's bsd) is that it sets the locally-administered bit in the address. -- Ian