git: 7748f70561f3 - stable/14 - cxgbe tom: Handle a race condition when enabling TLS offload
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 08 Apr 2024 19:04:48 UTC
The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=7748f70561f373a8d8e70c32223c99b02904ef51 commit 7748f70561f373a8d8e70c32223c99b02904ef51 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2024-03-20 22:30:09 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-04-08 18:07:13 +0000 cxgbe tom: Handle a race condition when enabling TLS offload Use a separate state for when a request to set RX_QUIESCE has been sent but the resulting TCB reply has not been received. In particular, this correctly handles the case where data has been received and queued in the receive queue before the quiesce request takes effect. Reviewed by: np Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D44435 (cherry picked from commit 9978c6289d621ac9edc95acb4e0f527a62a49b03) --- sys/dev/cxgbe/tom/t4_tls.c | 12 ++++++++++-- sys/dev/cxgbe/tom/t4_tom.h | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sys/dev/cxgbe/tom/t4_tls.c b/sys/dev/cxgbe/tom/t4_tls.c index 3a0c1a392e6c..bdd03edd3a6f 100644 --- a/sys/dev/cxgbe/tom/t4_tls.c +++ b/sys/dev/cxgbe/tom/t4_tls.c @@ -315,7 +315,7 @@ tls_alloc_ktls(struct toepcb *toep, struct ktls_session *tls, int direction) tls->params.max_frame_len; toep->tls.tx_key_info_size = t4_tls_key_info_size(tls); } else { - toep->flags |= TPF_TLS_STARTING | TPF_TLS_RX_QUIESCED; + toep->flags |= TPF_TLS_STARTING | TPF_TLS_RX_QUIESCING; toep->tls.rx_version = tls->params.tls_vmajor << 8 | tls->params.tls_vminor; @@ -1243,6 +1243,10 @@ tls_received_starting_data(struct adapter *sc, struct toepcb *toep, { MPASS(toep->flags & TPF_TLS_STARTING); + /* Data was received before quiescing took effect. */ + if ((toep->flags & TPF_TLS_RX_QUIESCING) != 0) + return; + /* * A previous call to tls_check_rx_sockbuf needed more data. * Now that more data has arrived, quiesce receive again and @@ -1250,7 +1254,7 @@ tls_received_starting_data(struct adapter *sc, struct toepcb *toep, */ if ((toep->flags & TPF_TLS_RX_QUIESCED) == 0) { CTR(KTR_CXGBE, "%s: tid %d quiescing", __func__, toep->tid); - toep->flags |= TPF_TLS_RX_QUIESCED; + toep->flags |= TPF_TLS_RX_QUIESCING; t4_set_rx_quiesce(toep); return; } @@ -1287,6 +1291,10 @@ do_tls_tcb_rpl(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) if ((toep->flags & TPF_TLS_STARTING) == 0) panic("%s: connection is not starting TLS RX\n", __func__); + MPASS((toep->flags & TPF_TLS_RX_QUIESCING) != 0); + + toep->flags &= ~TPF_TLS_RX_QUIESCING; + toep->flags |= TPF_TLS_RX_QUIESCED; so = inp->inp_socket; sb = &so->so_rcv; diff --git a/sys/dev/cxgbe/tom/t4_tom.h b/sys/dev/cxgbe/tom/t4_tom.h index d74f3f908286..ddf7dec55784 100644 --- a/sys/dev/cxgbe/tom/t4_tom.h +++ b/sys/dev/cxgbe/tom/t4_tom.h @@ -73,8 +73,9 @@ enum { TPF_KTLS = (1 << 11), /* send TLS records from KTLS */ TPF_INITIALIZED = (1 << 12), /* init_toepcb has been called */ TPF_TLS_RECEIVE = (1 << 13), /* should receive TLS records */ - TPF_TLS_RX_QUIESCED = (1 << 14), /* RX quiesced for TLS RX startup */ - TPF_WAITING_FOR_FINAL = (1<< 15), /* waiting for wakeup on final CPL */ + TPF_TLS_RX_QUIESCING = (1 << 14), /* RX quiesced for TLS RX startup */ + TPF_TLS_RX_QUIESCED = (1 << 15), /* RX quiesced for TLS RX startup */ + TPF_WAITING_FOR_FINAL = (1<< 16), /* waiting for wakeup on final CPL */ }; enum {