Re: FIN + RST behavior

Martin Thomson <martin.thomson@gmail.com> Thu, 23 March 2017 00:45 UTC

Return-Path: <martin.thomson@gmail.com>
X-Original-To: quic@ietfa.amsl.com
Delivered-To: quic@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 6E650128954 for <quic@ietfa.amsl.com>; Wed, 22 Mar 2017 17:45:35 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.999
X-Spam-Level:
X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tc2KCeaJ9CWi for <quic@ietfa.amsl.com>; Wed, 22 Mar 2017 17:45:33 -0700 (PDT)
Received: from mail-qt0-x22d.google.com (mail-qt0-x22d.google.com [IPv6:2607:f8b0:400d:c0d::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id D6A27128D19 for <quic@ietf.org>; Wed, 22 Mar 2017 17:45:32 -0700 (PDT)
Received: by mail-qt0-x22d.google.com with SMTP id x35so163692438qtc.2 for <quic@ietf.org>; Wed, 22 Mar 2017 17:45:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=3yq94Jh+EO/8+PrM2eLN5p1L7QFzf9kJZbNF1ecoZYE=; b=edIdcOgT0sKdD8g2FnntatGyISXOk/3/MYdnvFb5KtxyEcjGe7EN8ise5moTSjL+BI nvR3+qu8QazqzW623FrErmqyGuX6j5zKekcNA8Qi41fQp0fXzEg6Z/pKgkVD7PqI/uuN dZaNexG0zhGMPBUS8yiROHDW/SHo94yYP0e62JlnJIh09ysV837UvUwIzvPPNLBjcOdE uWEy4bS+p0RcfdtSmXt+uhIO95M/OZ7vgAlGLR3Bmbqoa8ngEo65GqBAvYC1Xd5D19jI JvH+HS2cDnU/JLASPt/USk1l3/wPTXkNKEWoJlOzZGRIJxO9uO1ez7/T+1i0ql6qAx93 f1Gw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=3yq94Jh+EO/8+PrM2eLN5p1L7QFzf9kJZbNF1ecoZYE=; b=aPMENRjYIBUISm+fJu8tA56y0G2bnRpPX8ese5numrzJN72UqpZU1qnx8JTvK0i/9q 00sOhFc1SSVe+JVnOXCqz7X7DWWaz97fUcwhXDRE85EKUOQSq3UVX28lmntOwtIWlCQg iWvVAlFap4zwJWPRfuk5I4W5UfqmPQLhnCa9Nz8FKRBlcaPci5BFq/qlab+tm7iyBNYh uB9yW9mRRR4Yh8rd8xYo9lUWU7XfTavgDYnEYidYOPsGN+tPkrUvnmS/tbeF3+M+ShXi 7VrVbxMWvlXQfYSLsFwxsXWEvajSjP/IA1lJ8Bjk8clc7bbt4qExrvxTtfXjARKTxkCF mATQ==
X-Gm-Message-State: AFeK/H1riVuMIm5rw1PrsSrGa0jWJBMai1mGpl7svnS6hF08TmFCnfh1dhV60nqa1Sz7YiwiT5Vd/6QqbxRmAQ==
X-Received: by 10.200.33.210 with SMTP id 18mr40231234qtz.159.1490229931937; Wed, 22 Mar 2017 17:45:31 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.140.27.194 with HTTP; Wed, 22 Mar 2017 17:45:31 -0700 (PDT)
In-Reply-To: <MWHPR15MB1455B5E6D4F4FAC8411927E4B63C0@MWHPR15MB1455.namprd15.prod.outlook.com>
References: <MWHPR15MB1455B5E6D4F4FAC8411927E4B63C0@MWHPR15MB1455.namprd15.prod.outlook.com>
From: Martin Thomson <martin.thomson@gmail.com>
Date: Thu, 23 Mar 2017 11:45:31 +1100
Message-ID: <CABkgnnVRo_mT7sPO=xvmMdS-6wAJoSpARp+FG1R8i-RQWqE8Lg@mail.gmail.com>
Subject: Re: FIN + RST behavior
To: Subodh Iyengar <subodh@fb.com>
Cc: "quic@ietf.org" <quic@ietf.org>
Content-Type: text/plain; charset="UTF-8"
Archived-At: <https://mailarchive.ietf.org/arch/msg/quic/myfrxlgmOpH9w95C2IkdEzklGR4>
X-BeenThere: quic@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Main mailing list of the IETF QUIC working group <quic.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/quic>, <mailto:quic-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/quic/>
List-Post: <mailto:quic@ietf.org>
List-Help: <mailto:quic-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/quic>, <mailto:quic-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 23 Mar 2017 00:45:35 -0000

This is just an error.  Both endpoints need to end their stream in one
way or other.  The text about not sending a RST_STREAM needs to take
into account the fact that any FIN or RST_STREAM that was previously
sent ALSO needs to be acknowledged.

A sender needs to wait for acknowledgment before transitioning to new
states.  Receivers just process and acknowledge.

I agree that this is poorly documented.  Here's the short version:

Each endpoint has to end the stream one way or other.  This
establishes the final data offset for the stream, which is necessary
for connection flow control accounting.  A stream can be ended by
either sending a STREAM frame with the FIN flag set, or a RST_STREAM
frame.  A stream isn't ended in the sending direction until a packet
containing one of those two frames has been acknowledged.  An endpoint
MAY choose to switch from sending STREAM frames to sending RST_STREAM
frames at any time.

For the long version, you will have to wait until we get around to
fixing https://github.com/quicwg/base-drafts/issues/413

On 23 March 2017 at 09:37, Subodh Iyengar <subodh@fb.com> wrote:
> There might be some strange cases around RSTs and FINs which I would love
> more clarity on.
>
> Let's say that the following actions happen:
> 1) Client initiates a stream to the server and sends some data
> 2) Server sends a FIN to the client which the client receives. The client
> and server are both half closed (remote and local respectively).
> 3) After some time the client sends a FIN to the server. So it's waiting for
> the FIN and the ack of all the data before closing the stream.
> 4) Server sends a RST which races with the client sending the FIN.
> 5) Client gets a RST
>
> From the draft I think it's ambiguous on what the client is supposed to do
>
> "An endpoint that receives a RST_STREAM frame (and which has not sent a FIN
> or a RST_STREAM) MUST immediately respond with a RST_STREAM frame, and MUST
> NOT send any more data on the stream"
>
> So clearly a client should not send a RST stream in response
>
> However:
> "When an endpoint sends a RST_STREAM frame, data outstanding on that stream
> SHOULD NOT be retransmitted, since subsequent data on this stream is
> expected to not be delivered by the receiver."
>
> If the client decides to honor both of these requirements I believe it will
> not retransmit the FIN. So if the FIN gets lost the client will have no idea
> whether the server has seen the FIN and reduced its
> number of streams counting towards the concurrency limit so that the client
> can open up a new stream. It would need to track the ACK of the ACK of the
> RST stream that the server sends back.
>
> Am I missing another requirement that prevents this from being an issue or
> could "not sent a FIN" mean that "not sent a FIN that has been ACKed".
>
> Subodh
>