Subject: Re: kernel ip_randomid() and libc randomid(3) still "broken"
To: Jonathan Stone <jonathan@DSG.Stanford.EDU>
From: Charles M. Hannum <abuse@spamalicious.com>
List: tech-net
Date: 11/27/2003 03:29:25
On Wednesday 26 November 2003 10:06 pm, Jonathan Stone wrote:
> In message <200311262148.55560.abuse@spamalicious.com>,
>
> "Charles M. Hannum" write:
> >When are you going to wake up to the rather obvious fact that the
> > "guarantee" has been thoroughly disproven?  It was clearly shown that
> > *consecutive* calls to ip_randomid() can return the same number.
>
> Charles, be fair.  At this point we're all discussing the less-broken
> version which repeats every 12,000 IDs or so.

Having tested and analyzed the code as updated yesterday, I can say that the 
best guarantee it provides -- assuming the LCG never fails -- is actually 
7501, not 12000.  In practice, it's around 11800 -- 40% of 30000 due to the 
arc4random() stirring, minus some slop due to multiple biases.

Anyway, more about speed.  In a test setup, I've modified the code so that it 
takes ~33s to generate 100,000,000 IDs, as opposed to 78s from the original 
code.  I wonder, though, if there is anything actually lost by using a 
power-of-2 modulus, which would significantly reduce the cost of the final 
exponentiation.