From: Mika Liljeberg <Mika.Liljeberg@welho.com>
To: Dan Kegel <dank@kegel.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tcp_v4_get_port() and ephemeral ports
Date: Mon, 01 Oct 2001 00:45:58 +0300 [thread overview]
Message-ID: <3BB79296.677458C5@welho.com> (raw)
In-Reply-To: <3BB75EB4.3268D3FC@kegel.com> <3BB7676C.1213CC84@welho.com> <3BB78291.F8732D4@kegel.com>
Dan Kegel wrote:
> Depends on what you mean by real-life situations. If you actually
> need to handle over ten thousand outgoing connections, this change
> could indeed help relieve port exhaustion. Think of web spiders
> or web caches on gigabit/sec links.
I should have said most real life situations. The point is simply that
there are relatively few real life applications where port exhaustion
can occur and even there it can be avoided by making the client a little
bit smarter. Granted, web spiders and caches are examples of these
applications.
> Perhaps one could go further, and have the kernel pick an ip address as
> well; that would make the app even easier to code. [...]
> Making this pick an alias at random
> is kind of a gross thought. [...]
Well, source address selection is really a policy decision and it would
be nice to have the policy tools to affect the source address selection
algorithm. This would be especially interesting with IPv6 where aliases
are par for the course and address privacy is something of an issue.
However, I'm not really sure what the best way of defining that policy
would be.
For your application you would need randomization or round-robin for a
kind of a load balancing. For address privacy you might want to simply
set a preferred address on each interface for outbound connections. From
routing standpoint you would like to select the address that is the best
match (e.g. longest prefix match) for the destination, to ensure
shortest return path. You would also need to combine this with scoping
rules.
> > Or you could even pick a completely empty port range and bind
> > each client socket with the SO_REUSE flag (which is ok, since your
> > clients are using different source addresses).
>
> SO_REUSE might let my app's connections collide with those
> of other apps, wouldn't it? Doesn't seem very clean. A web cache
> or web spider probably wouldn't use SO_REUSE, would it?
As long as you ensure that you don't have any listening sockets in the
port range you're using for the client connections this is a valid
technique. It would actually be especially useful for proxies and web
crawlers. Even though sharing the same source address and port between
multiple client sockets, the kernel still wont allow you to create two
connections to the same {destination address,port} pair, ensuring that
each connection 5-tuple is unique.
Granted, this takes a little book keeping in the application, but to run
out of ports you would have to make thousands of connections to the same
server (as your performance tool does). Even web crawlers can easily
avoid this by rate limiting the connections to a single target and
scanning multiple target hosts in parallel.
> I guess I'm resigned to managing the ephemeral port number in my app.
> A bit of a pain, but that's life.
It's probably still easiest to do this in the application. :)
Cheers,
Mika Liljeberg
next prev parent reply other threads:[~2001-09-30 21:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-09-30 18:04 [PATCH] tcp_v4_get_port() and ephemeral ports Dan Kegel
2001-09-30 18:16 ` Davide Libenzi
2001-09-30 18:29 ` Dan Kegel
2001-09-30 18:41 ` Mika Liljeberg
2001-09-30 20:37 ` Dan Kegel
2001-09-30 21:45 ` Mika Liljeberg [this message]
2001-09-30 20:53 ` Chris Wedgwood
-- strict thread matches above, loose matches on Subject: below --
2001-09-30 21:15 Andi Kleen
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=3BB79296.677458C5@welho.com \
--to=mika.liljeberg@welho.com \
--cc=dank@kegel.com \
--cc=linux-kernel@vger.kernel.org \
/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