@@ -616,17 +616,22 @@ static int qc_handle_strm_frm(struct quic_rx_packet *pkt,
616616 return !ret ;
617617}
618618
619- /* Parse <frm> CRYPTO frame coming with <pkt> packet at <qel> <qc> connectionn.
620- * Returns 1 if succeeded, 0 if not. Also set <*fast_retrans> to 1 if the
621- * speed up handshake completion may be run after having received duplicated
622- * CRYPTO data.
619+ /* Parse <frm> CRYPTO frame coming with <pkt> packet at <qel> <qc> connection.
620+ *
621+ * Returns 0 on success or a negative error code. A positive value is used to
622+ * indicate that the current frame cannot be handled immediately, but it could
623+ * be solved by running a new packet parsing iteration.
624+ *
625+ * Also set <*fast_retrans> as output parameter to 1 if the speed up handshake
626+ * completion may be run after having received duplicated CRYPTO data.
623627 */
624- static int qc_handle_crypto_frm (struct quic_conn * qc ,
625- struct qf_crypto * crypto_frm , struct quic_rx_packet * pkt ,
626- struct quic_enc_level * qel , int * fast_retrans )
628+ static enum quic_rx_ret_frm qc_handle_crypto_frm (struct quic_conn * qc ,
629+ struct qf_crypto * crypto_frm ,
630+ struct quic_rx_packet * pkt ,
631+ struct quic_enc_level * qel )
627632{
628- int ret = 0 ;
629633 enum ncb_ret ncb_ret ;
634+ enum quic_rx_ret_frm ret = QUIC_RX_RET_FRM_DONE ;
630635 /* XXX TO DO: <cfdebug> is used only for the traces. */
631636 struct quic_rx_crypto_frm cfdebug = {
632637 .offset_node .key = crypto_frm -> offset ,
@@ -643,10 +648,8 @@ static int qc_handle_crypto_frm(struct quic_conn *qc,
643648 if (crypto_frm -> offset + crypto_frm -> len <= cstream -> rx .offset ) {
644649 /* Nothing to do */
645650 TRACE_PROTO ("Already received CRYPTO data" ,
646- QUIC_EV_CONN_RXPKT , qc , pkt , & cfdebug );
647- if (qc_is_listener (qc ) && qel == qc -> iel &&
648- !(qc -> flags & QUIC_FL_CONN_HANDSHAKE_SPEED_UP ))
649- * fast_retrans = 1 ;
651+ QUIC_EV_CONN_RXPKT , qc , pkt , & cfdebug );
652+ ret = QUIC_RX_RET_FRM_DUP ;
650653 goto done ;
651654 }
652655
@@ -661,7 +664,7 @@ static int qc_handle_crypto_frm(struct quic_conn *qc,
661664
662665 if (!quic_get_ncbuf (ncbuf ) || ncb_is_null (ncbuf )) {
663666 TRACE_ERROR ("CRYPTO ncbuf allocation failed" , QUIC_EV_CONN_PRSHPKT , qc );
664- goto leave ;
667+ goto err ;
665668 }
666669
667670 /* crypto_frm->offset > cstream-trx.offset */
@@ -677,7 +680,7 @@ static int qc_handle_crypto_frm(struct quic_conn *qc,
677680 TRACE_ERROR ("cannot bufferize frame due to gap size limit" ,
678681 QUIC_EV_CONN_PRSHPKT , qc );
679682 }
680- goto leave ;
683+ goto err ;
681684 }
682685
683686 /* Reschedule with TASK_HEAVY if CRYPTO data ready for decoding. */
@@ -687,10 +690,12 @@ static int qc_handle_crypto_frm(struct quic_conn *qc,
687690 }
688691
689692 done :
690- ret = 1 ;
691- leave :
692693 TRACE_LEAVE (QUIC_EV_CONN_PRSHPKT , qc );
693694 return ret ;
695+
696+ err :
697+ TRACE_DEVEL ("leaving on error" , QUIC_EV_CONN_PRSHPKT , qc );
698+ return QUIC_RX_RET_FRM_FATAL ;
694699}
695700
696701/* Handle RETIRE_CONNECTION_ID frame from <frm> frame.
@@ -770,6 +775,7 @@ static int qc_parse_pkt_frms(struct quic_conn *qc, struct quic_rx_packet *pkt,
770775{
771776 struct quic_frame * frm = NULL ;
772777 const unsigned char * pos , * end ;
778+ enum quic_rx_ret_frm ret ;
773779 int fast_retrans = 0 ;
774780
775781 TRACE_ENTER (QUIC_EV_CONN_PRSHPKT , qc );
@@ -848,8 +854,20 @@ static int qc_parse_pkt_frms(struct quic_conn *qc, struct quic_rx_packet *pkt,
848854 break ;
849855 }
850856 case QUIC_FT_CRYPTO :
851- if (!qc_handle_crypto_frm (qc , & frm -> crypto , pkt , qel , & fast_retrans ))
857+ ret = qc_handle_crypto_frm (qc , & frm -> crypto , pkt , qel );
858+ switch (ret ) {
859+ case QUIC_RX_RET_FRM_FATAL :
852860 goto err ;
861+ case QUIC_RX_RET_FRM_DUP :
862+ if (qc_is_listener (qc ) && qel == qc -> iel &&
863+ !(qc -> flags & QUIC_FL_CONN_HANDSHAKE_SPEED_UP )) {
864+ fast_retrans = 1 ;
865+ }
866+ break ;
867+ case QUIC_RX_RET_FRM_DONE :
868+ /* nothing to do here */
869+ break ;
870+ }
853871 break ;
854872 case QUIC_FT_NEW_TOKEN :
855873 /* TODO */
0 commit comments