Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1105173ybl; Fri, 31 Jan 2020 14:13:53 -0800 (PST) X-Google-Smtp-Source: APXvYqxnEBuQhTFuzHgcxM940nn2YOzQQPWPhL+jIqZ0sbX/JE7/2RLo2/WlQ2KtdXvulqsvVZ/n X-Received: by 2002:a9d:12cf:: with SMTP id g73mr8772618otg.329.1580508833839; Fri, 31 Jan 2020 14:13:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580508833; cv=none; d=google.com; s=arc-20160816; b=F5DY0MGS9SkIU2R//Mb7T2fr+N3O8i+v8T/40uMmE0aYGxpdEgE52Iml5qGz0Btvn7 U8Ud05lR/15a3uS8E7q401RZ6m6qrjsiiaI587CEw6jzd1OOaExYh73TFNTuryiNuIZK Jw9yNEpgQ1RYI7hE/C0zXKhprHaEQlHtCFdldil/hm0VFtzD0ov2BpmkAKwIT4lovrjY OJJyyw407feg9EcWdJblTICPmdepFyh6VRQqNe1MEcY7IJUhkRJRekkkzMFfAZ4QbtLJ 4fO62Mvhae8MgRnTcvY0Ex/niK0SiAvul2Dt7HA6gfIFkgkNs2+QR+4KlqhEajgQA9Dz FKKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IUtHl3dHVrCGChHJNZz7f2YCmBuydJiAM0b18mQZtvE=; b=L8rPhxJNnrIQAcrTt784Rd1c8xxOXh6fHoQWIs2k/j61KJL1Ugdes6h+tYx2bs1VZR oY/KT7HKCHZ7F+qHPAq3zEFuPB+7lrplkjsIvdy0ZEjImM/P83IaNvwFYqb7K18QWA3Y pZmaOpjueQd/oHtSqGcKdLUg3FpD5qoSUhCCmojKc5camD8gJUA8s1HxmxVsmyDpb37v dQcwPaRaFThURRmPaQC2MffBCiYJTot3dGlUEcamhYHSsm5eYL+VWSmYWrC+BCpNqRWz vZcrVKd138iAJOyzOU9h7wkgLGGn8LorlllRVarH0KKT9aKSn3MW2rPcWO5XvjiQuBti HbqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FnZtPmTy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si5690646otp.25.2020.01.31.14.13.28; Fri, 31 Jan 2020 14:13:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FnZtPmTy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726443AbgAaWLx (ORCPT + 99 others); Fri, 31 Jan 2020 17:11:53 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:43072 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726163AbgAaWLw (ORCPT ); Fri, 31 Jan 2020 17:11:52 -0500 Received: by mail-ot1-f65.google.com with SMTP id p8so8059927oth.10 for ; Fri, 31 Jan 2020 14:11:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IUtHl3dHVrCGChHJNZz7f2YCmBuydJiAM0b18mQZtvE=; b=FnZtPmTyFfflSLT9ix9U7l7Vj5iAxGPg3HBrILk6HczJIYDrF+Md+5uvL5vskeKMNh KLJaeZzxn3bmCOeARi+yfni1PSa6xXvwsqcGg8ecxx78m2AoMiKclqLwj2A2iMNXlX2m SKVm9XOytZVDUDz7XfRPS3DcoHi/0csh4YPhNTOgLFSTq5x+ITwOQhAXXX5WZZDhBhGr cI9bQeEK3oroUJvX+u5LCLP6rMJwov5aWLITMiqbQFXYMbZiONEC9WXSIYxPSpOg2018 t266ngesJIRxy09r++8k7Rf7Nq+BBI4jnntHyeor9luWLP9auf5V8fKBG5tcovZE+pWy nDiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IUtHl3dHVrCGChHJNZz7f2YCmBuydJiAM0b18mQZtvE=; b=hnhX0y5YlbJmKMNKMc3O5FWWqsq2zu7AnM6jS4QbiOHqdJEO28Qq7+ImhtrteROIKN NfOmfmnW3Jddzq8weoTMam2DQ0Lt9Z20xnfaAJ0/CyNLmQb/9Am6I67f6YWmkocdVfiV 9gQGi7x8YGRuE4GPqTZhmR4tNhkCcoSola9FV1JNDlLXuWa91T+DCnrRoopZJqLHkpWR PlENKHUjE1Qlli6xZIUW3ZGK3TlFLZIL5gyhoBk5L5WCQLay3io5kwkSmP/3XDLvufWg ZDke9wh8LGWIR8QGcWy1e4XBBvuaq/SP1UuBLlh7TOffHJPW3rZxGII/onWOrgF1jSiw 072A== X-Gm-Message-State: APjAAAWw2k2Bk354ivp9Ik2WByfD4niLvg60lIqKbjWeVcvIyuJ6eXEs KXjr9k5a34YV2EqEuz70IwcwiwDa7ogdZ17sY68izw== X-Received: by 2002:a9d:7b51:: with SMTP id f17mr9025707oto.302.1580508711413; Fri, 31 Jan 2020 14:11:51 -0800 (PST) MIME-Version: 1.0 References: <20200131122421.23286-1-sjpark@amazon.com> <20200131122421.23286-3-sjpark@amazon.com> In-Reply-To: From: Neal Cardwell Date: Fri, 31 Jan 2020 17:11:35 -0500 Message-ID: Subject: Re: [PATCH 2/3] tcp: Reduce SYN resend delay if a suspicous ACK is received To: Eric Dumazet Cc: sjpark@amazon.com, Eric Dumazet , David Miller , shuah@kernel.org, Netdev , linux-kselftest@vger.kernel.org, LKML , sj38.park@gmail.com, aams@amazon.com, SeongJae Park , Yuchung Cheng Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 31, 2020 at 1:12 PM Eric Dumazet wrote: > > > > On 1/31/20 7:10 AM, Neal Cardwell wrote: > > On Fri, Jan 31, 2020 at 7:25 AM wrote: > >> > >> From: SeongJae Park > >> > >> When closing a connection, the two acks that required to change closing > >> socket's status to FIN_WAIT_2 and then TIME_WAIT could be processed in > >> reverse order. This is possible in RSS disabled environments such as a > >> connection inside a host. > >> > >> For example, expected state transitions and required packets for the > >> disconnection will be similar to below flow. > >> > >> 00 (Process A) (Process B) > >> 01 ESTABLISHED ESTABLISHED > >> 02 close() > >> 03 FIN_WAIT_1 > >> 04 ---FIN--> > >> 05 CLOSE_WAIT > >> 06 <--ACK--- > >> 07 FIN_WAIT_2 > >> 08 <--FIN/ACK--- > >> 09 TIME_WAIT > >> 10 ---ACK--> > >> 11 LAST_ACK > >> 12 CLOSED CLOSED > > > > AFAICT this sequence is not quite what would happen, and that it would > > be different starting in line 8, and would unfold as follows: > > > > 08 close() > > 09 LAST_ACK > > 10 <--FIN/ACK--- > > 11 TIME_WAIT > > 12 ---ACK--> > > 13 CLOSED CLOSED > > > > > >> The acks in lines 6 and 8 are the acks. If the line 8 packet is > >> processed before the line 6 packet, it will be just ignored as it is not > >> a expected packet, > > > > AFAICT that is where the bug starts. > > > > AFAICT, from first principles, when process A receives the FIN/ACK it > > should move to TIME_WAIT even if it has not received a preceding ACK. > > That's because ACKs are cumulative. So receiving a later cumulative > > ACK conveys all the information in the previous ACKs. > > > > Also, consider the de facto standard state transition diagram from > > "TCP/IP Illustrated, Volume 2: The Implementation", by Wright and > > Stevens, e.g.: > > > > https://courses.cs.washington.edu/courses/cse461/19sp/lectures/TCPIP_State_Transition_Diagram.pdf > > > > This first-principles analysis agrees with the Wright/Stevens diagram, > > which says that a connection in FIN_WAIT_1 that receives a FIN/ACK > > should move to TIME_WAIT. > > > > This seems like a faster and more robust solution than installing > > special timers. > > > > Thoughts? > > > This is orthogonal I think. > > No matter how hard we fix the other side, we should improve the active side. > > Since we send a RST, sending the SYN a few ms after the RST seems way better > than waiting 1 second as if we received no packet at all. > > Receiving this ACK tells us something about networking health, no need > to be very cautious about the next attempt. Yes, all good points. Thanks! > Of course, if you have a fix for the passive side, that would be nice to review ! I looked into fixing this, but my quick reading of the Linux tcp_rcv_state_process() code is that it should behave correctly and that a connection in FIN_WAIT_1 that receives a FIN/ACK should move to TIME_WAIT. SeongJae, do you happen to have a tcpdump trace of the problematic sequence where the "process A" ends up in FIN_WAIT_2 when it should be in TIME_WAIT? If I have time I will try to construct a packetdrill case to verify the behavior in this case. thanks, neal > > >