public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] UML - Don't roll my own random MAC generator
@ 2006-09-28 18:14 Jeff Dike
  2006-09-29 22:18 ` Ollie Wild
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff Dike @ 2006-09-28 18:14 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, user-mode-linux-devel, dhollis, Jason Lunz

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 <jdike@addtoit.com>
---

 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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] UML - Don't roll my own random MAC generator
  2006-09-28 18:14 [PATCH 2/2] UML - Don't roll my own random MAC generator Jeff Dike
@ 2006-09-29 22:18 ` Ollie Wild
  2006-09-29 22:38   ` Andrew Morton
  2006-09-30  3:49   ` Jeff Dike
  0 siblings, 2 replies; 9+ messages in thread
From: Ollie Wild @ 2006-09-29 22:18 UTC (permalink / raw)
  To: Jeff Dike; +Cc: akpm, linux-kernel, user-mode-linux-devel, dhollis, Jason Lunz

[-- Attachment #1: Type: text/plain, Size: 3064 bytes --]

This patch as provided breaks my build due to a missing semicolon.

Patch attached.

Ollie

On 9/28/06, Jeff Dike <jdike@addtoit.com> 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 <jdike@addtoit.com>
> ---
>
>  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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

[-- Attachment #2: random_ether_addr.patch --]
[-- Type: text/x-patch, Size: 344 bytes --]

diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 16aa572..300a54a 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -310,7 +310,7 @@ static void setup_etheraddr(char *str, u
 	return;
 
 random:
-	random_ether_addr(addr)
+	random_ether_addr(addr);
 }
 
 static DEFINE_SPINLOCK(devices_lock);

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] UML - Don't roll my own random MAC generator
  2006-09-29 22:18 ` Ollie Wild
@ 2006-09-29 22:38   ` Andrew Morton
  2006-09-29 22:48     ` Ollie Wild
  2006-09-30  3:52     ` Jeff Dike
  2006-09-30  3:49   ` Jeff Dike
  1 sibling, 2 replies; 9+ messages in thread
From: Andrew Morton @ 2006-09-29 22:38 UTC (permalink / raw)
  To: Ollie Wild
  Cc: Jeff Dike, linux-kernel, user-mode-linux-devel, dhollis,
	Jason Lunz

On Fri, 29 Sep 2006 15:18:52 -0700
"Ollie Wild" <aaw@google.com> 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?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] UML - Don't roll my own random MAC generator
  2006-09-29 22:38   ` Andrew Morton
@ 2006-09-29 22:48     ` Ollie Wild
  2006-09-29 23:16       ` Andrew Morton
  2006-09-30  3:52     ` Jeff Dike
  1 sibling, 1 reply; 9+ messages in thread
From: Ollie Wild @ 2006-09-29 22:48 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Jeff Dike, linux-kernel, user-mode-linux-devel, dhollis,
	Jason Lunz

You can use "make ARCH=um SUBARCH=i386 .." to build for i386.

Ollie

On 9/29/06, Andrew Morton <akpm@osdl.org> wrote:
> On Fri, 29 Sep 2006 15:18:52 -0700
> "Ollie Wild" <aaw@google.com> 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?
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] UML - Don't roll my own random MAC generator
  2006-09-29 22:48     ` Ollie Wild
@ 2006-09-29 23:16       ` Andrew Morton
  2006-09-30  4:15         ` [uml-devel] " Jeff Dike
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2006-09-29 23:16 UTC (permalink / raw)
  To: Ollie Wild
  Cc: Jeff Dike, linux-kernel, user-mode-linux-devel, dhollis,
	Jason Lunz

On Fri, 29 Sep 2006 15:48:04 -0700
"Ollie Wild" <aaw@google.com> 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)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] UML - Don't roll my own random MAC generator
  2006-09-29 22:18 ` Ollie Wild
  2006-09-29 22:38   ` Andrew Morton
@ 2006-09-30  3:49   ` Jeff Dike
  1 sibling, 0 replies; 9+ messages in thread
From: Jeff Dike @ 2006-09-30  3:49 UTC (permalink / raw)
  To: Ollie Wild; +Cc: akpm, linux-kernel, user-mode-linux-devel, dhollis, Jason Lunz

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] UML - Don't roll my own random MAC generator
  2006-09-29 22:38   ` Andrew Morton
  2006-09-29 22:48     ` Ollie Wild
@ 2006-09-30  3:52     ` Jeff Dike
  2006-09-30  4:08       ` Andrew Morton
  1 sibling, 1 reply; 9+ messages in thread
From: Jeff Dike @ 2006-09-30  3:52 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Ollie Wild, linux-kernel, user-mode-linux-devel, dhollis,
	Jason Lunz

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] UML - Don't roll my own random MAC generator
  2006-09-30  3:52     ` Jeff Dike
@ 2006-09-30  4:08       ` Andrew Morton
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2006-09-30  4:08 UTC (permalink / raw)
  To: Jeff Dike
  Cc: Ollie Wild, linux-kernel, user-mode-linux-devel, dhollis,
	Jason Lunz

On Fri, 29 Sep 2006 23:52:34 -0400
Jeff Dike <jdike@addtoit.com> 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?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [uml-devel] [PATCH 2/2] UML - Don't roll my own random MAC generator
  2006-09-29 23:16       ` Andrew Morton
@ 2006-09-30  4:15         ` Jeff Dike
  0 siblings, 0 replies; 9+ messages in thread
From: Jeff Dike @ 2006-09-30  4:15 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Ollie Wild, dhollis, linux-kernel, user-mode-linux-devel,
	Jason Lunz

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-09-30  4:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-28 18:14 [PATCH 2/2] UML - Don't roll my own random MAC generator Jeff Dike
2006-09-29 22:18 ` Ollie Wild
2006-09-29 22:38   ` Andrew Morton
2006-09-29 22:48     ` Ollie Wild
2006-09-29 23:16       ` Andrew Morton
2006-09-30  4:15         ` [uml-devel] " Jeff Dike
2006-09-30  3:52     ` Jeff Dike
2006-09-30  4:08       ` Andrew Morton
2006-09-30  3:49   ` Jeff Dike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox