net: helper functions
Subsystems (2)
v4 cover net: helper functions
This patchset is a split-off from my patch series "Kirkwood: add lschlv2 and lsxhl board support".
Changes:
v4:
- typo fixes (thanks Mike)
- seed all 46bits of the generated ethernet address (suggested by Mike)
v3, v2:
[contained only lsxhl board changes]
Michael Walle (3):
lib: add rand() function
net: add helper to generate random mac address
net: add eth_setenv_enetaddr_by_index()
include/common.h | 4 ++++ include/net.h | 27 +++++++++++++++++++++++++++ lib/Makefile | 1 + lib/rand.c | 43 +++++++++++++++++++++++++++++++++++++++++++ net/eth.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 0 deletions(-) create mode 100644 lib/rand.c
Signature · 1 line
1.7.2.5
PATCH v4 1/3 lib: add rand() function
It's a PRNG using the simple and fast xorshift method.
--- include/common.h | 4 ++++ lib/Makefile | 1 + lib/rand.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 0 deletions(-) create mode 100644 lib/rand.c
include/common.h +4 -0
@@ -733,6 +733,10 @@ char * strmhz(char *buf, unsigned long hz);/* lib/crc32.c */ #include <u-boot/crc.h> +/* lib/rand.c */ +void srand (unsigned int seed); +unsigned int rand (void ); +/* common/console.c */ int console_init_f (void );/* Before relocation; uses the serial stuff */ int console_init_r (void );/* After relocation; uses the console stuff */
lib/Makefile +1 -0
@@ -65,6 +65,7 @@ COBJS-y += string.o COBJS-y += time.o COBJS-$(CONFIG_BOOTP_PXE) += uuid.o COBJS-y += vsprintf.o +COBJS-y += rand.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
lib/rand.c new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v4 1/3 lib: add rand() function
Dear Michael Walle,
Quoted 1 line · In message <[email protected]> you wrote:
It's a PRNG using the simple and fast xorshift method.
...
Quoted 1 line
+static unsigned int y = 2463534242U;
Hm... can we introduce at least a little entropy somewhere?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A Puritan is someone who is deathly afraid that someone, somewhere, is having fun.
PATCH v4 1/3 lib: add rand() function
Am Freitag 11 Mai 2012, 21:20:02 schrieb Wolfgang Denk:
Quoted 10 lines
Dear Michael Walle,
Quoted 1 line · In message <[email protected]> you wrote:
It's a PRNG using the simple and fast xorshift method.
...
Quoted 1 line
+static unsigned int y = 2463534242U;
Hm... can we introduce at least a little entropy somewhere?
Mh? A user is supposed to seed via srand().
Signature · 1 line
michael
PATCH v4 1/3 lib: add rand() function
Dear Michael Walle,
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 4 lines
Quoted 2 lines
+static unsigned int y = 2463534242U;
Hm... can we introduce at least a little entropy somewhere?
Mh? A user is supposed to seed via
srand().
Then why initialize y at all?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de And now remains That we find out the cause of this effect, Or rather say, the cause of this defect... -- Hamlet, Act II, Scene 2
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v4 1/3 lib: add rand() function
Dear Michael Walle,
please keep the ML on Cc: - thanks.
Quoted 11 lines · In message <[email protected]> you wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
+static unsigned int y = 2463534242U;
Hm... can we introduce at least a little entropy somewhere?
Mh? A user is supposed to seed via
srand().Then why initialize y at all?
To have a sane fallback. Maybe i should have written
"A user is supposed to seed viasrand()if he wan't some
entropy."
This is inconsequent. Either we assume that the user will seed srand(), then y should not be initialized at all, so it goes to the BSS segment and does not waste space in the binary image. Or we want to deal with cases where the user doesn call srand(), and then we should provide a bit better than such a static initialization.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de If all the Chinese simultaneously jumped into the Pacific off a 10 foot platform erected 10 feet off their coast, it would cause a tidal wave that would destroy everything in this country west of Nebraska.
PATCH v4 1/3 lib: add rand() function
Quoted 2 lines
please keep the ML on Cc: - thanks.
sorry wrong key
Quoted 13 lines
Quoted 12 lines · In message <[email protected]> you wrote:
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+static unsigned int y = 2463534242U;
Hm... can we introduce at least a little entropy somewhere?
Mh? A user is supposed to seed via
srand().Then why initialize y at all?
To have a sane fallback. Maybe i should have written
"A user is supposed to seed via
srand()if he wan't some
Quoted 7 lines
Quoted 1 line
entropy."
This is inconsequent. Either we assume that the user will seed
srand(), then y should not be initialized at all, so it goes to the BSS segment and does not waste space in the binary image. Or we want to deal with cases where the user doesn callsrand(), and then we should provide a bit better than such a static initialization.
Again, i wanted to stick with the regular rand() srand() semantics.
http://pubs.opengroup.org/onlinepubs/009695399/functions/rand.html
"If rand() is called before any calls to srand() are made, the same sequence shall be generated as when srand() is first called with a seed value of 1."
But i'm fine with removing the initialization.
Signature · 1 line
Michael
PATCH v4 1/3 lib: add rand() function
Dear Michael Walle,
Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 6 lines
This is inconsequent. Either we assume that the user will seed
srand(), then y should not be initialized at all, so it goes to the BSS segment and does not waste space in the binary image. Or we want to deal with cases where the user doesn callsrand(), and then we should provide a bit better than such a static initialization.
Quoted 5 lines
Again, i wanted to stick with the regular
rand()srand()semantics.http://pubs.opengroup.org/onlinepubs/009695399/functions/rand.html
"Ifrand()is called before any calls tosrand()are made, the same sequence shall be generated as whensrand()is first called with a seed value of 1."
Good point.
But then y should be initialized as 1 ?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "Security is mostly a superstition. It does not exist in nature... Life is either a daring adventure or nothing." - Helen Keller
PATCH v4 1/3 lib: add rand() function
Am Freitag 11 Mai 2012, 23:29:47 schrieb Wolfgang Denk:
Quoted 11 lines
Dear Michael Walle,
Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 5 lines
This is inconsequent. Either we assume that the user will seed
srand(), then y should not be initialized at all, so it goes to the BSS segment and does not waste space in the binary image. Or we want to deal with cases where the user doesn callsrand(), and then we should provide a bit better than such a static initialization.Again, i wanted to stick with the regular
rand()srand()semantics.
Quoted 8 lines
Quoted 4 lines
http://pubs.opengroup.org/onlinepubs/009695399/functions/rand.html
"Ifrand()is called before any calls tosrand()are made, the same sequence shall be generated as whensrand()is first called with a seed value of 1."Good point.
But then y should be initialized as 1 ?
I'm no crypto expert, so i sticked with the values/examples from the cited paper. But i guess it shouldn't make any difference, i'll change it to 1.
Signature · 1 line
michael
PATCH v4 2/3 net: add helper to generate random mac address
In reply to Michael WalleAdd new function eth_random_enetaddr() to generate a locally administered ethernet address.
--- include/net.h | 15 +++++++++++++++ net/eth.c | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-)
include/net.h +15 -0
@@ -118,6 +118,21 @@ extern int eth_setenv_enetaddr(char *name, const uchar *enetaddr);extern int eth_getenv_enetaddr_by_index (const char *base_name,int index,uchar *enetaddr); +/* +* The u-boot policy does not allow hardcoded ethernet addresses. Under the +* following circumstances a random generated address is allowed: +* - in emergency cases, where you need a working network connection to set +* the ethernet address. +* Eg. you want a rescue boot and don't have a serial port to access the +* CLI to set environment variables. +* +* In these cases, we generate a random locally administered ethernet address. +* +* Args: +* enetaddr - returns 6 byte hardware address +*/ +extern void eth_random_enetaddr (uchar *enetaddr); +extern int usb_eth_initialize (bd_t *bi);extern int eth_init (bd_t *bis);/* Initialize the device */ extern int eth_send (volatile void *packet,int length);/* Send a packet */
net/eth.c +20 -0
@@ -70,6 +70,26 @@ static int eth_mac_skip(int index)return ((skip_state =getenv (enetvar)) !=NULL ); } +void eth_random_enetaddr (uchar *enetaddr) +{ +uint32_t rval; + +srand (get_timer (0 )); + + rval =rand (); + enetaddr[0 ] = rval &0xff ; + enetaddr[1 ] = (rval >>8 ) &0xff ; + enetaddr[2 ] = (rval >>16 ) &0xff ; + + rval =rand (); + enetaddr[3 ] = rval &0xff ; + enetaddr[4 ] = (rval >>8 ) &0xff ; + enetaddr[5 ] = (rval >>16 ) &0xff ; + +/* make sure it's local and unicast */ + enetaddr[0 ] = (enetaddr[0 ] |0x02 ) & ~0x01 ; +} +/* * CPU and board-specific Ethernet initializations. Aliased function * signals caller to move on
Signature · 1 line
1.7.2.5
PATCH v4 2/3 net: add helper to generate random mac address
Dear Michael Walle,
Quoted 8 lines · In message <[email protected]> you wrote:
Add new function
eth_random_enetaddr()to generate a locally administered ethernet address.Signed-off-by Michael Walle <[email protected]>--- include/net.h | 15 +++++++++++++++ net/eth.c | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-)
Please make this code configurable. I don't want to bloat code size for all boards when only one or two will ever use this feature.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I'd like to meet the man who invented sex and see what he's working on now.
PATCH v4 2/3 net: add helper to generate random mac address
Quoted 7 lines · On Friday 11 May 2012 15:21:19 Wolfgang Denk wrote:
Quoted 6 lines · Michael Walle
Add new function
eth_random_enetaddr()to generate a locally administered ethernet address.Signed-off-by Michael Walle <[email protected]>---
Quoted 6 lines
Quoted 3 lines
include/net.h | 15 +++++++++++++++ net/eth.c | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-)Please make this code configurable. I don't want to bloat code size for all boards when only one or two will ever use this feature.
it would be nice if we could standardize gc-sections across the board
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120514/fb715b46/attachment.pgp>
PATCH v4 3/3 net: add eth_setenv_enetaddr_by_index()
In reply to Michael Walle--- include/net.h | 12 ++++++++++++ net/eth.c | 8 ++++++++ 2 files changed, 20 insertions(+), 0 deletions(-)
include/net.h +12 -0
@@ -119,6 +119,18 @@ extern int eth_getenv_enetaddr_by_index(const char *base_name, int index, uchar *enetaddr);/* +* Set the hardware address for an ethernet interface . +* Args: +* base_name - base name for device (normally "eth") +* index - device index number (0 for first) +* enetaddr - returns 6 byte hardware address +* Returns: +* 0 on success, else 1. +*/ +extern int eth_setenv_enetaddr_by_index (const char *base_name,int index, +const uchar *enetaddr); + +/* * The u-boot policy does not allow hardcoded ethernet addresses. Under the * following circumstances a random generated address is allowed: * - in emergency cases, where you need a working network connection to set
net/eth.c +8 -0
@@ -62,6 +62,14 @@ int eth_getenv_enetaddr_by_index(const char *base_name, int index,return eth_getenv_enetaddr (enetvar, enetaddr); } +int eth_setenv_enetaddr_by_index (const char *base_name,int index, +const uchar *enetaddr) +{ +char enetvar[32 ]; +sprintf (enetvar, index ?"%s%daddr" :"%saddr" , base_name, index); +return eth_setenv_enetaddr (enetvar, enetaddr); +} +static int eth_mac_skip (int index) {char enetvar[15 ];
Signature · 1 line
1.7.2.5
PATCH v4 3/3 net: add eth_setenv_enetaddr_by_index()
Dear Michael Walle,
Quoted 1 line · In message <[email protected]> you wrote:
Signed-off-by Michael Walle <[email protected]>
How many boards will be using this code?
Eventually this should be made configurable?
net/eth.c int eth_getenv_enetaddr_by_index(const char *base_name, int index, · line 69
Quoted 1 line
net/eth.c +1
-0+sprintf (enetvar, index ?"%s%daddr" :"%saddr" , base_name, index);
This should generate a warning: too many arguments for format.
Please fix.
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de In the pitiful, multipage, connection-boxed form to which the flow- chart has today been elaborated, it has proved to be useless as a design tool -- programmers draw flowcharts after, not before, writing the programs they describe. - Fred Brooks, Jr.
PATCH v4 3/3 net: add eth_setenv_enetaddr_by_index()
Am Freitag 11 Mai 2012, 21:25:27 schrieb Wolfgang Denk:
Quoted 6 lines
Dear Michael Walle,
Quoted 1 line · In message <[email protected]> you wrote:
Signed-off-by Michael Walle <[email protected]>How many boards will be using this code?
Hopefully more boars will use this function in the future, instead of messing around with the variable names themselves.
Quoted 1 line
Eventually this should be made configurable?
Given the above, i would keep it non-configurable if youre fine with that.
Quoted 4 lines
net/eth.c int eth_getenv_enetaddr_by_index(const char *base_name, int index, · line 69
Quoted 2 lines
net/eth.c +1
-0+sprintf (enetvar, index ?"%s%daddr" :"%saddr" , base_name, index);This should generate a warning: too many arguments for format.
Mh, nice catch. That was just copied from the eth_getenv_enetaddr_by_index() function. I'll fix all of them.
Signature · 1 line
michael
PATCH v4 3/3 net: add eth_setenv_enetaddr_by_index()
Dear Michael Walle,
Quoted 3 lines · In message <[email protected]> you wrote:
Quoted 2 lines
Eventually this should be made configurable?
Given the above, i would keep it non-configurable if youre fine with that.
Only if the code size for the existing boards that don't need this does not grow.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de If you fail to plan, plan to fail.
PATCH v4 3/3 net: add eth_setenv_enetaddr_by_index()
Am Freitag 11 Mai 2012, 23:16:02 schrieb Wolfgang Denk:
Quoted 10 lines
Dear Michael Walle,
Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 1 line
Eventually this should be made configurable?
Given the above, i would keep it non-configurable if youre fine with that.
Only if the code size for the existing boards that don't need this does not grow.
Well i can't add a new function without increasing the filesize, can i?
Using inline functions would be one option, but that would be inconsistend with the eth_getenv_enetaddr_by_index().
phew, i wonder how the eth_getenv_enetaddr_by_index() made it into uboot ;)
Signature · 1 line
michael
v4 cover net: helper functions
In reply to Michael WalleAm Donnerstag 10 Mai 2012, 19:32:11 schrieb Michael Walle:
Quoted 2 lines
This patchset is a split-off from my patch series "Kirkwood: add lschlv2 and lsxhl board support".
Hi Joe,
will you ack/nak these patch series and in case of an ack, Prafulla will fetch these into his tree? Or how is it supposed to work?
Signature · 1 line
Michael
v4 cover net: helper functions
Hi Michael,
Quoted 8 lines · Michael Walle
Am Donnerstag 10 Mai 2012, 19:32:11 schrieb Michael Walle:
Quoted 2 lines
This patchset is a split-off from my patch series "Kirkwood: add lschlv2 and lsxhl board support".
Hi Joe,
will you ack/nak these patch series and in case of an ack, Prafulla will fetch these into his tree? Or how is it supposed to work?
It is up to Prafulla. If it makes more sense due to being required for your other patch, then it can go through his branch. Let me know.
-Joe
v4 cover net: helper functions
Quoted 18 lines
-----Original Message-----
From: Joe Hershberger [mailto:joe.hershberger at gmail.com]
Sent: 11 May 2012 09:47
To: Michael Walle
Cc: u-boot at lists.denx.de; Prafulla Wadaskar
Subject: Re: [PATCH v4 0/3] net: helper functionsHi Michael,
Quoted 2 lines · Michael Walle
Am Donnerstag 10 Mai 2012, 19:32:11 schrieb Michael Walle:
Quoted 1 line
This patchset is a split-off from my patch series "Kirkwood: add
lschlv2
Quoted 2 lines
Quoted 1 line
and lsxhl board support".
Quoted 8 lines
Quoted 3 lines
Hi Joe,
will you ack/nak these patch series and in case of an ack, Prafulla
will fetch
Quoted 1 line
these into his tree? Or how is it supposed to work?
It is up to Prafulla. If it makes more sense due to being required for your other patch, then it can go through his branch. Let me know.
I will check on this patch in this week end since I am travelling.
Regards..
Prafulla . . .
v4 cover net: helper functions
Am Freitag 11 Mai 2012, 18:51:09 schrieb Prafulla Wadaskar:
Quoted 1 line
I will check on this patch in this week end since I am travelling.
Hi Prafulla,
did you find the time to review the arm/board specific patches in this series
(http://patchwork.ozlabs.org/patch/158627/)?
Signature · 1 line
Michael
v4 cover net: helper functions
In reply to Michael WalleDear Michael Walle,
Quoted 10 lines · In message <[email protected]> you wrote:
This patchset is a split-off from my patch series "Kirkwood: add lschlv2 and lsxhl board support".
Changes:
v4:
- typo fixes (thanks Mike)
- seed all 46bits of the generated ethernet address (suggested by Mike)
v3, v2:
[contained only lsxhl board changes]
Quoted 4 lines
Michael Walle (3):
lib: addrand()function
net: add helper to generate random mac address
net: addeth_setenv_enetaddr_by_index()
This patchset alone just adds unused (= dead code), and will not be added because of this.
Please submit with the patches that actually use this code.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The IQ of the group is the lowest IQ of a member of the group divided by the number of people in the group.
v4 cover net: helper functions
Am Freitag 11 Mai 2012, 21:18:50 schrieb Wolfgang Denk:
Quoted 20 lines
Dear Michael Walle,
Quoted 9 lines · In message <[email protected]> you wrote:
This patchset is a split-off from my patch series "Kirkwood: add lschlv2 and lsxhl board support".
Changes:
v4:
- typo fixes (thanks Mike)
- seed all 46bits of the generated ethernet address (suggested by Mike)Quoted 7 lines
v3, v2:
[contained only lsxhl board changes]Michael Walle (3):
lib: addrand()function
net: add helper to generate random mac address
net: addeth_setenv_enetaddr_by_index()
Quoted 4 lines
This patchset alone just adds unused (= dead code), and will not be added because of this.
Please submit with the patches that actually use this code.
Please have a look at
"[PATCH v4] Kirkwood: add lschlv2 and lsxhl board support"
All introduced functions are used by this bsp. The original patch series was split because those three patches affect the net subsystem and should be reviewed/picked by Joe Hershberger.
Signature · 1 line
Michael
v4 cover net: helper functions
Dear Michael Walle,
Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 2 lines
Please submit with the patches that actually use this code.
Please have a look at
"[PATCH v4] Kirkwood: add lschlv2 and lsxhl board support"All introduced functions are used by this bsp. The original patch series was split because those three patches affect the net subsystem and should be reviewed/picked by Joe Hershberger.
Keep these patches together, please. The responsible custodians can still ACK individual patches of the series.
The fact that only a single board ever needed these functions makes me wonder if these are really of any general use.
In any case, I want to see these configurable, so that boards that do not need these will not have to suffer.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de When in doubt, mumble; when in trouble, delegate; when in charge, ponder. -- James H. Boren
v4 cover net: helper functions
Am Freitag 11 Mai 2012, 22:43:16 schrieb Wolfgang Denk:
Quoted 1 line
Keep these patches together, please. The responsible
custodians can
Quoted 3 lines
still ACK individual patches of the series.
The fact that only a single board ever needed these
functions makes me
Quoted 1 line
wonder if these are really of any general use.
Sorry, Prafulla asked me to split the patches, so should i combine them with the v5 respin again?
Quoted 1 line
In any case, I want to see these configurable, so that
boards that do
Quoted 1 line
not need these will not have to suffer.
Agreed.
What about the rand function? I guess that should be two compile time options
- CONFIG_RAND
- CONFIG_RANDOM_HWADDR
Any better names?
Signature · 1 line
Michael
v4 cover net: helper functions
Dear Michael Walle,
Quoted 8 lines · In message <[email protected]> you wrote:
What about the rand function? I guess that should be two compile time options
-
CONFIG_RAND
-CONFIG_RANDOM_HWADDRAny better names?
Please make this a single option, CONFIG_RANDOM_MACADDR. It appears nobody else ever needed a random number before, and we can still factor this out if another user pops up after another 12 years.
Eventually, also move the code together.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "The lesser of two evils -- is evil." - Seymour (Sy) Leon
v4 cover net: helper functions
Am Freitag 11 Mai 2012, 23:14:25 schrieb Wolfgang Denk:
Quoted 6 lines
Dear Michael Walle,
Quoted 3 lines · In message <[email protected]> you wrote:
What about the rand function? I guess that should be two compile time options
Quoted 8 lines
Quoted 4 lines
-
CONFIG_RAND
-CONFIG_RANDOM_HWADDRAny better names?
Please make this a single option,
CONFIG_RANDOM_MACADDR. It appears nobody else ever needed a random number before, and we can still factor this out if another user pops up after another 12 years.
from net/net.c:
unsigned int random_port(void)
{
return 1024 + (get_timer(0) % 0x4000);
}CONFIG_BOOTP_RANDOM_DELAY, in net/bootp.c
Signature · 1 line
michael
v4 cover net: helper functions
Dear Michael Walle,
Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 9 lines
Quoted 5 lines
-
CONFIG_RAND
-CONFIG_RANDOM_HWADDRAny better names?
Please make this a single option,
CONFIG_RANDOM_MACADDR. It appears nobody else ever needed a random number before, and we can still factor this out if another user pops up after another 12 years.
Quoted 7 lines
from
net/net.c:
unsigned intrandom_port(void){ return 1024 + (get_timer(0) % 0x4000); }
CONFIG_BOOTP_RANDOM_DELAY, innet/bootp.c
Well, you patch did not change this code.
And I have to admit that I doubt the increased code size would be worth such a change, at this place.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de core error - bus dumped
v4 cover net: helper functions
Am Freitag 11 Mai 2012, 23:30:59 schrieb Wolfgang Denk:
Quoted 4 lines
Well, you patch did not change this code.
And I have to admit that I doubt the increased code size would be worth such a change, at this place.
Ok, can we agree on keeping the rand function in lib/ but using just one macro CONFIG_RANDOM_MACADDR?
Signature · 1 line
Michael
v4 cover net: helper functions
Dear Michael Walle,
Quoted 7 lines · In message <[email protected]> you wrote:
Am Freitag 11 Mai 2012, 23:30:59 schrieb Wolfgang Denk:
Quoted 4 lines
Well, you patch did not change this code.
And I have to admit that I doubt the increased code size would be worth such a change, at this place.
Ok, can we agree on keeping the rand function in
lib/but using just one macroCONFIG_RANDOM_MACADDR?
Yes, that should do for now. thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The complexity of software is an essential property, not an acciden- tal one. Hence, descriptions of a software entity that abstract away its complexity often abstract away its essence. - Fred Brooks, Jr.
v4 cover net: helper functions
In reply to Michael WalleQuoted 14 lines · On Friday 11 May 2012 17:22:23 Michael Walle wrote:
Am Freitag 11 Mai 2012, 23:14:25 schrieb Wolfgang Denk:
Quoted 4 lines
Quoted 3 lines · Michael Walle
What about the rand function? I guess that should be two compile time options
Quoted 8 lines
Quoted 4 lines
-
CONFIG_RAND
-CONFIG_RANDOM_HWADDRAny better names?
Please make this a single option,
CONFIG_RANDOM_MACADDR. It appears nobody else ever needed a random number before, and we can still factor this out if another user pops up after another 12 years.
Quoted 7 lines
from
net/net.c:
unsigned intrandom_port(void){ return 1024 + (get_timer(0) % 0x4000); }
CONFIG_BOOTP_RANDOM_DELAY, innet/bootp.c
note that if you do change this code, the 0x4000 clamp is important. read the git history of this file/func fore more details.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120514/ef9e58c9/attachment.pgp>