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

Jakub Kicinski
2019-07-10T20:04:19Z

On Wed, 10 Jul 2019 12:34:17 -0700, Jakub Kicinski wrote:
> > > > + 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);

Do we still need to hook into unhash? With patch 6 in place perhaps we
can just do disconnect 🥺

cleanup is going to kick off TX but also:

if (unlikely(sk->sk_write_pending) &&
!wait_on_pending_writer(sk, &timeo))
tls_handle_open_record(sk, 0);

Are we guaranteed that sk_write_pending is 0? Otherwise
wait_on_pending_writer is hiding yet another release_sock() :(

> > > > + 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.
>
> Ack! Let me try to get a full grip of patches 2 and 6 and come back
> to this.
>
> > > > + 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);