[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <490B350E.3080401@cosmosbay.com>
Date: Fri, 31 Oct 2008 17:40:46 +0100
From: Eric Dumazet <dada1@...mosbay.com>
To: paulmck@...ux.vnet.ibm.com
CC: Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Corey Minyard <minyard@....org>,
David Miller <davem@...emloft.net>, shemminger@...tta.com,
benny+usenet@...rsen.dk, netdev@...r.kernel.org,
Christoph Lameter <cl@...ux-foundation.org>,
johnpol@....mipt.ru, Christian Bell <christian@...i.com>
Subject: Re: [PATCH 2/2] udp: RCU handling for Unicast packets.
Paul E. McKenney a écrit :
> On Thu, Oct 30, 2008 at 12:30:20PM +0100, Eric Dumazet wrote:
>> - while (udp_lib_lport_inuse(net, snum, udptable, sk,
>> - saddr_comp)) {
>> + for (;;) {
>> + hslot = &udptable->hash[udp_hashfn(net, snum)];
>> + spin_lock_bh(&hslot->lock);
>> + if (!udp_lib_lport_inuse(net, snum, hslot, sk, saddr_comp))
>> + break;
>> + spin_unlock_bh(&hslot->lock);
>> do {
>> snum = snum + rand;
>> } while (snum < low || snum > high);
>
> The above -really- confuses me, but not part of this patch. If we are
> out of range, keep going? Well, I guess that since it is a short, we
> cannot go very far...
>
>> if (snum == first)
>> goto fail;
>
> And I don't understand how we are guaranteed to have scanned all the
> possible ports upon failure, but happy to leave that to you guys.
Well, we have 65536(=2^16) possible port values, and while 'rand' is random,
it has the interesting property/bias of being odd.
We know (thanks modular arithmetic / congruence relation) we will hit
all 65356 values exactly once, after exactly 65536 iterations.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists