netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Lucian Adrian Grijincu <lgrijincu@ixiacom.com>
Cc: netdev@vger.kernel.org, Octavian Purdila <opurdila@ixiacom.com>
Subject: Re: [RFC 1/2] udp: add non-linear uniform port allocation scheme option /proc/sys/net/ipv4/udp_port_randomization
Date: Thu, 17 Dec 2009 15:07:55 +0100	[thread overview]
Message-ID: <4B2A3B3B.3000308@gmail.com> (raw)
In-Reply-To: <4B2933EF.9060606@ixiacom.com>

Le 16/12/2009 20:24, Lucian Adrian Grijincu a écrit :
> 
> When we allocate ports with a (really) high frequency, randomization
> does more harm as some values tend to repeat with a higher frequency
> than they would if allocated uniformly, while others are selected more
> rarely.
> 
> This patch does not allocate ports linearly as older kernels used to do,
> but it allocates the port with an uniform frequency.
> 
> For example: assuming UDP_HTABLE_SIZE=8, hint=3, low=0, high=32
> This leads to:
>> first=3, last=3+8=11, rand=(1 | 1) * UDP_HTABLE_SIZE=8
> 
> The port selection code is similar to:
>> for first in [3..11):
>>     snum = first
>>     do if (!good(snum)) snum+=8 while(snum!=first)
> 
> Will give the following sequence for snum (skipping `modulo 32` for
> brevity)
>   3,  3+8,  3+8+8,  3+8+8+8,
>   4,  4+8,  4+8+8,  4+8+8+8,
>  ...
>   9,  9+8,  9+8+8,  9+8+8+8,
>  10, 10+8, 10+8+8, 10+8+8+8,
> 
> This will generate all numbers in the [low..high) interval with the
> same frequency. This leads to better performance when most ports are
> already allocated.
> 
> Randomization is still enabled by default for normal setups that will
> most likely not encounter such situations.
> 

I dont like this patch, I am not convinced at all by your example.

Your example is flawed, since UDP_HTABLE_SIZE >= 128 (128 is the minimum hash size)

I cannot understand why chosing a "one" increment instead of a "random odd" increment
can give a more uniform allocation frequency.

If port randomization is not good enough, please make it better, not reverting to
plain sequential old behavior... (your application can do its own port allocation by the way)

BTW, net-next-2.6 is not yet open, this is not the right time to submit non bug fixes patches.

Thanks

  reply	other threads:[~2009-12-17 14:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-16 19:24 [RFC 1/2] udp: add non-linear uniform port allocation scheme option /proc/sys/net/ipv4/udp_port_randomization Lucian Adrian Grijincu
2009-12-17 14:07 ` Eric Dumazet [this message]
2009-12-17 15:16   ` Octavian Purdila
2009-12-17 16:00     ` Eric Dumazet
2009-12-18 13:12       ` Octavian Purdila

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B2A3B3B.3000308@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=lgrijincu@ixiacom.com \
    --cc=netdev@vger.kernel.org \
    --cc=opurdila@ixiacom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).