All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Sitnicki <jakub@cloudflare.com>
To: Eric Dumazet <edumazet@google.com>
Cc: netdev@vger.kernel.org,  Paolo Abeni <pabeni@redhat.com>,
	 "David S. Miller" <davem@davemloft.net>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Neal Cardwell <ncardwell@google.com>,
	 Kuniyuki Iwashima <kuniyu@google.com>,
	kernel-team@cloudflare.com,
	 Lee Valentine <lvalentine@cloudflare.com>
Subject: Re: [PATCH net-next v2 1/2] tcp: Consider every port when connecting with IP_LOCAL_PORT_RANGE
Date: Tue, 08 Jul 2025 16:35:00 +0200	[thread overview]
Message-ID: <874ivmhht7.fsf@cloudflare.com> (raw)
In-Reply-To: <CANn89iLm_hRW3+MHsP8p5aTUStohz0nvWbKTGZU6K3EdRadrYw@mail.gmail.com> (Eric Dumazet's message of "Tue, 8 Jul 2025 04:38:39 -0700")

On Tue, Jul 08, 2025 at 04:38 AM -07, Eric Dumazet wrote:
> On Thu, Jul 3, 2025 at 8:59 AM Jakub Sitnicki <jakub@cloudflare.com> wrote:

[...]

>> @@ -1070,6 +1107,8 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
>>                         if (!inet_bind_bucket_match(tb, net, port, l3mdev))
>>                                 continue;
>>                         if (tb->fastreuse >= 0 || tb->fastreuseport >= 0) {
>> +                               if (unlikely(local_ports))
>> +                                       break; /* optimistic assumption */
>
> I find this quite pessimistic :/
>
> It seems you had some internal code before my recent change (86c2bc293b8130
> "tcp: use RCU lookup in __inet_hash_connect()") ?
>
> Instead, make the RCU changes so that check_bound() can be called from RCU,
> and call it here before taking the decision to break off this loop.

Thanks for taking a look. I appreciate it.

That was intentional. Perhaps a bad call on my side.

My thinking here was that since we're already short on ephemeral ports
when these "blocked buckets" become an issue, then I wouldn't want to
dismiss a potential port in case the socket blocking it from reuse due
to src (IP, port) conflict goes away before we get to the second
(locked) phase of the search.

But then again, in hindsight, if we run into ephemeral port depletion,
then we must be under pressure from outgoing connections, so it seems
like a bad idea to put more stress on the bucket lock.

I will rework it as suggested.

>>                                 rcu_read_unlock();
>>                                 goto next_port;
>>                         }

[...]

      reply	other threads:[~2025-07-08 14:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03 15:59 [PATCH net-next v2 1/2] tcp: Consider every port when connecting with IP_LOCAL_PORT_RANGE Jakub Sitnicki
2025-07-03 15:59 ` [PATCH net-next v2 2/2] selftests/net: Cover port sharing scenarios " Jakub Sitnicki
2025-07-08  9:13 ` [PATCH net-next v2 1/2] tcp: Consider every port when connecting " Jakub Sitnicki
2025-07-08  9:35   ` Eric Dumazet
2025-07-08 11:38 ` Eric Dumazet
2025-07-08 14:35   ` Jakub Sitnicki [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874ivmhht7.fsf@cloudflare.com \
    --to=jakub@cloudflare.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kernel-team@cloudflare.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=lvalentine@cloudflare.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.