Commit 208a7204 authored by Lu Wei's avatar Lu Wei Committed by Zhengchao Shao
Browse files

tcp/dccp: Add another way to allocate local ports in connect()

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8KBYH



--------------------------------

Commit 07f4c900 ("tcp/dccp: try to not exhaust ip_local_port_range
in connect()") allocates even ports for connect() first while leaving
odd ports for bind() and this works well in busy servers.

But this strategy causes severe performance degradation in busy clients.
when a client has used more than half of the local ports setted in
proc/sys/net/ipv4/ip_local_port_range, if this client trys to connect
to a server again, the connect time increases rapidly since it will
traverse all the even ports though they are exhausted.

So this path provides another strategy by introducing a system option:
local_port_allocation. If it is a busy client, users should set it to 1
to use sequential allocation while it should be set to 0 in other
situations. Its default value is 0.

Signed-off-by: default avatarLu Wei <luwei32@huawei.com>
Signed-off-by: default avatarLiu Jian <liujian56@huawei.com>

Conflicts:
	include/net/tcp.h
	net/ipv4/inet_hashtables.c
	net/ipv4/sysctl_net_ipv4.c

Signed-off-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
parent 357e8ab1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment