]> git.baikalelectronics.ru Git - kernel.git/commit
tcp: improve REUSEADDR/NOREUSEADDR cohabitation
authorEric Dumazet <edumazet@google.com>
Wed, 20 May 2015 17:59:02 +0000 (10:59 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 May 2015 22:55:32 +0000 (18:55 -0400)
commit63e0bc6f42388485640411066416482964d234f3
treee57418581cf0adc129548c9427730f70b84045da
parenta0c4db853645b558bf3b55fc23c580b89dd4ad61
tcp: improve REUSEADDR/NOREUSEADDR cohabitation

inet_csk_get_port() randomization effort tends to spread
sockets on all the available range (ip_local_port_range)

This is unfortunate because SO_REUSEADDR sockets have
less requirements than non SO_REUSEADDR ones.

If an application uses SO_REUSEADDR hint, it is to try to
allow source ports being shared.

So instead of picking a random port number in ip_local_port_range,
lets try first in first half of the range.

This gives more chances to use upper half of the range for the
sockets with strong requirements (not using SO_REUSEADDR)

Note this patch does not add a new sysctl, and only changes
the way we try to pick port number.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Marcelo Ricardo Leitner <mleitner@redhat.com>
Cc: Flavio Leitner <fbl@redhat.com>
Acked-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/inet_connection_sock.c