netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Zhiqiang Liu <liuzhiqiang26@huawei.com>,
	Eric Dumazet <edumazet@google.com>,
	Mao Wenan <maowenan@huawei.com>
Cc: David Miller <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net] tcp: avoid creating multiple req socks with the same tuples
Date: Wed, 5 Jun 2019 07:18:44 -0700	[thread overview]
Message-ID: <91520bf3-42dd-a727-a706-0ff7711fe1d8@gmail.com> (raw)
In-Reply-To: <40f32663-f100-169c-4d1b-79d64d68a5f9@huawei.com>



On 6/5/19 1:52 AM, Zhiqiang Liu wrote:
> 
> 
> 在 2019/6/4 23:24, Eric Dumazet 写道:
>> On Tue, Jun 4, 2019 at 7:47 AM Mao Wenan <maowenan@huawei.com> wrote:
>>>
>>> There is one issue about bonding mode BOND_MODE_BROADCAST, and
>>> two slaves with diffierent affinity, so packets will be handled
>>> by different cpu. These are two pre-conditions in this case.
> 
>>> Signed-off-by: Mao Wenan <maowenan@huawei.com>
>>> --
>>
>> This issue has been discussed last year.
>>
>> I am afraid your patch does not solve all races.
>>
>> The lookup you add is lockless, so this is racy.
>>
>> Really the only way to solve this is to make sure that _when_ the
>> bucket lock is held,
>> we do not insert a request socket if the 4-tuple is already in the
>> chain (probably in inet_ehash_insert())
>>
>> This needs more tricky changes than your patch.
>>
> 
> This kind case is rarely used, and the condition of the issue is strict.
> If we add the "lookup" before or in inet_ehash_insert func for each reqsk,
> overall performance will be affected.
> 
> We may solve the small probability issue with a trick in the tcp_v4_rcv.
> If the ACK is invalid checked by tcp_check_req func, the req could be dropped,
> and then goto the lookup for searching another avaliable reqsk. In this way,
> the performance will not be affected in the normal process.
> 
> The patch is given as following:
> diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> index a2896944aa37..9d0491587ed2 100644
> --- a/net/ipv4/tcp_ipv4.c
> +++ b/net/ipv4/tcp_ipv4.c
> @@ -1874,8 +1874,10 @@ int tcp_v4_rcv(struct sk_buff *skb)
>                         goto discard_and_relse;
>                 }
>                 if (nsk == sk) {
> -                       reqsk_put(req);
> +                       inet_csk_reqsk_queue_drop_and_put(sk, req);
>                         tcp_v4_restore_cb(skb);
> +                       sock_put(sk);
> +                       goto lookup;
>                 } else if (tcp_child_process(sk, nsk, skb)) {
>                         tcp_v4_send_reset(nsk, skb);
>                         goto discard_and_relse;
> 

This is not solving the race.

Please read again my prior emails.

If you want to work on this issue, you have to fix it for good.

Thanks.

      parent reply	other threads:[~2019-06-05 14:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04 14:55 [PATCH net] tcp: avoid creating multiple req socks with the same tuples Mao Wenan
2019-06-04 15:24 ` Eric Dumazet
2019-06-05  2:06   ` maowenan
2019-06-05  3:16     ` Eric Dumazet
2019-06-05  8:52   ` Zhiqiang Liu
2019-06-05 10:49     ` [PATCH net] inet_connection_sock: remove unused parameter of reqsk_queue_unlink func Zhiqiang Liu
2019-06-05 14:10       ` Eric Dumazet
2019-06-06  1:49       ` David Miller
2019-06-06  2:06         ` Zhiqiang Liu
2019-06-06  2:19           ` David Miller
2019-06-06  2:29             ` Zhiqiang Liu
2019-06-05 14:18     ` Eric Dumazet [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=91520bf3-42dd-a727-a706-0ff7711fe1d8@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuzhiqiang26@huawei.com \
    --cc=maowenan@huawei.com \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).