diff src/event/ngx_event_quic_transport.c @ 8333:167d32476737 quic

Crypto buffer frames reordering. If offset in CRYPTO frame doesn't match expected, following actions are taken: a) Duplicate frames or frames within [0...current offset] are ignored b) New data from intersecting ranges (starts before current_offset, ends after) is consumed c) "Future" frames are stored in a sorted queue (min offset .. max offset) Once a frame is consumed, current offset is updated and the queue is inspected: we iterate the queue until the gap is found and act as described above for each frame. The amount of data in buffered frames is limited by corresponding macro. The CRYPTO and STREAM frame structures are now compatible: they share the same set of initial fields. This allows to have code that deals with both of this frames. The ordering layer now processes the frame with offset and invokes the handler when it can organise an ordered stream of data.
author Vladimir Homutov <vl@nginx.com>
date Tue, 14 Apr 2020 12:16:25 +0300
parents 1cdd53532309
children 0f9e9786b90d
line wrap: on
line diff
--- a/src/event/ngx_event_quic_transport.c
+++ b/src/event/ngx_event_quic_transport.c
@@ -593,14 +593,14 @@ ngx_quic_parse_frame(ngx_quic_header_t *
             return NGX_ERROR;
         }
 
-        p = ngx_quic_parse_int(p, end, &f->u.crypto.len);
+        p = ngx_quic_parse_int(p, end, &f->u.crypto.length);
         if (p == NULL) {
             ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
                           "failed to parse crypto frame len");
             return NGX_ERROR;
         }
 
-        p = ngx_quic_read_bytes(p, end, f->u.crypto.len, &f->u.crypto.data);
+        p = ngx_quic_read_bytes(p, end, f->u.crypto.length, &f->u.crypto.data);
         if (p == NULL) {
             ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
                           "failed to parse crypto frame data");
@@ -609,11 +609,11 @@ ngx_quic_parse_frame(ngx_quic_header_t *
 
         ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
                        "quic CRYPTO frame length: %uL off:%uL pp:%p",
-                       f->u.crypto.len, f->u.crypto.offset,
+                       f->u.crypto.length, f->u.crypto.offset,
                        f->u.crypto.data);
 
         ngx_quic_hexdump0(pkt->log, "CRYPTO frame contents",
-                          f->u.crypto.data, f->u.crypto.len);
+                          f->u.crypto.data, f->u.crypto.length);
         break;
 
     case NGX_QUIC_FT_PADDING:
@@ -1242,8 +1242,8 @@ ngx_quic_create_crypto(u_char *p, ngx_qu
     if (p == NULL) {
         len = ngx_quic_varint_len(NGX_QUIC_FT_CRYPTO);
         len += ngx_quic_varint_len(crypto->offset);
-        len += ngx_quic_varint_len(crypto->len);
-        len += crypto->len;
+        len += ngx_quic_varint_len(crypto->length);
+        len += crypto->length;
 
         return len;
     }
@@ -1252,8 +1252,8 @@ ngx_quic_create_crypto(u_char *p, ngx_qu
 
     ngx_quic_build_int(&p, NGX_QUIC_FT_CRYPTO);
     ngx_quic_build_int(&p, crypto->offset);
-    ngx_quic_build_int(&p, crypto->len);
-    p = ngx_cpymem(p, crypto->data, crypto->len);
+    ngx_quic_build_int(&p, crypto->length);
+    p = ngx_cpymem(p, crypto->data, crypto->length);
 
     return p - start;
 }