History

tcp/dccp: warn user for preferred ip_local_port_range

After commit 07f4c90062f8f ("tcp/dccp: try to not exhaust ip_local_port_range in connect()") it is advised to have an even number of ports described in /proc/sys/net/ipv4/ip_local_port_range This means start/end values should have a different parity. Let's warn sysadmins of this, so that they can update their settings if they want to.

Eric Dumazet committed 11 years ago

Commit ed2dfd91 parent e2baad92 files · +7 −0Browse files

Unified · Split

2 files
  1. include/net/netns/ipv4.h +1 −0
  2. net/ipv4/sysctl_net_ipv4.c +6 −0
include/net/netns/ipv4.h+1−0
@@ -19,6 +19,7 @@ struct sock; · 18 unmodified lines
1919 struct local_ports {
2020 seqlock_t lock;
2121 int range[2];
22+ bool warned;
2223 };
2324
2425 struct ping_group_range {
net/ipv4/sysctl_net_ipv4.c+6−0
@@ -45,7 +45,13 @@ static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX }; · 44 unmodified lines
4545 /* Update system visible IP port range */
4646 static void set_local_port_range(struct net *net, int range[2])
4747 {
48+ bool same_parity = !((range[0] ^ range[1]) & 1);
49+
4850 write_seqlock(&net->ipv4.ip_local_ports.lock);
51+ if (same_parity && !net->ipv4.ip_local_ports.warned) {
52+ net->ipv4.ip_local_ports.warned = true;
53+ pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
54+ }
4955 net->ipv4.ip_local_ports.range[0] = range[0];
5056 net->ipv4.ip_local_ports.range[1] = range[1];
5157 write_sequnlock(&net->ipv4.ip_local_ports.lock);