]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Make qc_build_frms() build ack-eliciting frames from a list
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 25 Feb 2022 16:44:29 +0000 (17:44 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 4 Mar 2022 16:00:12 +0000 (17:00 +0100)
We want to be able to build ack-eliciting frames to be embedded into QUIC packets
from a prebuilt list of ack-eliciting frames. This will be helpful for the mux
which would like to send STREAM frames asap after having builts its own prebuilt
list.
To do so, we only add a parameter as struct list to this function to handle
such a prebuilt list.

src/xprt_quic.c

index f76634f5b1a422a0385e7b901cab786846f83c04..a7e45f72e27d508fe5b324bbdc3d085d849facc4 100644 (file)
@@ -4756,17 +4756,18 @@ static int quic_ack_frm_reduce_sz(struct quic_frame *ack_frm, size_t limit)
        return 1 + ack_delay_sz + ack_frm->tx_ack.arngs->enc_sz;
 }
 
-/* Prepare as most as possible CRYPTO or STREAM frames from their prebuilt frames
- * for <qel> encryption level to be encoded in a buffer with <room> as available room,
- * and <*len> the packet Length field initialized with the number of bytes already present
- * in this buffer which must be taken into an account for the Length packet field value.
- * <headlen> is the number of bytes already present in this packet before building frames.
+/* Prepare into <outlist> as most as possible ack-eliciting frame from their
+ * <inlist> prebuilt frames for <qel> encryption level to be encoded in a buffer
+ * with <room> as available room, and <*len> the packet Length field initialized
+ * with the number of bytes already present in this buffer which must be taken
+ * into an account for the Length packet field value. <headlen> is the number of
+ * bytes already present in this packet before building frames.
  *
  * Update consequently <*len> to reflect the size of these frames built
  * by this function. Also attach these frames to <l> frame list.
  * Return 1 if succeeded, 0 if not.
  */
-static inline int qc_build_frms(struct list *l,
+static inline int qc_build_frms(struct list *outlist, struct list *inlist,
                                 size_t room, size_t *len, size_t headlen,
                                 struct quic_enc_level *qel,
                                 struct quic_conn *qc)
@@ -4792,7 +4793,7 @@ static inline int qc_build_frms(struct list *l,
 
        TRACE_PROTO("************** frames build (headlen)",
                    QUIC_EV_CONN_BCFRMS, qc, &headlen);
-       list_for_each_entry_safe(cf, cfbak, &qel->pktns->tx.frms, list) {
+       list_for_each_entry_safe(cf, cfbak, inlist, list) {
                /* header length, data length, frame length. */
                size_t hlen, dlen, dlen_sz, avail_room, flen;
 
@@ -4824,7 +4825,7 @@ static inline int qc_build_frms(struct list *l,
                        if (dlen == cf->crypto.len) {
                                /* <cf> CRYPTO data have been consumed. */
                                LIST_DELETE(&cf->list);
-                               LIST_APPEND(l, &cf->list);
+                               LIST_APPEND(outlist, &cf->list);
                        }
                        else {
                                struct quic_frame *new_cf;
@@ -4839,7 +4840,7 @@ static inline int qc_build_frms(struct list *l,
                                new_cf->crypto.len = dlen;
                                new_cf->crypto.offset = cf->crypto.offset;
                                new_cf->crypto.qel = qel;
-                               LIST_APPEND(l, &new_cf->list);
+                               LIST_APPEND(outlist, &new_cf->list);
                                /* Consume <dlen> bytes of the current frame. */
                                cf->crypto.len -= dlen;
                                cf->crypto.offset += dlen;
@@ -4887,7 +4888,7 @@ static inline int qc_build_frms(struct list *l,
                        if (dlen == cf->stream.len) {
                                /* <cf> STREAM data have been consumed. */
                                LIST_DELETE(&cf->list);
-                               LIST_APPEND(l, &cf->list);
+                               LIST_APPEND(outlist, &cf->list);
                        }
                        else {
                                struct quic_frame *new_cf;
@@ -4910,7 +4911,7 @@ static inline int qc_build_frms(struct list *l,
                                /* FIN bit reset */
                                new_cf->type &= ~QUIC_STREAM_FRAME_TYPE_FIN_BIT;
                                new_cf->stream.data = cf->stream.data;
-                               LIST_APPEND(l, &new_cf->list);
+                               LIST_APPEND(outlist, &new_cf->list);
                                cf->type |= QUIC_STREAM_FRAME_TYPE_OFF_BIT;
                                /* Consume <dlen> bytes of the current frame. */
                                cf_buf = b_make(b_orig(cf->stream.buf),
@@ -4931,7 +4932,7 @@ static inline int qc_build_frms(struct list *l,
                        *len += flen;
                        room -= flen;
                        LIST_DELETE(&cf->list);
-                       LIST_APPEND(l, &cf->list);
+                       LIST_APPEND(outlist, &cf->list);
                        break;
                }
                ret = 1;
@@ -5038,7 +5039,8 @@ static int qc_do_build_pkt(unsigned char *pos, const unsigned char *end,
                 * we will have len_frms > len.
                 */
                len_frms = len;
-               if (!qc_build_frms(&frm_list, end - pos, &len_frms, pos - beg, qel, qc)) {
+               if (!qc_build_frms(&frm_list, frms,
+                                  end - pos, &len_frms, pos - beg, qel, qc)) {
                        TRACE_PROTO("Not enough room", QUIC_EV_CONN_HPKT,
                                    qc, NULL, NULL, &room);
                }