Use the existing random_ether_addr() instead of cooking up my own
version. Pointed out by Dave Hollis and Jason Lunz.
Signed-off-by: Jeff Dike <[email protected]>
---
arch/um/drivers/net_kern.c | 4 +---
arch/um/drivers/net_user.c | 29 -----------------------------
arch/um/include/net_user.h | 2 --
3 files changed, 1 insertion(+), 34 deletions(-)
Index: linux-2.6.18-mm/arch/um/drivers/net_kern.c
===================================================================
--- linux-2.6.18-mm.orig/arch/um/drivers/net_kern.c 2006-09-28 12:51:50.000000000 -0400
+++ linux-2.6.18-mm/arch/um/drivers/net_kern.c 2006-09-28 13:00:58.000000000 -0400
@@ -309,9 +309,7 @@ static void setup_etheraddr(char *str, u
return;
random:
- addr[0] = 0xfe;
- addr[1] = 0xfd;
- random_mac(addr);
+ random_ether_addr(addr)
}
static DEFINE_SPINLOCK(devices_lock);
Index: linux-2.6.18-mm/arch/um/drivers/net_user.c
===================================================================
--- linux-2.6.18-mm.orig/arch/um/drivers/net_user.c 2006-09-28 12:51:50.000000000 -0400
+++ linux-2.6.18-mm/arch/um/drivers/net_user.c 2006-09-28 13:00:06.000000000 -0400
@@ -259,32 +259,3 @@ char *split_if_spec(char *str, ...)
va_end(ap);
return str;
}
-
-void random_mac(unsigned char *addr)
-{
- struct timeval tv;
- long n;
- unsigned int seed;
-
- gettimeofday(&tv, NULL);
-
- /* Assume that 20 bits of microseconds and 12 bits of the pid are
- * reasonably unpredictable.
- */
- seed = tv.tv_usec | (os_getpid() << 20);
- srandom(seed);
-
- /* Don't care about endianness here - switching endianness
- * just rearranges what are hopefully random numbers.
- *
- * Assume that RAND_MAX > 65536, so random is called twice and
- * we use 16 bits of the result.
- */
- n = random();
- addr[2] = (n >> 8) & 255;
- addr[3] = n % 255;
-
- n = random();
- addr[4] = (n >> 8) & 255;
- addr[5] = n % 255;
-}
Index: linux-2.6.18-mm/arch/um/include/net_user.h
===================================================================
--- linux-2.6.18-mm.orig/arch/um/include/net_user.h 2006-09-28 12:15:48.000000000 -0400
+++ linux-2.6.18-mm/arch/um/include/net_user.h 2006-09-28 13:01:51.000000000 -0400
@@ -50,6 +50,4 @@ extern char *split_if_spec(char *str, ..
extern int dev_netmask(void *d, void *m);
-extern void random_mac(unsigned char *addr);
-
#endif
This patch as provided breaks my build due to a missing semicolon.
Patch attached.
Ollie
On 9/28/06, Jeff Dike <[email protected]> wrote:
> Use the existing random_ether_addr() instead of cooking up my own
> version. Pointed out by Dave Hollis and Jason Lunz.
>
> Signed-off-by: Jeff Dike <[email protected]>
> ---
>
> arch/um/drivers/net_kern.c | 4 +---
> arch/um/drivers/net_user.c | 29 -----------------------------
> arch/um/include/net_user.h | 2 --
> 3 files changed, 1 insertion(+), 34 deletions(-)
>
> Index: linux-2.6.18-mm/arch/um/drivers/net_kern.c
> ===================================================================
> --- linux-2.6.18-mm.orig/arch/um/drivers/net_kern.c 2006-09-28 12:51:50.000000000 -0400
> +++ linux-2.6.18-mm/arch/um/drivers/net_kern.c 2006-09-28 13:00:58.000000000 -0400
> @@ -309,9 +309,7 @@ static void setup_etheraddr(char *str, u
> return;
>
> random:
> - addr[0] = 0xfe;
> - addr[1] = 0xfd;
> - random_mac(addr);
> + random_ether_addr(addr)
> }
>
> static DEFINE_SPINLOCK(devices_lock);
> Index: linux-2.6.18-mm/arch/um/drivers/net_user.c
> ===================================================================
> --- linux-2.6.18-mm.orig/arch/um/drivers/net_user.c 2006-09-28 12:51:50.000000000 -0400
> +++ linux-2.6.18-mm/arch/um/drivers/net_user.c 2006-09-28 13:00:06.000000000 -0400
> @@ -259,32 +259,3 @@ char *split_if_spec(char *str, ...)
> va_end(ap);
> return str;
> }
> -
> -void random_mac(unsigned char *addr)
> -{
> - struct timeval tv;
> - long n;
> - unsigned int seed;
> -
> - gettimeofday(&tv, NULL);
> -
> - /* Assume that 20 bits of microseconds and 12 bits of the pid are
> - * reasonably unpredictable.
> - */
> - seed = tv.tv_usec | (os_getpid() << 20);
> - srandom(seed);
> -
> - /* Don't care about endianness here - switching endianness
> - * just rearranges what are hopefully random numbers.
> - *
> - * Assume that RAND_MAX > 65536, so random is called twice and
> - * we use 16 bits of the result.
> - */
> - n = random();
> - addr[2] = (n >> 8) & 255;
> - addr[3] = n % 255;
> -
> - n = random();
> - addr[4] = (n >> 8) & 255;
> - addr[5] = n % 255;
> -}
> Index: linux-2.6.18-mm/arch/um/include/net_user.h
> ===================================================================
> --- linux-2.6.18-mm.orig/arch/um/include/net_user.h 2006-09-28 12:15:48.000000000 -0400
> +++ linux-2.6.18-mm/arch/um/include/net_user.h 2006-09-28 13:01:51.000000000 -0400
> @@ -50,6 +50,4 @@ extern char *split_if_spec(char *str, ..
>
> extern int dev_netmask(void *d, void *m);
>
> -extern void random_mac(unsigned char *addr);
> -
> #endif
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
On Fri, 29 Sep 2006 15:18:52 -0700
"Ollie Wild" <[email protected]> wrote:
> This patch as provided breaks my build due to a missing semicolon.
>
> ..
>
> - random_ether_addr(addr)
> + random_ether_addr(addr);
ahem. That must have had a lot of testing ;)
Jeff, could we pleeeeeze arrange for UML's `make allmodconfig' to work, and
to continue to work?
Right now it goes splut with
arch/um/os-Linux/sys-x86_64/registers.c: In function 'get_thread_regs':
arch/um/os-Linux/sys-x86_64/registers.c:85: error: 'JB_PC' undeclared (first use in this function)
arch/um/os-Linux/sys-x86_64/registers.c:85: error: (Each undeclared identifier is reported only once
arch/um/os-Linux/sys-x86_64/registers.c:85: error: for each function it appears in.)
arch/um/os-Linux/sys-x86_64/registers.c:86: error: 'JB_RSP' undeclared (first use in this function)
arch/um/os-Linux/sys-x86_64/registers.c:87: error: 'JB_RBP' undeclared (first use in this function)
How does one build uml-for-i386 on an x86_64 host, btw?
You can use "make ARCH=um SUBARCH=i386 .." to build for i386.
Ollie
On 9/29/06, Andrew Morton <[email protected]> wrote:
> On Fri, 29 Sep 2006 15:18:52 -0700
> "Ollie Wild" <[email protected]> wrote:
>
> > This patch as provided breaks my build due to a missing semicolon.
> >
> > ..
> >
> > - random_ether_addr(addr)
> > + random_ether_addr(addr);
>
> ahem. That must have had a lot of testing ;)
>
> Jeff, could we pleeeeeze arrange for UML's `make allmodconfig' to work, and
> to continue to work?
>
> Right now it goes splut with
>
> arch/um/os-Linux/sys-x86_64/registers.c: In function 'get_thread_regs':
> arch/um/os-Linux/sys-x86_64/registers.c:85: error: 'JB_PC' undeclared (first use in this function)
> arch/um/os-Linux/sys-x86_64/registers.c:85: error: (Each undeclared identifier is reported only once
> arch/um/os-Linux/sys-x86_64/registers.c:85: error: for each function it appears in.)
> arch/um/os-Linux/sys-x86_64/registers.c:86: error: 'JB_RSP' undeclared (first use in this function)
> arch/um/os-Linux/sys-x86_64/registers.c:87: error: 'JB_RBP' undeclared (first use in this function)
>
>
> How does one build uml-for-i386 on an x86_64 host, btw?
>
On Fri, 29 Sep 2006 15:48:04 -0700
"Ollie Wild" <[email protected]> wrote:
> You can use "make ARCH=um SUBARCH=i386 .." to build for i386.
OIC, thanks.
I still get:
arch/um/os-Linux/sys-i386/registers.c: In function 'get_thread_regs':
arch/um/os-Linux/sys-i386/registers.c:137: error: 'JB_PC' undeclared (first use in this function)
arch/um/os-Linux/sys-i386/registers.c:137: error: (Each undeclared identifier is reported only once
arch/um/os-Linux/sys-i386/registers.c:137: error: for each function it appears in.)
arch/um/os-Linux/sys-i386/registers.c:138: error: 'JB_SP' undeclared (first use in this function)
arch/um/os-Linux/sys-i386/registers.c:139: error: 'JB_BP' undeclared (first use in this function)
On Fri, Sep 29, 2006 at 03:38:53PM -0700, Andrew Morton wrote:
> ahem. That must have had a lot of testing ;)
It did have some - just missed a patch refresh.
> Jeff, could we pleeeeeze arrange for UML's `make allmodconfig' to work, and
> to continue to work?
It works for me - I haven't built -mm2 on x86_64 yet, but I'll check that.
Jeff
On Fri, Sep 29, 2006 at 03:18:52PM -0700, Ollie Wild wrote:
> This patch as provided breaks my build due to a missing semicolon.
>
> Patch attached.
Thanks - I fixed that, but forgot to refresh the patch.
Jeff
On Fri, 29 Sep 2006 23:52:34 -0400
Jeff Dike <[email protected]> wrote:
> > Jeff, could we pleeeeeze arrange for UML's `make allmodconfig' to work, and
> > to continue to work?
>
> It works for me - I haven't built -mm2 on x86_64 yet, but I'll check that.
that was mainline. Perhaps a toolchain thing?
On Fri, Sep 29, 2006 at 04:16:16PM -0700, Andrew Morton wrote:
> arch/um/os-Linux/sys-i386/registers.c: In function 'get_thread_regs':
> arch/um/os-Linux/sys-i386/registers.c:137: error: 'JB_PC' undeclared (first use in this function)
> arch/um/os-Linux/sys-i386/registers.c:137: error: (Each undeclared identifier is reported only once
> arch/um/os-Linux/sys-i386/registers.c:137: error: for each function it appears in.)
> arch/um/os-Linux/sys-i386/registers.c:138: error: 'JB_SP' undeclared (first use in this function)
> arch/um/os-Linux/sys-i386/registers.c:139: error: 'JB_BP' undeclared (first use in this function)
Hmmm, I never tried a cross-build before, but I don't even get this far:
CC arch/um/sys-i386/user-offsets.s
In file included from /usr/include/features.h:352,
from /usr/include/stdio.h:28,
from /home/jdike/linux/2.6/linux-2.6.17/arch/um/sys-i386/user-\offsets.c:1:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
m
I just flew into Ohio and am not in any shape to debug this atm. I'll have
another look tomorrow.
Jeff