From: Bakul Shah <bakul@bitblocks.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] adding TCP half-duplex close
Date: Fri, 3 Feb 2017 22:29:16 -0800 [thread overview]
Message-ID: <F9D9F703-0167-4D2B-A48E-3ADF901EEF5E@bitblocks.com> (raw)
In-Reply-To: <CAJSxfmJKdKF7ntmHkbeZXya+5kh_biyim7qhVNHkwE7Wm3a=DA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1980 bytes --]
For the shut_rd case, I think a cleaner impl is to send RST *only* if there is pending data (received but not read by the user) or new data is received after the read end is closed. At the moment I don't recall what BSD does but you don't have to allow draining once the read end is closed. Just drain and RST! Any user reads should fail.
I recall having to deal with this in the past while working on a packet level network proxy. No access to that code now so the above is from memory.
Sent from my iPad
> On Feb 3, 2017, at 5:56 PM, Skip Tavakkolian <skip.tavakkolian@gmail.com> wrote:
>
> Has anyone looked into implementing this? Can anyone comment on the details?
>
> For the curious, this is described here: https://tools.ietf.org/html/rfc1122#page-87
> Go net package (https://github.com/golang/go/issues/17906).
>
> As I understand it, one would only worry about 'shutdown' if the connection is in 'Established' state. It is not clear to me what the state should transition to when the read-end is closed (i.e. shut_rd). Also, there doesn't not seem to be consistency between different implementations (Windows,Linux, *BSD) on what should happen to what's already in the read queue; should it be allowed to drain to the reader or discarded immediately?
>
> Shutting down the write-end (i.e. 'shut_wr'), should send FIN, and transition to Finwait1.
>
> I think the correct mechanics to handle this would be to add two new messages in tcpctl (/sys/src/9/ip/tcp.c). Then, roughly something like this:
>
> case 'shut_rd' :
> if (Etablished) {
> qhangup(rq);
> send(RST); // Windows does this and RFC1122 seems to recommend it. Linux does not.
> tcb->rcv.blocked = 1; // all that's needed?
> tcb->rcv.wnd = 0;
> tcpsetstate(????) // not sure what it should be or should stay Established?
> }
>
> case 'shut_wr':
> if (Established) {
> qhangup(wq);
> send(FIN)
> tcpsetstate(Finwait_1)
> }
>
>
[-- Attachment #2: Type: text/html, Size: 3375 bytes --]
next prev parent reply other threads:[~2017-02-04 6:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-04 1:56 Skip Tavakkolian
2017-02-04 6:29 ` Bakul Shah [this message]
2017-02-05 4:24 ` Skip Tavakkolian
2017-02-04 9:58 ` Charles Forsyth
2017-02-04 10:11 ` Charles Forsyth
2017-02-04 10:13 ` Charles Forsyth
2017-02-05 4:39 ` Skip Tavakkolian
2017-02-05 5:23 ` Bakul Shah
2017-02-05 15:51 ` Charles Forsyth
2017-02-05 15:54 ` Charles Forsyth
2017-02-05 18:13 ` Bakul Shah
2017-02-05 21:48 ` Charles Forsyth
2017-02-10 8:49 ` Skip Tavakkolian
2017-02-12 3:28 ` Skip Tavakkolian
2017-02-05 7:54 ` Fran. J Ballesteros
2017-02-05 4:16 ` Skip Tavakkolian
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=F9D9F703-0167-4D2B-A48E-3ADF901EEF5E@bitblocks.com \
--to=bakul@bitblocks.com \
--cc=9fans@9fans.net \
/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).