Skip to contentSkip to conversation

use default 32768-61000 outgoing port range in all cases

PATCH In review Mark Glines 2 participants 2 messages May 15, 2007 – May 31, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 use default 32768-61000 outgoing port range in all cases

Hi,

I noticed I had chopped off a whole comment, when I meant to only remove part of it. So I've fixed that.

This is a reissued use-high-ports-for-local-stuff.diff, with a comment fix. Does anyone have a problem with this patch in its current form? Any chance of applying it?

This diff changes the default port range used for outgoing connections, from "use 32768-61000 in most cases, but use N-4999 on small boxes (where N is a multiple of 1024, depending on just *how* small the box is)" to just "use 32768-61000 in all cases".

I don't believe there are any drawbacks to this change, and it keeps outgoing connection ports farther away from the mess of IANA-registered ports.

Thanks,

net/ipv4/inet_connection_sock.c +1 -3
index 43fb160..fbe7714 100644
@@ -31,10 +31,8 @@ EXPORT_SYMBOL(inet_csk_timer_bug_msg);
 
 /*
  * This array holds the first and last local port number.
- * For high-usage systems, use sysctl to change this to
- * 32768-61000
  */
-int sysctl_local_port_range[2] = { 1024, 4999 };
+int sysctl_local_port_range[2] = { 32768, 61000 };
 
 int inet_csk_bind_conflict(const struct sock *sk,
 			   const struct inet_bind_bucket *tb)
net/ipv4/tcp.c +0 -3
index bd4c295..33ef0e7 100644
@@ -2465,13 +2465,10 @@ void __init tcp_init(void)
 			order++)
 		;
 	if (order >= 4) {
-		sysctl_local_port_range[0] = 32768;
-		sysctl_local_port_range[1] = 61000;
 		tcp_death_row.sysctl_max_tw_buckets = 180000;
 		sysctl_tcp_max_orphans = 4096 << (order - 4);
 		sysctl_max_syn_backlog = 1024;
 	} else if (order < 3) {
-		sysctl_local_port_range[0] = 1024 * (3 - order);
 		tcp_death_row.sysctl_max_tw_buckets >>= (3 - order);
 		sysctl_tcp_max_orphans >>= (3 - order);
 		sysctl_max_syn_backlog = 128;
maintainer
#1 lore raw

From: Mark Glines <[email protected]>
Date: Tue, 15 May 2007 15:50:54 -0700

Quoted 12 lines

I noticed I had chopped off a whole comment, when I meant to only remove part of it. So I've fixed that.

This is a reissued use-high-ports-for-local-stuff.diff, with a comment fix. Does anyone have a problem with this patch in its current form? Any chance of applying it?

This diff changes the default port range used for outgoing connections, from "use 32768-61000 in most cases, but use N-4999 on small boxes (where N is a multiple of 1024, depending on just *how* small the box is)" to just "use 32768-61000 in all cases".

Quoted 5 lines

I don't believe there are any drawbacks to this change, and it keeps outgoing connection ports farther away from the mess of IANA-registered ports.

Sorry for taking forever to wrap my brain around this, I think your patch is the way to go and I will merge it.

The code was trying to match the allowed port range with the sizing of the bind hash table, which is hashed by local port number. But even considering that I think it's OK to use the full range by default, always.

Thanks a lot.