* Re: /proc/sys/net/ipv4/ip_local_reserved_ports
@ 2011-09-16 4:21 David Bein
0 siblings, 0 replies; only message in thread
From: David Bein @ 2011-09-16 4:21 UTC (permalink / raw)
To: linux-kernel
For the reserved port bitmap to be truly useful, there needs to be a way to
have the kernel bind (+ implicit bind in connect, datagram sendmsg, etc)
be told to use a "privileged" port range.
Has anyone ever considered adding the IP_PORTRANGE socket option
which would add 2 other port ranges: LOW (privileged -- e.g. 600-1023)
and HIGH (for high end ports, e.g. 55000-65535) for running around
firewalls.
This interface was added to FreeBSD maybe 15 years ago and in practical
terms means that glibc bindresvport() would select the privileged port
range,
set sin->sin_port to 0 and lets the kernel do the rest. Similar dance
for AF_INET6.
This does require tweaking glibc bindresvport() to handle the details.
The FreeBSD folks have the details in their versions of libc.
It is in fact faster because in the presence of a number of busy ports
the overhead of a few hundred bind() system calls is eliminated.
The kernel is very good at picking free ports, so this is just extending
where it does it without hacking ip_local_port_range to include
privileged ports (which IMO is a very bad idea).
I've prototyped the kernel ip socket option support for IP_PORTRANGE
(along with the sysctl glue for 2 more port ranges).
Using this and ip_local_reserved_ports, it is indeed possible to use
the reserved ports set in the bitmap and prevent all the usual problems
when some program innocently picks a privileged port that some other
daemon will expect to be free for a specific binding on a well known port.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-09-16 4:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-16 4:21 /proc/sys/net/ipv4/ip_local_reserved_ports David Bein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox