public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Yuchung Cheng <ycheng@google.com>
Cc: davem@davemloft.net, hkchu@google.com, edumazet@google.com,
	ncardwell@google.com, sivasankar@cs.ucsd.edu,
	netdev@vger.kernel.org
Subject: Re: [PATCH v2 3/7] net-tcp: Fast Open client - sending SYN-data
Date: Wed, 18 Jul 2012 23:23:24 +0200	[thread overview]
Message-ID: <1342646604.2626.3705.camel@edumazet-glaptop> (raw)
In-Reply-To: <1342645307-17772-4-git-send-email-ycheng@google.com>

On Wed, 2012-07-18 at 14:01 -0700, Yuchung Cheng wrote:
> This patch implements sending SYN-data in tcp_connect(). The data is
> from tcp_sendmsg() with flag MSG_FASTOPEN (implemented in a later patch).
> 
> The length of the cookie in tcp_fastopen_req, init'd to 0, controls the
> type of the SYN. If the cookie is not cached (len==0), the host sends
> data-less SYN with Fast Open cookie request option to solicit a cookie
> from the remote. If cookie is not available (len > 0), the host sends
> a SYN-data with Fast Open cookie option. If cookie length is negative,
>   the SYN will not include any Fast Open option (for fall back operations).
> 
> To deal with middleboxes that may drop SYN with data or experimental TCP
> option, the SYN-data is only sent once. SYN retransmits do not include
> data or Fast Open options. The connection will fall back to regular TCP
> handshake.
> 
> Signed-off-by: Yuchung Cheng <ycheng@google.com>

...

>  
>  static long inet_wait_for_connect(struct sock *sk, long timeo)
>  {
> +	const bool write = (sk->sk_protocol == IPPROTO_TCP) &&
> +			   tcp_sk(sk)->fastopen_req &&
> +			   tcp_sk(sk)->fastopen_req->data;
>  	DEFINE_WAIT(wait);
>  
>  	prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
> +	if (write)
> +		sk->sk_write_pending++;
>  
>  	/* Basic assumption: if someone sets sk->sk_err, he _must_
>  	 * change state of the socket from TCP_SYN_*.
> @@ -576,6 +581,8 @@ static long inet_wait_for_connect(struct sock *sk, long timeo)
>  		prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
>  	}
>  	finish_wait(sk_sleep(sk), &wait);
> +	if (write)
> +		sk->sk_write_pending--;
>  	return timeo;
>  }
>  

It might be cleaner to move the TCP stuff out of this function and put
it in inet_stream_connect(), since inet_stream_connect() is known to
already have TCP magic.

So I suggest you add a "int writebias" argument to this function, and
use :


static long inet_wait_for_connect(struct sock *sk, long timeo,
+                                 int writebias)
 {
        DEFINE_WAIT(wait);
 
        prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
+       sk->sk_write_pending += writebias;
 
        /* Basic assumption: if someone sets sk->sk_err, he _must_
         * change state of the socket from TCP_SYN_*.
@@ -576,6 +581,8 @@ static long inet_wait_for_connect(struct sock *sk,
long timeo)
                prepare_to_wait(sk_sleep(sk), &wait,
TASK_INTERRUPTIBLE);
        }
        finish_wait(sk_sleep(sk), &wait);
+       sk->sk_write_pending -= writebias;
        return timeo;
 }

  reply	other threads:[~2012-07-18 21:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 21:01 [PATCH v2 0/7] TCP Fast Open client Yuchung Cheng
2012-07-18 21:01 ` [PATCH v2 1/7] net-tcp: Fast Open base Yuchung Cheng
2012-07-18 21:16   ` Eric Dumazet
2012-07-18 21:01 ` [PATCH v2 2/7] net-tcp: Fast Open client - cookie cache Yuchung Cheng
2012-07-18 21:16   ` Eric Dumazet
2012-07-18 21:54     ` Eric Dumazet
2012-07-18 21:01 ` [PATCH v2 3/7] net-tcp: Fast Open client - sending SYN-data Yuchung Cheng
2012-07-18 21:23   ` Eric Dumazet [this message]
2012-07-18 21:01 ` [PATCH v2 4/7] net-tcp: Fast Open client - receiving SYN-ACK Yuchung Cheng
2012-07-18 21:27   ` Eric Dumazet
2012-07-18 21:01 ` [PATCH v2 5/7] net-tcp: Fast Open client - sendmsg(MSG_FASTOPEN) Yuchung Cheng
2012-07-18 21:30   ` Eric Dumazet
2012-07-18 21:01 ` [PATCH v2 6/7] net-tcp: Fast Open client - detecting SYN-data drops Yuchung Cheng
2012-07-18 21:35   ` Eric Dumazet
2012-07-18 21:01 ` [PATCH v2 7/7] net-tcp: Fast Open client - cookie-less mode Yuchung Cheng
2012-07-18 21:36   ` Eric Dumazet
2012-07-27 11:42 ` [PATCH v2 0/7] TCP Fast Open client Michael Kerrisk
2012-07-27 17:28   ` Jerry Chu
2012-07-27 19:06     ` Michael Kerrisk
2012-07-27 19:39       ` Jerry Chu
2012-07-27 19:52         ` Vijay Subramanian
2012-08-16  8:50 ` David Laight
2012-08-16 16:35   ` Rick Jones
2012-08-17 18:15   ` Yuchung Cheng

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=1342646604.2626.3705.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkchu@google.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=sivasankar@cs.ucsd.edu \
    --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