Re: [bpf PATCH v2 2/6] bpf: tls fix transition through disconnect with close

Jakub Kicinski
2019-07-10T02:45:31Z

On Mon, 08 Jul 2019 19:14:05 +0000, John Fastabend wrote:
> @@ -287,6 +313,27 @@ static void tls_sk_proto_cleanup(struct sock *sk,
> #endif
> }
>
> +static void tls_sk_proto_unhash(struct sock *sk)
> +{
> + struct inet_connection_sock *icsk = inet_csk(sk);
> + long timeo = sock_sndtimeo(sk, 0);
> + struct tls_context *ctx;
> +
> + if (unlikely(!icsk->icsk_ulp_data)) {

Is this for when sockmap is stacked on top of TLS and TLS got removed
without letting sockmap know?

> + if (sk->sk_prot->unhash)
> + sk->sk_prot->unhash(sk);
> + }
> +
> + ctx = tls_get_ctx(sk);
> + if (ctx->tx_conf == TLS_SW || ctx->rx_conf == TLS_SW)
> + tls_sk_proto_cleanup(sk, ctx, timeo);
> + icsk->icsk_ulp_data = NULL;

I think close only starts checking if ctx is NULL in patch 6.
Looks like some chunks of ctx checking/clearing got spread to
patch 1 and some to patch 6.

> + tls_ctx_free_wq(ctx);
> +
> + if (ctx->unhash)
> + ctx->unhash(sk);
> +}
> +
> static void tls_sk_proto_close(struct sock *sk, long timeout)
> {
> struct tls_context *ctx = tls_get_ctx(sk);