From: Larry Finger <Larry.Finger@lwfinger.net>
To: "Nicolas de Pesloüan" <nicolas.2p.debian@free.fr>
Cc: Michael Buesch <mb@bu3sch.de>,
Calvin Walton <calvin.walton@gmail.com>,
linux-wireless@vger.kernel.org, b43-dev@lists.infradead.org
Subject: [PATCH V2] ssb: Implement virtual SPROM on disk
Date: Sun, 28 Mar 2010 19:33:53 -0500 [thread overview]
Message-ID: <4BAFF571.1090706@lwfinger.net> (raw)
In-Reply-To: <4BAFA83B.8050505@free.fr>
On 03/28/2010 02:04 PM, Nicolas de Peslo?an wrote:
> Larry Finger wrote:
>> On 03/28/2010 12:14 PM, Nicolas de Peslo?an wrote:
>>> Larry Finger wrote:
>>> MACADDRESS=$(/bin/dd if=/dev/random bs=1 count=6 2>/dev/null |
>>> /usr/bin/od -tx1 |
>>> sed -ne '1{;s/0000000 //;s/^\(.\)[014589cd]/\12/;y/ /:/;p}'
>>
>> It also needs to be even as an odd value would be a broadcast address.
>> Using
>> only sed instead of head|cut|awk does have merit and the randomness is
>> increased
>> by 6 bits. It will take me a while to understand the sed here. Regular
>> expressions are not my thing.
>
> Yes, you are right, so I need to change a few things, in order to keep
> the highest possible level of randomness while ensuring the lower half
> of first byte is 2, 6, a or e.
>
> dd if=/dev/random bs=1 count=6 2>/dev/null |
> od -tx1 |
> sed -ne '1{;s/0000000 //;
> s/^\(.\)[013]/\12/;s/^\(.\)[457]/\16/;
> s/^\(.\)[89b]/\1a/;s/^\(.\)[cdf]/\1e/;
> y/ /:/;p}'
>
> Translation to humain form :
>
> # for the first line only,
> # If second char is 0, 1 or 3, replace it with 2.
> # If second char is 4, 5 or 7, replace it with 6.
> # If second char is 8, 9 or b, replace it with a.
> # If second char is c, d or f, replace it with e.
> # Replace all spaces with ':'.
> # print
> # Print nothing for other lines, thanks to -n option.
That is a lot of work for 2 extra bits, but thanks. I had changed the [014589cd]
of your original with [01345789bcdf], which resulted in X2 as the first byte for
most generated addresses.
>>> If DEVPATH is "generic" (wlan*), how would you distinguish between two
>>> broadcom NIC present in the system, both without an SPROM ?
>>
>> That is covered by the
>> /devices/pci0000:00/0000:00:0d.0/0000:04:00.0/... part of
>
> Ok, sounds good for me. Did you had the opportunity to test with two
> such devices ?
Yes. On a machine where I have two PCI versions of BCM43XX devices, one is
...00:08.0/... and the other is ...00:0a.0/... The generated rules are
SUBSYSTEM=="net", DEVPATH=="/devices/pci0000:00/0000:00:08.0/ssb0:0/net/wlan*",
ATTR{address}=="82:82:82:82:82:82", ENV{MAC_CHANGED}="yes", RUN+="/sbin/ifconfig
$env{INTERFACE} hw ether c2:e7:d3:d8:73:a8"
SUBSYSTEM=="net", DEVPATH=="/devices/pci0000:00/0000:00:0a.0/ssb1:0/net/wlan*",
ATTR{address}=="82:82:82:82:82:82", ENV{MAC_CHANGED}="yes", RUN+="/sbin/ifconfig
$env{INTERFACE} hw ether 02:56:31:dd:7f:85"
Incidentally, I tried ip rather than ifconfig, and found that the MAC address
was never changed.
Larry
WARNING: multiple messages have this Message-ID (diff)
From: Larry Finger <Larry.Finger@lwfinger.net>
To: "Nicolas de Pesloüan" <nicolas.2p.debian@free.fr>
Cc: Michael Buesch <mb@bu3sch.de>,
Calvin Walton <calvin.walton@gmail.com>,
linux-wireless@vger.kernel.org, b43-dev@lists.infradead.org
Subject: Re: [PATCH V2] ssb: Implement virtual SPROM on disk
Date: Sun, 28 Mar 2010 19:33:53 -0500 [thread overview]
Message-ID: <4BAFF571.1090706@lwfinger.net> (raw)
In-Reply-To: <4BAFA83B.8050505@free.fr>
On 03/28/2010 02:04 PM, Nicolas de Pesloüan wrote:
> Larry Finger wrote:
>> On 03/28/2010 12:14 PM, Nicolas de Pesloüan wrote:
>>> Larry Finger wrote:
>>> MACADDRESS=$(/bin/dd if=/dev/random bs=1 count=6 2>/dev/null |
>>> /usr/bin/od -tx1 |
>>> sed -ne '1{;s/0000000 //;s/^\(.\)[014589cd]/\12/;y/ /:/;p}'
>>
>> It also needs to be even as an odd value would be a broadcast address.
>> Using
>> only sed instead of head|cut|awk does have merit and the randomness is
>> increased
>> by 6 bits. It will take me a while to understand the sed here. Regular
>> expressions are not my thing.
>
> Yes, you are right, so I need to change a few things, in order to keep
> the highest possible level of randomness while ensuring the lower half
> of first byte is 2, 6, a or e.
>
> dd if=/dev/random bs=1 count=6 2>/dev/null |
> od -tx1 |
> sed -ne '1{;s/0000000 //;
> s/^\(.\)[013]/\12/;s/^\(.\)[457]/\16/;
> s/^\(.\)[89b]/\1a/;s/^\(.\)[cdf]/\1e/;
> y/ /:/;p}'
>
> Translation to humain form :
>
> # for the first line only,
> # If second char is 0, 1 or 3, replace it with 2.
> # If second char is 4, 5 or 7, replace it with 6.
> # If second char is 8, 9 or b, replace it with a.
> # If second char is c, d or f, replace it with e.
> # Replace all spaces with ':'.
> # print
> # Print nothing for other lines, thanks to -n option.
That is a lot of work for 2 extra bits, but thanks. I had changed the [014589cd]
of your original with [01345789bcdf], which resulted in X2 as the first byte for
most generated addresses.
>>> If DEVPATH is "generic" (wlan*), how would you distinguish between two
>>> broadcom NIC present in the system, both without an SPROM ?
>>
>> That is covered by the
>> /devices/pci0000:00/0000:00:0d.0/0000:04:00.0/... part of
>
> Ok, sounds good for me. Did you had the opportunity to test with two
> such devices ?
Yes. On a machine where I have two PCI versions of BCM43XX devices, one is
...00:08.0/... and the other is ...00:0a.0/... The generated rules are
SUBSYSTEM=="net", DEVPATH=="/devices/pci0000:00/0000:00:08.0/ssb0:0/net/wlan*",
ATTR{address}=="82:82:82:82:82:82", ENV{MAC_CHANGED}="yes", RUN+="/sbin/ifconfig
$env{INTERFACE} hw ether c2:e7:d3:d8:73:a8"
SUBSYSTEM=="net", DEVPATH=="/devices/pci0000:00/0000:00:0a.0/ssb1:0/net/wlan*",
ATTR{address}=="82:82:82:82:82:82", ENV{MAC_CHANGED}="yes", RUN+="/sbin/ifconfig
$env{INTERFACE} hw ether 02:56:31:dd:7f:85"
Incidentally, I tried ip rather than ifconfig, and found that the MAC address
was never changed.
Larry
next prev parent reply other threads:[~2010-03-29 0:33 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-21 23:22 [PATCH V2] ssb: Implement virtual SPROM on disk Larry Finger
2010-03-22 6:28 ` Calvin Walton
2010-03-22 8:37 ` Michael Buesch
2010-03-22 15:06 ` Larry Finger
2010-03-22 21:55 ` Michael Buesch
2010-03-22 22:19 ` Larry Finger
2010-03-22 22:28 ` Michael Buesch
2010-03-22 21:56 ` Larry Finger
2010-03-22 22:25 ` Michael Buesch
2010-03-22 23:45 ` Larry Finger
2010-03-23 8:52 ` Michael Buesch
2010-03-23 14:25 ` Larry Finger
2010-03-23 20:58 ` Calvin Walton
2010-03-23 22:02 ` Michael Buesch
2010-03-24 14:16 ` Larry Finger
2010-03-24 19:21 ` Michael Buesch
2010-03-26 3:47 ` Larry Finger
2010-03-28 17:14 ` Nicolas de Pesloüan
2010-03-28 17:14 ` Nicolas de Pesloüan
2010-03-28 18:25 ` Larry Finger
2010-03-28 18:25 ` Larry Finger
2010-03-28 19:04 ` Nicolas de Pesloüan
2010-03-28 19:04 ` Nicolas de Pesloüan
2010-03-29 0:33 ` Larry Finger [this message]
2010-03-29 0:33 ` Larry Finger
2010-03-29 2:06 ` Peter Stuge
2010-03-29 2:21 ` Gene Heskett
2010-03-29 2:43 ` Larry Finger
2010-03-29 7:44 ` Stefano Brivio
2010-03-29 8:00 ` David Woodhouse
2010-03-29 12:39 ` Gene Heskett
2010-03-30 22:21 ` Peter Stuge
2010-03-30 22:34 ` Gene Heskett
2010-03-24 1:25 ` Ehud Gavron
2010-03-23 8:55 ` Florian Fainelli
2010-03-23 11:43 ` Michael Buesch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BAFF571.1090706@lwfinger.net \
--to=larry.finger@lwfinger.net \
--cc=b43-dev@lists.infradead.org \
--cc=calvin.walton@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=mb@bu3sch.de \
--cc=nicolas.2p.debian@free.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.