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

John Fastabend
2019-07-10T03:39:36Z

Jakub Kicinski wrote:
> 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?

Right its a pattern I used on the sockmap side and put here. But
I dropped the patch to let sockmap stack on top of TLS because
it was more than a fix IMO. We could probably drop this check on
the other hand its harmless.
>
> > + 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.

Yeah, I thought the patches were easier to read this way but
maybe not. Could add something in the commit log.

>
> > + 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);
>