MINOR: mux-quic: define flag for last received frame

This flag is set when the STREAM frame with FIN set has been received on
a qcs instance. For now, this is only used as a BUG_ON guard to prevent
against multiple frames with FIN set. It will also be useful when
reorganize the RX path and move some of its code in the mux.
This commit is contained in:
Amaury Denoyelle 2022-02-28 11:36:57 +01:00
parent f77e3435a9
commit 3bf06093dc
2 changed files with 10 additions and 6 deletions

View File

@ -63,9 +63,10 @@ struct qcc {
}; };
#define QC_SF_NONE 0x00000000 #define QC_SF_NONE 0x00000000
#define QC_SF_FIN_STREAM 0x00000001 // FIN bit must be set for last frame of the stream #define QC_SF_FIN_RECV 0x00000001 // last frame received for this stream
#define QC_SF_BLK_MROOM 0x00000002 // app layer is blocked waiting for room in the qcs.tx.buf #define QC_SF_FIN_STREAM 0x00000002 // FIN bit must be set for last frame of the stream
#define QC_SF_DETACH 0x00000004 // cs is detached but there is remaining data to send #define QC_SF_BLK_MROOM 0x00000004 // app layer is blocked waiting for room in the qcs.tx.buf
#define QC_SF_DETACH 0x00000008 // cs is detached but there is remaining data to send
struct qcs { struct qcs {
struct qcc *qcc; struct qcc *qcc;

View File

@ -2079,7 +2079,6 @@ static int qc_handle_bidi_strm_frm(struct quic_rx_packet *pkt,
struct qcs *strm; struct qcs *strm;
struct eb64_node *strm_node; struct eb64_node *strm_node;
struct quic_rx_strm_frm *frm; struct quic_rx_strm_frm *frm;
char fin = 0;
strm_node = qcc_get_qcs(qc->qcc, strm_frm->id); strm_node = qcc_get_qcs(qc->qcc, strm_frm->id);
if (!strm_node) { if (!strm_node) {
@ -2104,6 +2103,8 @@ static int qc_handle_bidi_strm_frm(struct quic_rx_packet *pkt,
strm_frm->data += diff; strm_frm->data += diff;
} }
BUG_ON(strm->flags & QC_SF_FIN_RECV);
total = 0; total = 0;
if (strm_frm->offset.key == strm->rx.offset) { if (strm_frm->offset.key == strm->rx.offset) {
int ret; int ret;
@ -2118,8 +2119,10 @@ static int qc_handle_bidi_strm_frm(struct quic_rx_packet *pkt,
total += qc_treat_rx_strm_frms(strm); total += qc_treat_rx_strm_frms(strm);
/* FIN is set only if all data were copied. */ /* FIN is set only if all data were copied. */
fin = strm_frm->fin && !strm_frm->len; if (strm_frm->fin && !strm_frm->len)
if (total && qc->qcc->app_ops->decode_qcs(strm, fin, qc->qcc->ctx) < 0) { strm->flags |= QC_SF_FIN_RECV;
if (total && qc->qcc->app_ops->decode_qcs(strm, strm->flags & QC_SF_FIN_RECV, qc->qcc->ctx) < 0) {
TRACE_PROTO("Decoding error", QUIC_EV_CONN_PSTRM, qc); TRACE_PROTO("Decoding error", QUIC_EV_CONN_PSTRM, qc);
return 0; return 0;
} }