Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 05 Nov 2013 15:18:29 -0700
From:      Ian Lepore <ian@FreeBSD.org>
To:        John-Mark Gurney <jmg@funkthat.com>
Cc:        FreeBSD Stable List <freebsd-stable@FreeBSD.org>, Dan Nelson <dnelson@allantgroup.com>, "illoai@gmail.com" <illoai@gmail.com>, "freebsd-virtualization@freebsd.org" <freebsd-virtualization@FreeBSD.org>
Subject:   Re: how is the MAC for tap(4) computed?
Message-ID:  <1383689909.31172.169.camel@revolution.hippie.lan>
In-Reply-To: <20131105182435.GT73243@funkthat.com>
References:  <CAGBxaXn27u3J6iJBoDkW_R2=_kcHzSBU=d0v5eDUvnoAsucSjw@mail.gmail.com> <20131104170955.GH63947@dan.emsphone.com> <CAHHBGkpwWSbRxPxhvGwwzTB5SU-dNi9PfeCuOBUB82thspHEtQ@mail.gmail.com> <20131105182435.GT73243@funkthat.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <dnelson@allantgroup.com> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1383689909.31172.169.camel>