mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Benjamin Hesmans <benjamin.hesmans@tessares.net>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v1 5/5] mptcp: poll allow write call before actual connect
Date: Wed, 21 Sep 2022 19:43:34 +0200	[thread overview]
Message-ID: <944acdd357436317ac065e18581b4557737b6f1e.camel@redhat.com> (raw)
In-Reply-To: <20220921152539.1851441-6-benjamin.hesmans@tessares.net>

On Wed, 2022-09-21 at 17:25 +0200, Benjamin Hesmans wrote:
> If fastopen is used, poll must allow a first write that will trigger
> the SYN+data
> 
> Similar to what is done in tcp_poll().
> 
> Signed-off-by: Benjamin Hesmans <benjamin.hesmans@tessares.net>
> ---
>  net/mptcp/protocol.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index aa6e13949b23..308a09b3c0b6 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -3733,10 +3733,12 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock,
>  {
>  	struct sock *sk = sock->sk;
>  	struct mptcp_sock *msk;
> +	struct socket *ssock;
>  	__poll_t mask = 0;
>  	int state;
>  
>  	msk = mptcp_sk(sk);
> +	ssock = __mptcp_nmpc_socket(msk);

The above is not safe. We need to own the msk socket lock to invoke
__mptcp_nmpc_socket(), and we really want to avoid acquiring such lock
here.

Instead you can copy the ssk 'defer_connect' into the msk at
mptcp_stream_connect() time...

> 
>  	sock_poll_wait(file, sock, wait);
>  
>  	state = inet_sk_state_load(sk);
> @@ -3751,6 +3753,9 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock,
>  	if (state != TCP_SYN_SENT && state != TCP_SYN_RECV) {
>  		mask |= mptcp_check_readable(msk);
>  		mask |= mptcp_check_writeable(msk);
> +	} else if (ssock && state == TCP_SYN_SENT && inet_sk(ssock->sk)->defer_connect) {

... and check it here.

Cheers,

Paolo


      parent reply	other threads:[~2022-09-21 17:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21 15:25 [PATCH mptcp-next v1 0/5] mptcp: add support for TFO, sender side only Benjamin Hesmans
2022-09-21 15:25 ` [PATCH mptcp-next v1 1/5] mptcp: add TCP_FASTOPEN_CONNECT socket option Benjamin Hesmans
2022-09-21 15:25 ` [PATCH mptcp-next v1 2/5] tcp: export tcp_sendmsg_fastopen Benjamin Hesmans
2022-09-21 15:25 ` [PATCH mptcp-next v1 3/5] mptcp: handle defer connect in mptcp_sendmsg Benjamin Hesmans
2022-09-21 17:41   ` Paolo Abeni
2022-09-21 15:25 ` [PATCH mptcp-next v1 4/5] mptcp: add MSG_FASTOPEN support Benjamin Hesmans
2022-09-21 15:25 ` [PATCH mptcp-next v1 5/5] mptcp: poll allow write call before actual connect Benjamin Hesmans
2022-09-21 16:52   ` mptcp: poll allow write call before actual connect: Tests Results MPTCP CI
2022-09-21 17:43   ` Paolo Abeni [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=944acdd357436317ac065e18581b4557737b6f1e.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=benjamin.hesmans@tessares.net \
    --cc=mptcp@lists.linux.dev \
    /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).