comparison src/event/ngx_event_quic.c @ 8020:69033a50c3ae quic

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.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 07 Aug 2020 12:34:15 +0300
parents fc16e303003a
children b66a2a041d7e
comparison
equal deleted inserted replaced
8019:fc16e303003a 8020:69033a50c3ae
2287 ngx_quic_handle_ack_frame(ngx_connection_t *c, ngx_quic_header_t *pkt, 2287 ngx_quic_handle_ack_frame(ngx_connection_t *c, ngx_quic_header_t *pkt,
2288 ngx_quic_ack_frame_t *ack) 2288 ngx_quic_ack_frame_t *ack)
2289 { 2289 {
2290 ssize_t n; 2290 ssize_t n;
2291 u_char *pos, *end; 2291 u_char *pos, *end;
2292 uint64_t gap, range; 2292 uint64_t min, max, gap, range;
2293 ngx_msec_t send_time; 2293 ngx_msec_t send_time;
2294 ngx_uint_t i, min, max; 2294 ngx_uint_t i;
2295 ngx_quic_send_ctx_t *ctx; 2295 ngx_quic_send_ctx_t *ctx;
2296 ngx_quic_connection_t *qc; 2296 ngx_quic_connection_t *qc;
2297 2297
2298 qc = c->quic; 2298 qc = c->quic;
2299 2299
2326 2326
2327 /* 13.2.3. Receiver Tracking of ACK Frames */ 2327 /* 13.2.3. Receiver Tracking of ACK Frames */
2328 if (ctx->largest_ack < max) { 2328 if (ctx->largest_ack < max) {
2329 ctx->largest_ack = max; 2329 ctx->largest_ack = max;
2330 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 2330 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
2331 "quic updated largest received ack: %ui", max); 2331 "quic updated largest received ack: %uL", max);
2332 2332
2333 /* 2333 /*
2334 * An endpoint generates an RTT sample on receiving an 2334 * An endpoint generates an RTT sample on receiving an
2335 * ACK frame that meets the following two conditions: 2335 * ACK frame that meets the following two conditions:
2336 * 2336 *
2352 if (n == NGX_ERROR) { 2352 if (n == NGX_ERROR) {
2353 return NGX_ERROR; 2353 return NGX_ERROR;
2354 } 2354 }
2355 pos += n; 2355 pos += n;
2356 2356
2357 if (gap >= min) { 2357 if (gap + 2 > min) {
2358 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; 2358 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR;
2359 ngx_log_error(NGX_LOG_INFO, c->log, 0, 2359 ngx_log_error(NGX_LOG_INFO, c->log, 0,
2360 "quic invalid range %ui in ack frame", i); 2360 "quic invalid range %ui in ack frame", i);
2361 return NGX_ERROR; 2361 return NGX_ERROR;
2362 } 2362 }
2363 2363
2364 max = min - 1 - gap; 2364 max = min - gap - 2;
2365 2365
2366 if (range > max + 1) { 2366 if (range > max) {
2367 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; 2367 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR;
2368 ngx_log_error(NGX_LOG_INFO, c->log, 0, 2368 ngx_log_error(NGX_LOG_INFO, c->log, 0,
2369 "quic invalid range %ui in ack frame", i); 2369 "quic invalid range %ui in ack frame", i);
2370 return NGX_ERROR; 2370 return NGX_ERROR;
2371 } 2371 }
2372 2372
2373 min = max - range + 1; 2373 min = max - range;
2374 2374
2375 if (ngx_quic_handle_ack_frame_range(c, ctx, min, max, &send_time) 2375 if (ngx_quic_handle_ack_frame_range(c, ctx, min, max, &send_time)
2376 != NGX_OK) 2376 != NGX_OK)
2377 { 2377 {
2378 return NGX_ERROR; 2378 return NGX_ERROR;
2390 uint64_t found_num; 2390 uint64_t found_num;
2391 ngx_uint_t found; 2391 ngx_uint_t found;
2392 ngx_queue_t *q; 2392 ngx_queue_t *q;
2393 ngx_quic_frame_t *f; 2393 ngx_quic_frame_t *f;
2394 ngx_quic_connection_t *qc; 2394 ngx_quic_connection_t *qc;
2395
2396 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
2397 "quic handle ack range: min:%uL max:%uL", min, max);
2395 2398
2396 qc = c->quic; 2399 qc = c->quic;
2397 2400
2398 *send_time = NGX_TIMER_INFINITE; 2401 *send_time = NGX_TIMER_INFINITE;
2399 found = 0; 2402 found = 0;