All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Christoph Paasch <cpaasch@apple.com>, netdev@vger.kernel.org
Cc: Eric Dumazet <edumazet@google.com>,
	Yuchung Cheng <ycheng@google.com>,
	David Miller <davem@davemloft.net>
Subject: Re: [PATCH net-next 1/5] tcp: Create list of TFO-contexts
Date: Sun, 16 Dec 2018 22:31:41 -0800	[thread overview]
Message-ID: <4f327eec-ce46-c871-0ca5-26d6939b9faf@gmail.com> (raw)
In-Reply-To: <20181214224007.54813-2-cpaasch@apple.com>



On 12/14/2018 02:40 PM, Christoph Paasch wrote:
> Instead of having a single TFO-context, we now have a list of
> tcp_fastopen_context, bounded by TCP_FASTOPEN_CTXT_LEN (set to 2).
> 
> This enables us to do a rolling TFO-key update that allows the server to
> accept old cookies and at the same time announce new ones to the client
> (see follow-up patch).
> 
> Signed-off-by: Christoph Paasch <cpaasch@apple.com>
> ---
>  include/net/tcp.h       |  2 ++
>  net/ipv4/tcp_fastopen.c | 52 +++++++++++++++++++++++++++++++++++++++++++++----
>  2 files changed, 50 insertions(+), 4 deletions(-)
> 
> diff --git a/include/net/tcp.h b/include/net/tcp.h
> index e0a65c067662..e629ea2e6c9d 100644
> --- a/include/net/tcp.h
> +++ b/include/net/tcp.h
> @@ -1622,9 +1622,11 @@ bool tcp_fastopen_cookie_check(struct sock *sk, u16 *mss,
>  			     struct tcp_fastopen_cookie *cookie);
>  bool tcp_fastopen_defer_connect(struct sock *sk, int *err);
>  #define TCP_FASTOPEN_KEY_LENGTH 16
> +#define TCP_FASTOPEN_CTXT_LEN 2
>  
>  /* Fastopen key context */
>  struct tcp_fastopen_context {
> +	struct tcp_fastopen_context __rcu *next;
>  	struct crypto_cipher	*tfm;
>  	__u8			key[TCP_FASTOPEN_KEY_LENGTH];
>  	struct rcu_head		rcu;
> diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
> index 018a48477355..c52d5b8eabf0 100644
> --- a/net/ipv4/tcp_fastopen.c
> +++ b/net/ipv4/tcp_fastopen.c
> @@ -37,8 +37,14 @@ static void tcp_fastopen_ctx_free(struct rcu_head *head)
>  {
>  	struct tcp_fastopen_context *ctx =
>  	    container_of(head, struct tcp_fastopen_context, rcu);
> -	crypto_free_cipher(ctx->tfm);
> -	kfree(ctx);
> +
> +	while (ctx) {
> +		struct tcp_fastopen_context *prev = ctx;
> +		/* We own ctx, thus no need to hold the Fastopen-lock */
> +		ctx = rcu_dereference_protected(ctx->next, 1);
> +		crypto_free_cipher(prev->tfm);
> +		kfree(prev);
> +	}
>

It seems this function does not need to be changed, since at most one context
should be freed per run ?

  reply	other threads:[~2018-12-17  6:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14 22:40 [PATCH net-next 0/5] tcp: Introduce a TFO key-pool for clean cookie-rotation Christoph Paasch
2018-12-14 22:40 ` [PATCH net-next 1/5] tcp: Create list of TFO-contexts Christoph Paasch
2018-12-17  6:31   ` Eric Dumazet [this message]
2018-12-17 15:49     ` Christoph Paasch
2018-12-17 16:07       ` Eric Dumazet
2018-12-17 16:04   ` Eric Dumazet
2018-12-17 21:57     ` Christoph Paasch
2018-12-17 22:01       ` Eric Dumazet
2018-12-17 22:50         ` Christoph Paasch
2018-12-14 22:40 ` [PATCH net-next 2/5] tcp: TFO: search for correct cookie and accept data Christoph Paasch
2018-12-17  6:30   ` Eric Dumazet
2018-12-17 22:59     ` Christoph Paasch
2018-12-14 22:40 ` [PATCH net-next 3/5] tcp: Print list of TFO-keys from proc Christoph Paasch
2018-12-17  6:32   ` Eric Dumazet
2018-12-17 16:52     ` Yuchung Cheng
2018-12-17 23:35       ` Christoph Paasch
2018-12-17 23:49         ` Yuchung Cheng
2018-12-14 22:40 ` [PATCH net-next 4/5] tcp: Allow getsockopt of listener's keypool Christoph Paasch
2018-12-14 22:40 ` [PATCH net-next 5/5] tcp: TFO - cleanup code duplication Christoph Paasch
2018-12-17  6:33   ` Eric Dumazet
2018-12-18  0:16     ` Christoph Paasch
2018-12-16 20:19 ` [PATCH net-next 0/5] tcp: Introduce a TFO key-pool for clean cookie-rotation David Miller
2018-12-17  5:54   ` Eric Dumazet

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=4f327eec-ce46-c871-0ca5-26d6939b9faf@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=cpaasch@apple.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.