QUIC: fixed ACK Ranges processing.

According to quic-transport draft 29, section 19.3.1:

   The value of the Gap field establishes the largest packet number
   value for the subsequent ACK Range using the following formula:

      largest = previous_smallest - gap - 2

   Thus, given a largest packet number for the range, the smallest value
   is determined by the formula:

      smallest = largest - ack_range

While here, changed min/max to uint64_t for consistency.
This commit is contained in:
Sergey Kandaurov 2020-08-07 12:34:15 +03:00
parent 7d1a1fb6de
commit e4ca695700

View File

@ -2289,9 +2289,9 @@ ngx_quic_handle_ack_frame(ngx_connection_t *c, ngx_quic_header_t *pkt,
{ {
ssize_t n; ssize_t n;
u_char *pos, *end; u_char *pos, *end;
uint64_t gap, range; uint64_t min, max, gap, range;
ngx_msec_t send_time; ngx_msec_t send_time;
ngx_uint_t i, min, max; ngx_uint_t i;
ngx_quic_send_ctx_t *ctx; ngx_quic_send_ctx_t *ctx;
ngx_quic_connection_t *qc; ngx_quic_connection_t *qc;
@ -2328,7 +2328,7 @@ ngx_quic_handle_ack_frame(ngx_connection_t *c, ngx_quic_header_t *pkt,
if (ctx->largest_ack < max) { if (ctx->largest_ack < max) {
ctx->largest_ack = max; ctx->largest_ack = max;
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic updated largest received ack: %ui", max); "quic updated largest received ack: %uL", max);
/* /*
* An endpoint generates an RTT sample on receiving an * An endpoint generates an RTT sample on receiving an
@ -2354,23 +2354,23 @@ ngx_quic_handle_ack_frame(ngx_connection_t *c, ngx_quic_header_t *pkt,
} }
pos += n; pos += n;
if (gap >= min) { if (gap + 2 > min) {
qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR;
ngx_log_error(NGX_LOG_INFO, c->log, 0, ngx_log_error(NGX_LOG_INFO, c->log, 0,
"quic invalid range %ui in ack frame", i); "quic invalid range %ui in ack frame", i);
return NGX_ERROR; return NGX_ERROR;
} }
max = min - 1 - gap; max = min - gap - 2;
if (range > max + 1) { if (range > max) {
qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR;
ngx_log_error(NGX_LOG_INFO, c->log, 0, ngx_log_error(NGX_LOG_INFO, c->log, 0,
"quic invalid range %ui in ack frame", i); "quic invalid range %ui in ack frame", i);
return NGX_ERROR; return NGX_ERROR;
} }
min = max - range + 1; min = max - range;
if (ngx_quic_handle_ack_frame_range(c, ctx, min, max, &send_time) if (ngx_quic_handle_ack_frame_range(c, ctx, min, max, &send_time)
!= NGX_OK) != NGX_OK)
@ -2393,6 +2393,9 @@ ngx_quic_handle_ack_frame_range(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx,
ngx_quic_frame_t *f; ngx_quic_frame_t *f;
ngx_quic_connection_t *qc; ngx_quic_connection_t *qc;
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic handle ack range: min:%uL max:%uL", min, max);
qc = c->quic; qc = c->quic;
*send_time = NGX_TIMER_INFINITE; *send_time = NGX_TIMER_INFINITE;