Mercurial > hg > nginx-quic
comparison src/event/ngx_event_quic_transport.c @ 7792:1cdd53532309 quic
ACK ranges processing.
+ since number of ranges in unknown, provide a function to parse them once
again in handler to avoid memory allocation
+ ack handler now processes all ranges, not only the first
+ ECN counters are parsed and saved into frame if present
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Mon, 06 Apr 2020 16:19:26 +0300 |
parents | 853908b5a216 |
children | 167d32476737 |
comparison
equal
deleted
inserted
replaced
7791:9b9d592c0da3 | 7792:1cdd53532309 |
---|---|
559 | 559 |
560 ssize_t | 560 ssize_t |
561 ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end, | 561 ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end, |
562 ngx_quic_frame_t *f) | 562 ngx_quic_frame_t *f) |
563 { | 563 { |
564 u_char *p; | 564 u_char *p; |
565 uint8_t flags; | 565 uint8_t flags; |
566 uint64_t varint; | 566 uint64_t varint; |
567 ngx_uint_t i; | |
567 | 568 |
568 flags = pkt->flags; | 569 flags = pkt->flags; |
569 p = start; | 570 p = start; |
570 | 571 |
571 p = ngx_quic_parse_int(p, end, &varint); | 572 p = ngx_quic_parse_int(p, end, &varint); |
639 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, | 640 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
640 "failed to parse ack frame"); | 641 "failed to parse ack frame"); |
641 return NGX_ERROR; | 642 return NGX_ERROR; |
642 } | 643 } |
643 | 644 |
644 if (f->u.ack.range_count) { | 645 f->u.ack.ranges_start = p; |
645 p = ngx_quic_parse_int(p, end, &f->u.ack.ranges[0]); | 646 |
647 /* process all ranges to get bounds, values are ignored */ | |
648 for (i = 0; i < f->u.ack.range_count; i++) { | |
649 p = ngx_quic_parse_int_multi(p, end, &varint, &varint, NULL); | |
646 if (p == NULL) { | 650 if (p == NULL) { |
647 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, | 651 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
648 "failed to parse ack frame first range"); | 652 "failed to parse ack frame range %ui", i); |
649 return NGX_ERROR; | 653 return NGX_ERROR; |
650 } | 654 } |
651 } | 655 } |
652 | 656 |
653 if (f->type == NGX_QUIC_FT_ACK_ECN) { | 657 f->u.ack.ranges_end = p; |
654 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, | |
655 "TODO: parse ECN ack frames"); | |
656 /* TODO: add parsing of such frames */ | |
657 return NGX_ERROR; | |
658 } | |
659 | 658 |
660 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | 659 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, pkt->log, 0, |
661 "ACK: { largest=%ui delay=%ui count=%ui first=%ui}", | 660 "ACK: { largest=%ui delay=%ui count=%ui first=%ui}", |
662 f->u.ack.largest, | 661 f->u.ack.largest, |
663 f->u.ack.delay, | 662 f->u.ack.delay, |
664 f->u.ack.range_count, | 663 f->u.ack.range_count, |
665 f->u.ack.first_range); | 664 f->u.ack.first_range); |
665 | |
666 if (f->type == NGX_QUIC_FT_ACK_ECN) { | |
667 | |
668 p = ngx_quic_parse_int_multi(p, end, &f->u.ack.ect0, | |
669 &f->u.ack.ect1, &f->u.ack.ce, NULL); | |
670 if (p == NULL) { | |
671 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, | |
672 "failed to parse ack frame ECT counts", i); | |
673 return NGX_ERROR; | |
674 } | |
675 | |
676 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | |
677 "ACK ECN counters: %ui %ui %ui", | |
678 f->u.ack.ect0, f->u.ack.ect1, f->u.ack.ce); | |
679 } | |
666 | 680 |
667 break; | 681 break; |
668 | 682 |
669 case NGX_QUIC_FT_PING: | 683 case NGX_QUIC_FT_PING: |
670 | 684 |
1106 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, | 1120 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, |
1107 "frame type 0x%xi is not allowed in packet with flags 0x%xi", | 1121 "frame type 0x%xi is not allowed in packet with flags 0x%xi", |
1108 f->type, pkt->flags); | 1122 f->type, pkt->flags); |
1109 | 1123 |
1110 return NGX_DECLINED; | 1124 return NGX_DECLINED; |
1125 } | |
1126 | |
1127 | |
1128 ssize_t | |
1129 ngx_quic_parse_ack_range(ngx_quic_header_t *pkt, u_char *start, u_char *end, | |
1130 uint64_t *gap, uint64_t *range) | |
1131 { | |
1132 u_char *p; | |
1133 | |
1134 p = start; | |
1135 | |
1136 p = ngx_quic_parse_int(p, end, gap); | |
1137 if (p == NULL) { | |
1138 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, | |
1139 "failed to parse ack frame gap"); | |
1140 return NGX_ERROR; | |
1141 } | |
1142 | |
1143 p = ngx_quic_parse_int(p, end, range); | |
1144 if (p == NULL) { | |
1145 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, | |
1146 "failed to parse ack frame range"); | |
1147 return NGX_ERROR; | |
1148 } | |
1149 | |
1150 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, | |
1151 "ACK range: gap %ui range %ui", *gap, *range); | |
1152 | |
1153 return p - start; | |
1111 } | 1154 } |
1112 | 1155 |
1113 | 1156 |
1114 ssize_t | 1157 ssize_t |
1115 ngx_quic_create_frame(u_char *p, ngx_quic_frame_t *f) | 1158 ngx_quic_create_frame(u_char *p, ngx_quic_frame_t *f) |