[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iKxeYhqO-zNG5cTxw_o_3ORhcsXN7OJvFbhxPUEcoB3nA@mail.gmail.com>
Date: Mon, 29 Jul 2024 14:46:38 +0200
From: Eric Dumazet <edumazet@...gle.com>
To: xiaolinkui@....com
Cc: davem@...emloft.net, dsahern@...nel.org, kuba@...nel.org,
pabeni@...hat.com, netdev@...r.kernel.org,
Linkui Xiao <xiaolinkui@...inos.cn>
Subject: Re: [PATCH] tcp/dccp: Add another way to allocate local ports in connect()
On Mon, Jul 29, 2024 at 11:56 AM <xiaolinkui@....com> wrote:
>
> From: Linkui Xiao <xiaolinkui@...inos.cn>
>
> Commit 07f4c90062f8 ("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 try 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.
>
> In commit 207184853dbd ("tcp/dccp: change source port selection at
> connect() time"), tell users that they can access all odd and even ports
> by using IP_LOCAL_PORT_RANGE. But this requires users to modify the
> socket application. When even numbered ports are not sufficient, use the
> sysctl parameter to achieve the same effect:
> sysctl -w net.ipv4.local_port_allocation=1
>
> Signed-off-by: Linkui Xiao <xiaolinkui@...inos.cn>
Too many errors in this patch...
Lack of READ_ONCE() when reading a sysctl.
Lack or per-netns sysctl.
No documentation.
Powered by blists - more mailing lists