From 048c05e2a36bcf3a2660ab39763bd9206607ac9c Mon Sep 17 00:00:00 2001 From: plumplumli <528785263@qq.com> Date: Thu, 26 Dec 2024 15:17:53 +0800 Subject: [PATCH 1/2] Fix lsquic compliance with RFC 9000 for MAX_STREAM_DATA frame --- src/liblsquic/lsquic_full_conn_ietf.c | 43 +++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/liblsquic/lsquic_full_conn_ietf.c b/src/liblsquic/lsquic_full_conn_ietf.c index fbed005b..6d28938d 100644 --- a/src/liblsquic/lsquic_full_conn_ietf.c +++ b/src/liblsquic/lsquic_full_conn_ietf.c @@ -6194,9 +6194,46 @@ process_max_stream_data_frame (struct ietf_full_conn *conn, stream_id); else { - ABORT_QUIETLY(0, TEC_STREAM_STATE_ERROR, "received MAX_STREAM_DATA " - "frame on never-opened stream %"PRIu64, stream_id); - return 0; + if (is_peer_initiated(conn, stream_id)) + { + const lsquic_stream_id_t max_allowed = + conn->ifc_max_allowed_stream_id[stream_id & SIT_MASK]; + if (stream_id >= max_allowed) + { + ABORT_QUIETLY(0, TEC_STREAM_LIMIT_ERROR, "incoming stream " + "%"PRIu64" exceeds allowed max of %"PRIu64, + stream_id, max_allowed); + return 0; + } + if (conn->ifc_flags & IFC_GOING_AWAY) + { + LSQ_DEBUG("going away: reject new incoming stream %"PRIu64, + stream_id); + maybe_schedule_ss_for_stream(conn, stream_id, + HEC_REQUEST_REJECTED); + return parsed_len; + } + stream = new_stream(conn, stream_id, SCF_CALL_ON_NEW); + if (!stream) + { + ABORT_ERROR("cannot create new stream: %s", strerror(errno)); + return 0; + } + if (SD_BIDI == ((stream_id >> SD_SHIFT) & 1) + && (!valid_stream_id(conn->ifc_max_req_id) + || conn->ifc_max_req_id < stream_id)) + conn->ifc_max_req_id = stream_id; + if (SD_UNI == ((stream_id >> SD_SHIFT) & 1) + && (!valid_stream_id(conn->ifc_max_uni_req_id) + || conn->ifc_max_uni_req_id < stream_id)) + conn->ifc_max_uni_req_id = stream_id; + } + else + { + ABORT_QUIETLY(0, TEC_STREAM_STATE_ERROR, "received MAX_STREAM_DATA " + "frame on never-opened stream %"PRIu64, stream_id); + return 0; + } } return parsed_len; From ff2e5401349d719f47af6b8617a27dfd0805f2a8 Mon Sep 17 00:00:00 2001 From: plumplumli <528785263@qq.com> Date: Thu, 26 Dec 2024 17:14:41 +0800 Subject: [PATCH 2/2] Fix lsquic compliance with RFC 9000 for MAX_STREAM_DATA frame, and build successfully upon latest version --- src/liblsquic/lsquic_full_conn_ietf.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/liblsquic/lsquic_full_conn_ietf.c b/src/liblsquic/lsquic_full_conn_ietf.c index 6d28938d..b6f7129b 100644 --- a/src/liblsquic/lsquic_full_conn_ietf.c +++ b/src/liblsquic/lsquic_full_conn_ietf.c @@ -6223,10 +6223,6 @@ process_max_stream_data_frame (struct ietf_full_conn *conn, && (!valid_stream_id(conn->ifc_max_req_id) || conn->ifc_max_req_id < stream_id)) conn->ifc_max_req_id = stream_id; - if (SD_UNI == ((stream_id >> SD_SHIFT) & 1) - && (!valid_stream_id(conn->ifc_max_uni_req_id) - || conn->ifc_max_uni_req_id < stream_id)) - conn->ifc_max_uni_req_id = stream_id; } else {