BUG/MINOR: quic: also send RESET_STREAM if MUX released

When the MUX is freed, the quic-conn layer may stay active until all
streams acknowledgment are processed. In this interval, if a new stream
is opened by the client, the quic-conn is thus now responsible to handle
it. This is done by the emission of a STOP_SENDING.

This process has been completed to also emit a RESET_STREAM with the
same error code H3_REQUEST_REJECTED. This is done to conform with the H3
specification to invite the client to retry its request on a new
connection.

This should be backported up to 2.6.

(cherry picked from commit 75463017123ad32ff1afe4fe95dd9088b7e9cba4)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit eb284ce40ca3425694ac5e4e1aae7b9df652f883)
[ad: replace non-existant wrapper for quic_frame alloc/dealloc by
 plain pool_alloc/pool_free]
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
This commit is contained in:
Amaury Denoyelle 2023-02-20 10:31:27 +01:00
parent ec28b53567
commit 03414c0bd1

View File

@ -2677,7 +2677,7 @@ static void qc_cc_err_count_inc(struct quic_conn *qc, struct quic_frame *frm)
/* Cancel a request on connection <qc> for stream id <id>. This is useful when
* the client opens a new stream but the MUX has already been released. A
* STOP_SENDING frame is prepared for emission.
* STOP_SENDING + RESET_STREAM frames are prepared for emission.
*
* TODO this function is closely related to H3. Its place should be in H3 layer
* instead of quic-conn but this requires an architecture adjustment.
@ -2687,7 +2687,7 @@ static void qc_cc_err_count_inc(struct quic_conn *qc, struct quic_frame *frm)
static int qc_h3_request_reject(struct quic_conn *qc, uint64_t id)
{
int ret = 0;
struct quic_frame *frm;
struct quic_frame *ss, *rs;
struct quic_enc_level *qel = &qc->els[QUIC_TLS_ENC_LEVEL_APP];
const uint64_t app_error_code = H3_REQUEST_REJECTED;
@ -2703,17 +2703,32 @@ static int qc_h3_request_reject(struct quic_conn *qc, uint64_t id)
}
// fixme: zalloc
frm = pool_zalloc(pool_head_quic_frame);
if (!frm) {
ss = pool_zalloc(pool_head_quic_frame);
if (!ss) {
TRACE_ERROR("failed to allocate quic_frame", QUIC_EV_CONN_PRSHPKT, qc);
goto out;
}
frm->type = QUIC_FT_STOP_SENDING;
frm->stop_sending.id = id;
frm->stop_sending.app_error_code = app_error_code;
LIST_INIT(&frm->reflist);
LIST_APPEND(&qel->pktns->tx.frms, &frm->list);
ss->type = QUIC_FT_STOP_SENDING;
ss->stop_sending.id = id;
ss->stop_sending.app_error_code = app_error_code;
LIST_INIT(&ss->reflist);
rs = pool_zalloc(pool_head_quic_frame);
if (!rs) {
TRACE_ERROR("failed to allocate quic_frame", QUIC_EV_CONN_PRSHPKT, qc);
pool_free(pool_head_quic_frame, &ss);
goto out;
}
rs->type = QUIC_FT_RESET_STREAM;
rs->reset_stream.id = id;
rs->reset_stream.app_error_code = app_error_code;
rs->reset_stream.final_size = 0;
LIST_INIT(&rs->reflist);
LIST_APPEND(&qel->pktns->tx.frms, &ss->list);
LIST_APPEND(&qel->pktns->tx.frms, &rs->list);
ret = 1;
out:
TRACE_LEAVE(QUIC_EV_CONN_PRSHPKT, qc);