From: Michael Walle Date: Wed, 30 May 2012 00:54:58 +0200 Subject: [U-Boot] [PATCH v3 02/21] net: Move MAC-seeded rand out of bootp.c In-Reply-To: References: <1332891772-17279-1-git-send-email-joe.hershberger@ni.com> <201205300006.19410.michael@walle.cc> Message-ID: <201205300054.58897.michael@walle.cc> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Joe, Am Mittwoch 30 Mai 2012, 00:40:18 schrieb Joe Hershberger: > > Ah now i get it. But which other code may run and seed the NG with the > > timer only, while we are in the link local netloop? Shouldn't it be safe > > to first call srand(mac+timer) and then rand() multiple times? No other > > code can be run unless NetLoop(LINKLOCAL) returns, right? > > It needs to run multiple times, yes. But it will also process any > packets that are received when executing any other net command later. > The state machine will keep running. There can obviously be other > commands that run in between. i guess i have to study the netloop a bit more ;) > > Perhaps we can separate the state for the PRNG between the 2 cases but > share the code. yeah i was thinking of rand_r(). > >> The most naive way around it > >> would be to rename the rand() in net to rand_mac() or something like > >> that and not attempt to combine them. > > > > i think we should focus on combining not reinventing the wheel multiple > > times. > > Agreed, but we have to solve the problem above. fully argreeing ;) -- michael