From: Eric Dumazet <dada1@cosmosbay.com>
To: Octavian Purdila <opurdila@ixiacom.com>
Cc: netdev@vger.kernel.org
Subject: Re: ports beeing reused too fast
Date: Sat, 09 May 2009 08:58:25 +0200 [thread overview]
Message-ID: <4A052991.5040009@cosmosbay.com> (raw)
In-Reply-To: <200905082311.09414.opurdila@ixiacom.com>
Octavian Purdila a écrit :
> Hi,
>
> We've been running into an issue where a firewall would drop packets when an
> moderate (~360) connection rate was going through it. It looks like the
> firewall is dropping the SYNs that reuse ports "too fast".
>
> We have no issues with Linux 2.6.7, so I guess the behavior changed because of
> this this commit:
>
> commit 6df716340da3a6fdd33d73d7ed4c6f7590ca1c42
> Author: Stephen Hemminger <shemminger@osdl.org>
> Date: Thu Nov 3 16:33:23 2005 -0800
>
> [TCP/DCCP]: Randomize port selection
>
>
> Now, I did some tests to confirm my suspicion. Basically, I am simulating a
> connection rate test (I've attached the .c to this email) by opening up
> connections and closing them - one at a time, and noting down the ports used,
> then looking for duplicate ports and printing the distance between the
> connection no.
>
> Here is one of the runs, which make 1000 iterations:
>
> listening (port 1242)
> port reused: 38203: distance 578 (624,46)
> port reused: 55693: distance 85 (147,62)
> port reused: 38269: distance 803 (872,69)
> port reused: 46239: distance 249 (344,95)
> port reused: 40981: distance 215 (319,104)
> port reused: 46246: distance 524 (641,117)
> port reused: 43990: distance 378 (498,120)
> port reused: 53766: distance 52 (232,180)
> port reused: 44199: distance 194 (383,189)
> port reused: 59464: distance 173 (384,211)
> port reused: 44417: distance 264 (492,228)
> port reused: 56989: distance 229 (553,324)
> port reused: 60117: distance 69 (394,325)
> port reused: 44549: distance 179 (566,387)
> port reused: 39213: distance 300 (801,501)
> port reused: 60166: distance 152 (671,519)
> port reused: 44178: distance 108 (712,604)
> port reused: 46516: distance 6 (792,786)
> port reused: 55754: distance 95 (969,874)
> 19 ports were being reused
>
> Running the same test on 2.6.7 yields a "0 ports were being reused" on all
> tests that I've ran (10 or so).
>
> Isn't it desirable to have the behavior from 2.6.7?
>
> I've looked over the code and it looks right, so maybe net_random() is not
> random enough? Or maybe there are side effects because of the % port_range?
>
Random is random :)
Probability a port can be reused pretty fast is not nul.
So yes, behavior you discovered is expected, when we switched port selection
from a sequential one (not very secure btw) to a random one.
Any strong reason why a firewall would drop a SYN because ports were used in a
previous session ?
Previous mode can be restored by application itself, using a bind() before
connect(), if this application knows it has a very high rate of connections
from a particular host to a particular host. (source ports range being
small anyway, so your firewall could complain again)
next prev parent reply other threads:[~2009-05-09 6:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-08 20:11 ports beeing reused too fast Octavian Purdila
2009-05-09 6:58 ` Eric Dumazet [this message]
2009-05-09 13:11 ` Octavian Purdila
2009-05-09 15:17 ` Eric Dumazet
2009-05-09 16:16 ` Eric Dumazet
2009-05-09 19:31 ` Bill Fink
2009-05-09 19:41 ` Octavian Purdila
2009-05-09 22:45 ` Stephen Hemminger
2009-05-12 12:32 ` Octavian Purdila
2009-05-12 15:11 ` Stephen Hemminger
2009-05-12 15:52 ` Octavian Purdila
2009-05-14 20:29 ` Stephen Hemminger
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=4A052991.5040009@cosmosbay.com \
--to=dada1@cosmosbay.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).