Commit ed2dfd90 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

tcp/dccp: warn user for preferred ip_local_port_range

After commit 07f4c900 ("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.
Suggested-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e2baad9e
...@@ -19,6 +19,7 @@ struct sock; ...@@ -19,6 +19,7 @@ struct sock;
struct local_ports { struct local_ports {
seqlock_t lock; seqlock_t lock;
int range[2]; int range[2];
bool warned;
}; };
struct ping_group_range { struct ping_group_range {
......
...@@ -45,7 +45,13 @@ static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX }; ...@@ -45,7 +45,13 @@ static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
/* Update system visible IP port range */ /* Update system visible IP port range */
static void set_local_port_range(struct net *net, int range[2]) static void set_local_port_range(struct net *net, int range[2])
{ {
bool same_parity = !((range[0] ^ range[1]) & 1);
write_seqlock(&net->ipv4.ip_local_ports.lock); write_seqlock(&net->ipv4.ip_local_ports.lock);
if (same_parity && !net->ipv4.ip_local_ports.warned) {
net->ipv4.ip_local_ports.warned = true;
pr_err_ratelimited("ip_local_port_range: prefer different parity for start/end values.\n");
}
net->ipv4.ip_local_ports.range[0] = range[0]; net->ipv4.ip_local_ports.range[0] = range[0];
net->ipv4.ip_local_ports.range[1] = range[1]; net->ipv4.ip_local_ports.range[1] = range[1];
write_sequnlock(&net->ipv4.ip_local_ports.lock); write_sequnlock(&net->ipv4.ip_local_ports.lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment