All of lore.kernel.org
 help / color / mirror / Atom feed
From: William Mills <wmills@ti.com>
To: Darren Hart <dvhart@linux.intel.com>
Cc: Yocto Project <yocto@yoctoproject.org>
Subject: Re: [pull-sys940x 3/4] genmac: Replace RANDOM_MAC in	network/interfaces with a randomly generated MAC
Date: Thu, 2 Feb 2012 09:09:40 -0500	[thread overview]
Message-ID: <4F2A9924.3050001@ti.com> (raw)
In-Reply-To: <8c5010ca5786a486f2082d711fdf52b8617973af.1328135056.git.dvhart@linux.intel.com>


On 02/01/2012 05:26 PM, Darren Hart wrote:
> For machines that do not have a MAC in hardware and with drivers that don't
> generate a random one in the kernel, this init script will replace the string
> RANDOM_MAC in the network/interfaces file with one generated with "ranpwd -m".
> Care is taken to ensure multiple interfaces can use RANDOM_MAC and receive
> unique addresses. ranpwd generates MACs with the locally administered bit set
> and the multicast bit disabled.
>
> Signed-off-by: Darren Hart<dvhart@linux.intel.com>
> ---
>   meta-sys940x/recipes-bsp/genmac/files/genmac |   46 ++++++++++++++++++++++++++
>   meta-sys940x/recipes-bsp/genmac/genmac.bb    |   30 +++++++++++++++++
>   2 files changed, 76 insertions(+), 0 deletions(-)
>   create mode 100644 meta-sys940x/recipes-bsp/genmac/files/genmac
>   create mode 100644 meta-sys940x/recipes-bsp/genmac/genmac.bb
>
> diff --git a/meta-sys940x/recipes-bsp/genmac/files/genmac b/meta-sys940x/recipes-bsp/genmac/files/genmac
> new file mode 100644
> index 0000000..6ca069c
> --- /dev/null
> +++ b/meta-sys940x/recipes-bsp/genmac/files/genmac
> @@ -0,0 +1,46 @@
> +#!/bin/sh
> +### BEGIN INIT INFO
> +# Provides:          Random MAC address generator
> +# Required-Start:    $syslog
> +# Required-Stop:     $syslog
> +# Default-Start:     2 3 4 5
> +# Default-Stop:      0 1 6
> +# Short-Description: Set a random MAC for tagged interfaces
> +# Description:       Set a random MAC for interfaces with RANDOM_MAC
> +### END INIT INFO
> +
> +# Author: Darren Hart<dvhart@linux.intel.com>
> +# Based on /etc/init.d/skeleton
> +
> +PATH=/sbin:/usr/sbin:/bin:/usr/bin
> +DESC="Set a random MAC for tagged interfaces"
> +NAME=genmac
> +RANPWD=`which ranpwd`
> +SCRIPTNAME=/etc/init.d/$NAME
> +
> +# Exit if amixer is not installed
> +[ -x "$RANPWD" ] || exit 0
> +
> +do_start() {
> +	# Replace every occurance of RANDOM_MAC with a unique locally
> +	# administered, unicast, randomly generated MAC address.
> +	while grep -q RANDOM_MAC /etc/network/interfaces; do
> +		sed -i "1,/RANDOM_MAC/s/RANDOM_MAC/$($RANPWD -m)/" /etc/network/interfaces
> +	done
> +}

So on a non-volatile r/w filesystem this will assign a new random mac to 
each interface on the first boot and reuse that MAC on each subsquent boot.

On a volatile r/w filesystem this will use a new MAC addr for each 
boot.  I guess thats better than nothing and not much to do on a 
volatile system.

What does this do on a ro filesystem?  No network?  network with 
0:0:0:0:0:0 MAC addr? (horror! but I suspect the kernel won't allow 
that).  Certainly this script failing should not cause the rest of boot 
to fail.



  parent reply	other threads:[~2012-02-02 14:09 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-01 22:26 [pull-sys940x 0/4][meta-intel] Inforce SYS940X BSP (Intel Atom E6xx + EG20T) Darren Hart
2012-02-01 22:26 ` [pull-sys940x 1/4] meta-intel: Add Inforce SYS940x BSP Darren Hart
2012-02-01 22:37   ` Joshua Lock
2012-02-01 23:05     ` Joshua Lock
2012-02-02 18:07       ` Darren Hart
2012-02-01 22:26 ` [pull-sys940x 2/4] ranpwd: Add ranpwd recipe Darren Hart
2012-02-01 22:40   ` Joshua Lock
2012-02-02  7:22     ` Martin Jansa
2012-02-02 18:26       ` Darren Hart
2012-02-02 19:13         ` Joshua Lock
2012-02-02 19:34           ` Darren Hart
2012-02-02 18:24     ` Darren Hart
2012-02-02 19:24       ` Joshua Lock
2012-02-02 19:32         ` Darren Hart
2012-02-02 21:11           ` Joshua Lock
2012-02-06 16:17             ` Paul Eggleton
2012-02-06 23:59               ` Joshua Lock
2012-02-07  7:06                 ` Martin Jansa
2012-02-07  9:20                   ` [yocto] " Koen Kooi
2012-02-11  0:14                   ` Darren Hart
2012-02-11  1:45                     ` Khem Raj
2012-02-01 22:26 ` [pull-sys940x 3/4] genmac: Replace RANDOM_MAC in network/interfaces with a randomly generated MAC Darren Hart
2012-02-01 22:42   ` Joshua Lock
2012-02-02 18:27     ` Darren Hart
2012-02-02 14:09   ` William Mills [this message]
2012-02-02 17:19     ` Darren Hart
2012-02-02 18:37       ` William Mills
2012-02-01 22:26 ` [pull-sys940x 4/4] netbase: Add interfaces with RANDOM_MAC for sys940x* machines Darren Hart
2012-02-01 22:52   ` Joshua Lock
2012-02-01 23:03     ` Joshua Lock
2012-02-02 18:31       ` Darren Hart
2012-02-02 19:02       ` Joshua Lock

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=4F2A9924.3050001@ti.com \
    --to=wmills@ti.com \
    --cc=dvhart@linux.intel.com \
    --cc=yocto@yoctoproject.org \
    /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.