[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANn89iLF9HEaPhMJn1U7zU-ewCOMVv2Azsu4cGPXr5h0a0WRFQ@mail.gmail.com>
Date: Mon, 29 Jul 2024 18:16:39 +0200
From: Eric Dumazet <edumazet@...gle.com>
To: Kuniyuki Iwashima <kuniyu@...zon.com>
Cc: xiaolinkui@....com, davem@...emloft.net, dsahern@...nel.org,
kuba@...nel.org, netdev@...r.kernel.org, pabeni@...hat.com,
xiaolinkui@...inos.cn
Subject: Re: [PATCH] tcp/dccp: Add another way to allocate local ports in connect()
On Mon, Jul 29, 2024 at 5:57 PM Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
>
> From: xiaolinkui@....com
> Date: Mon, 29 Jul 2024 17:55:54 +0800
> > 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.
>
> The application should be changed, or probably you can put your application
> into a cgroup and hook connect() to call bpf_setsockopt() and silently
> enable IP_LOCAL_PORT_RANGE.
LD_PRELOAD can also be used for non eBPF users.
Powered by blists - more mailing lists