From: Willy Tarreau <w@1wt.eu>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Wei Wang <tracywwnj@gmail.com>,
netdev@vger.kernel.org, David Miller <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Yuchung Cheng <ycheng@google.com>, Wei Wang <weiwan@google.com>
Subject: Re: [PATCH net-next 3/3] net/tcp-fastopen: Add new API support
Date: Tue, 24 Jan 2017 19:34:46 +0100 [thread overview]
Message-ID: <20170124183446.GE21921@1wt.eu> (raw)
In-Reply-To: <1485279889.16328.306.camel@edumazet-glaptop3.roam.corp.google.com>
Hi Eric,
On Tue, Jan 24, 2017 at 09:44:49AM -0800, Eric Dumazet wrote:
> I believe there is a bug in this application.
>
> It does not check connect() return value.
Yes in fact it does but I noticed the same thing, there's something causing
the event not to be registered or something like this.
> When 0 is returned, it makes no sense to wait 200 ms :
>
> > 06:29:24.048593 epoll_ctl(3, EPOLL_CTL_ADD, 9, {EPOLLIN|EPOLLRDHUP, {u32=9, u64=9}}) = 0
> > 06:29:24.048651 epoll_wait(3, [], 200, 0) = 0
> > 06:29:24.048699 getsockopt(10, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
>
> And it makes no sense to call connect() again :
>
> > 06:29:24.048751 connect(10, {sa_family=AF_INET, sin_port=htons(8001), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRES
> > S (Operation now in progress)
I totally agree.
> man connect
>
> <quote>
> Generally, connection-based protocol sockets may successfully connect()
> only once;
> </quote>
>
>
> I would prefer we do not add yet another bit in tcp kernel sockets, to
> work around some oddity in your program Willy.
I'm fine with chasing the bug on my side and fixing it, but there's a
semantic trouble anyway with returning -EINPROGRESS :
- connect() = 0 indicates that the connection is established
- then a further connect() should return -EISCONN, and does so when
not using TFO
man connect says this regarding EINPROGRESS :
The socket is nonblocking and the connection cannot be completed immediately.
It is possible to select(2) or poll(2) for completion by selecting the
socket for writing. After select(2) indicates writability, use getsockopt(2)
to read the SO_ERROR option at level SOL_SOCKET to determine whether connect()
completed successfully (SO_ERROR is zero) or unsuccess-fully (SO_ERROR is
one of the usual error codes listed here, explaining the reason for the failure).
Here we clearly have an incompatibility between this EINPROGRESS saying
that we must poll, and poll returning POLLOUT suggesting that it's now
OK.
I'm totally fine with not using an extra bit in a scarce area, but then
we can either add an extra argument to __inet_stream_connect() to say
"this is sendmsg" or just add an extra flag in the last argument.
But in general I don't feel comfortable with a semantics that doesn't
completely match the current and documented one :-/
Thanks,
Willy
next prev parent reply other threads:[~2017-01-24 18:35 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-23 18:59 [PATCH net-next 0/3] net/tcp-fastopen: Add new userspace API support Wei Wang
2017-01-23 18:59 ` [PATCH net-next 1/3] net/tcp-fastopen: refactor cookie check logic Wei Wang
2017-01-23 19:13 ` Eric Dumazet
2017-01-23 20:51 ` Yuchung Cheng
2017-01-23 18:59 ` [PATCH net-next 2/3] net: Remove __sk_dst_reset() in tcp_v6_connect() Wei Wang
2017-01-23 19:14 ` Eric Dumazet
2017-01-23 18:59 ` [PATCH net-next 3/3] net/tcp-fastopen: Add new API support Wei Wang
2017-01-23 19:15 ` Eric Dumazet
2017-01-23 20:55 ` Yuchung Cheng
2017-01-23 21:16 ` Willy Tarreau
[not found] ` <CAEA6p_DxVMAry1PCz_idmk=TGpnnTib3WpWso03FB1oMVXN+sg@mail.gmail.com>
2017-01-23 21:37 ` Willy Tarreau
2017-01-23 22:01 ` Willy Tarreau
2017-01-23 22:33 ` Willy Tarreau
[not found] ` <CAC15z3g8OxZNET+OnvcyYwHYuHq7QBamgGmjkBHzDr-XnUSGDQ@mail.gmail.com>
2017-01-23 23:01 ` Willy Tarreau
2017-01-24 17:44 ` Eric Dumazet
2017-01-24 18:34 ` Willy Tarreau [this message]
2017-01-24 18:51 ` Eric Dumazet
2017-01-24 19:11 ` Willy Tarreau
[not found] ` <CAC15z3izWNh7th_yxA_a90vgLnU5XzVDm6vyojq3cMDgQZ71YA@mail.gmail.com>
2017-01-25 17:22 ` David Miller
2017-01-25 17:54 ` Willy Tarreau
2017-01-25 18:54 ` Wei Wang
2017-01-25 19:03 ` Eric Dumazet
2017-01-25 19:03 ` David Miller
2017-01-25 19:30 ` Wei Wang
2017-01-25 17:53 ` Willy Tarreau
2017-01-24 7:30 ` Willy Tarreau
2017-01-24 17:26 ` Yuchung Cheng
2017-01-24 17:42 ` Eric Dumazet
2017-01-24 18:43 ` Willy Tarreau
2017-01-25 19:09 ` [PATCH net-next 0/3] net/tcp-fastopen: Add new userspace " David Miller
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=20170124183446.GE21921@1wt.eu \
--to=w@1wt.eu \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=tracywwnj@gmail.com \
--cc=weiwan@google.com \
--cc=ycheng@google.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 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).