comparison src/event/ngx_event_quic_transport.c @ 8359:2f900ae486bc quic

Debug cleanup. + all dumps are moved under one of the following macros (undefined by default): NGX_QUIC_DEBUG_PACKETS NGX_QUIC_DEBUG_FRAMES NGX_QUIC_DEBUG_FRAMES_ALLOC NGX_QUIC_DEBUG_CRYPTO + all QUIC debug messages got "quic " prefix + all input frames are reported as "quic frame in FOO_FRAME bar:1 baz:2" + all outgoing frames re reported as "quic frame out foo bar baz" + all stream operations are prefixed with id, like: "quic stream id 0x33 recv" + all transport parameters are prefixed with "quic tp" (hex dump is moved to caller, to avoid using ngx_cycle->log) + packet flags and some other debug messages are updated to include packet type
author Vladimir Homutov <vl@nginx.com>
date Fri, 24 Apr 2020 10:11:47 +0300
parents 2a6e91a1691d
children f175006124d0
comparison
equal deleted inserted replaced
8358:2a6e91a1691d 8359:2f900ae486bc
232 uint8_t idlen; 232 uint8_t idlen;
233 233
234 p = pkt->data; 234 p = pkt->data;
235 end = pkt->data + pkt->len; 235 end = pkt->data + pkt->len;
236 236
237 #ifdef NGX_QUIC_DEBUG_PACKETS
237 ngx_quic_hexdump0(pkt->log, "long input", pkt->data, pkt->len); 238 ngx_quic_hexdump0(pkt->log, "long input", pkt->data, pkt->len);
239 #endif
238 240
239 p = ngx_quic_read_uint8(p, end, &pkt->flags); 241 p = ngx_quic_read_uint8(p, end, &pkt->flags);
240 if (p == NULL) { 242 if (p == NULL) {
241 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, 243 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
242 "packet is too small to read flags"); 244 "packet is too small to read flags");
254 "packet is too small to read version"); 256 "packet is too small to read version");
255 return NGX_ERROR; 257 return NGX_ERROR;
256 } 258 }
257 259
258 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 260 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
259 "quic flags:%xi version:%xD", pkt->flags, pkt->version); 261 "quic long packet flags:%xi version:%xD",
262 pkt->flags, pkt->version);
260 263
261 if (pkt->version != NGX_QUIC_VERSION) { 264 if (pkt->version != NGX_QUIC_VERSION) {
262 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, 265 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
263 "unsupported quic version: 0x%xi", pkt->version); 266 "unsupported quic version: 0x%xi", pkt->version);
264 return NGX_ERROR; 267 return NGX_ERROR;
386 u_char *p, *end; 389 u_char *p, *end;
387 390
388 p = pkt->data; 391 p = pkt->data;
389 end = pkt->data + pkt->len; 392 end = pkt->data + pkt->len;
390 393
394 #ifdef NGX_QUIC_DEBUG_PACKETS
391 ngx_quic_hexdump0(pkt->log, "short input", pkt->data, pkt->len); 395 ngx_quic_hexdump0(pkt->log, "short input", pkt->data, pkt->len);
396 #endif
392 397
393 p = ngx_quic_read_uint8(p, end, &pkt->flags); 398 p = ngx_quic_read_uint8(p, end, &pkt->flags);
394 if (p == NULL) { 399 if (p == NULL) {
395 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, 400 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
396 "packet is too small to read flags"); 401 "packet is too small to read flags");
401 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "not a short packet"); 406 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "not a short packet");
402 return NGX_ERROR; 407 return NGX_ERROR;
403 } 408 }
404 409
405 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 410 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
406 "quic flags:%xi", pkt->flags); 411 "quic short packet flags:%xi", pkt->flags);
407 412
408 if (ngx_memcmp(p, dcid->data, dcid->len) != 0) { 413 if (ngx_memcmp(p, dcid->data, dcid->len) != 0) {
409 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "unexpected quic dcid"); 414 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "unexpected quic dcid");
410 return NGX_ERROR; 415 return NGX_ERROR;
411 } 416 }
458 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "bad packet length"); 463 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "bad packet length");
459 return NGX_ERROR; 464 return NGX_ERROR;
460 } 465 }
461 466
462 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 467 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
463 "quic packet length: %uL", varint); 468 "quic initial packet length: %uL", varint);
464 469
465 if (varint > (uint64_t) ((pkt->data + pkt->len) - p)) { 470 if (varint > (uint64_t) ((pkt->data + pkt->len) - p)) {
466 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "truncated initial packet"); 471 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "truncated initial packet");
467 return NGX_ERROR; 472 return NGX_ERROR;
468 } 473 }
469 474
470 pkt->raw->pos = p; 475 pkt->raw->pos = p;
471 pkt->len = varint; 476 pkt->len = varint;
472 477
478 #ifdef NGX_QUIC_DEBUG_PACKETS
473 ngx_quic_hexdump0(pkt->log, "DCID", pkt->dcid.data, pkt->dcid.len); 479 ngx_quic_hexdump0(pkt->log, "DCID", pkt->dcid.data, pkt->dcid.len);
474 ngx_quic_hexdump0(pkt->log, "SCID", pkt->scid.data, pkt->scid.len); 480 ngx_quic_hexdump0(pkt->log, "SCID", pkt->scid.data, pkt->scid.len);
475 ngx_quic_hexdump0(pkt->log, "token", pkt->token.data, pkt->token.len); 481 ngx_quic_hexdump0(pkt->log, "token", pkt->token.data, pkt->token.len);
482 #endif
476 483
477 return NGX_OK; 484 return NGX_OK;
478 } 485 }
479 486
480 487
494 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "bad packet length"); 501 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "bad packet length");
495 return NGX_ERROR; 502 return NGX_ERROR;
496 } 503 }
497 504
498 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 505 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
499 "quic packet length: %uL", plen); 506 "quic handshake packet length: %uL", plen);
500 507
501 if (plen > (uint64_t)((pkt->data + pkt->len) - p)) { 508 if (plen > (uint64_t)((pkt->data + pkt->len) - p)) {
502 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "truncated handshake packet"); 509 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "truncated handshake packet");
503 return NGX_ERROR; 510 return NGX_ERROR;
504 } 511 }
563 "failed to parse crypto frame data"); 570 "failed to parse crypto frame data");
564 return NGX_ERROR; 571 return NGX_ERROR;
565 } 572 }
566 573
567 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 574 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
568 "quic CRYPTO frame length: %uL off:%uL pp:%p", 575 "quic frame in: CRYPTO length: %uL off:%uL pp:%p",
569 f->u.crypto.length, f->u.crypto.offset, 576 f->u.crypto.length, f->u.crypto.offset,
570 f->u.crypto.data); 577 f->u.crypto.data);
571 578
579 #ifdef NGX_QUIC_DEBUG_FRAMES
572 ngx_quic_hexdump0(pkt->log, "CRYPTO frame contents", 580 ngx_quic_hexdump0(pkt->log, "CRYPTO frame contents",
573 f->u.crypto.data, f->u.crypto.length); 581 f->u.crypto.data, f->u.crypto.length);
582 #endif
574 break; 583 break;
575 584
576 case NGX_QUIC_FT_PADDING: 585 case NGX_QUIC_FT_PADDING:
577 586
578 /* allowed in any packet type */ 587 /* allowed in any packet type */
618 } 627 }
619 628
620 f->u.ack.ranges_end = p; 629 f->u.ack.ranges_end = p;
621 630
622 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 631 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
623 "ACK: { largest=%ui delay=%ui count=%ui first=%ui}", 632 "quic frame in ACK largest:%ui delay:%ui"
624 f->u.ack.largest, 633 " count:%ui first:%ui", f->u.ack.largest,
625 f->u.ack.delay, 634 f->u.ack.delay,
626 f->u.ack.range_count, 635 f->u.ack.range_count,
627 f->u.ack.first_range); 636 f->u.ack.first_range);
628 637
629 if (f->type == NGX_QUIC_FT_ACK_ECN) { 638 if (f->type == NGX_QUIC_FT_ACK_ECN) {
636 "failed to parse ack frame ECT counts", i); 645 "failed to parse ack frame ECT counts", i);
637 return NGX_ERROR; 646 return NGX_ERROR;
638 } 647 }
639 648
640 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 649 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
641 "ACK ECN counters: %ui %ui %ui", 650 "quic ACK ECN counters: %ui %ui %ui",
642 f->u.ack.ect0, f->u.ack.ect1, f->u.ack.ce); 651 f->u.ack.ect0, f->u.ack.ect1, f->u.ack.ce);
643 } 652 }
644 653
645 break; 654 break;
646 655
690 "failed to parse new connection id srt"); 699 "failed to parse new connection id srt");
691 return NGX_ERROR; 700 return NGX_ERROR;
692 } 701 }
693 702
694 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 703 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
695 "NCID: { seq=%ui retire=%ui len=%ui}", 704 "quic frame in: NCID seq:%ui retire:%ui len:%ui",
696 f->u.ncid.seqnum, f->u.ncid.retire, f->u.ncid.len); 705 f->u.ncid.seqnum, f->u.ncid.retire, f->u.ncid.len);
697 break; 706 break;
698 707
699 case NGX_QUIC_FT_CONNECTION_CLOSE2: 708 case NGX_QUIC_FT_CONNECTION_CLOSE2:
700 709
744 } 753 }
745 754
746 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) { 755 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) {
747 756
748 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 757 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
749 "CONN.CLOSE: { %s (0x%xi) type=0x%xi reason='%V'}", 758 "quic frame in CONNECTION_CLOSE"
759 " err:%s code:0x%xi type:0x%xi reason:'%V'",
750 ngx_quic_error_text(f->u.close.error_code), 760 ngx_quic_error_text(f->u.close.error_code),
751 f->u.close.error_code, f->u.close.frame_type, 761 f->u.close.error_code, f->u.close.frame_type,
752 &f->u.close.reason); 762 &f->u.close.reason);
753 } else { 763 } else {
754 764
755 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 765 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
756 "CONN.CLOSE2: { (0x%xi) reason '%V'}", 766 "quic frame in: CONNECTION_CLOSE2:"
767 " code:0x%xi reason:'%V'",
757 f->u.close.error_code, &f->u.close.reason); 768 f->u.close.error_code, &f->u.close.reason);
758 } 769 }
759 770
760 break; 771 break;
761 772
817 "offset=%ui", f->u.stream.length, f->u.stream.offset); 828 "offset=%ui", f->u.stream.length, f->u.stream.offset);
818 return NGX_ERROR; 829 return NGX_ERROR;
819 } 830 }
820 831
821 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 832 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
822 "STREAM frame { 0x%xi id 0x%xi offset 0x%xi " 833 "quic frame in: STREAM type:0x%xi id:0x%xi offset:0x%xi "
823 "len 0x%xi bits:off=%d len=%d fin=%d }", 834 "len:0x%xi bits off:%d len:%d fin:%d",
824 f->type, f->u.stream.stream_id, f->u.stream.offset, 835 f->type, f->u.stream.stream_id, f->u.stream.offset,
825 f->u.stream.length, f->u.stream.off, f->u.stream.len, 836 f->u.stream.length, f->u.stream.off, f->u.stream.len,
826 f->u.stream.fin); 837 f->u.stream.fin);
827 838
839 #ifdef NGX_QUIC_DEBUG_FRAMES
828 ngx_quic_hexdump0(pkt->log, "STREAM frame contents", 840 ngx_quic_hexdump0(pkt->log, "STREAM frame contents",
829 f->u.stream.data, f->u.stream.length); 841 f->u.stream.data, f->u.stream.length);
842 #endif
830 break; 843 break;
831 844
832 case NGX_QUIC_FT_MAX_DATA: 845 case NGX_QUIC_FT_MAX_DATA:
833 846
834 if (!(ngx_quic_short_pkt(flags) || ngx_quic_pkt_zrtt(flags))) { 847 if (!(ngx_quic_short_pkt(flags) || ngx_quic_pkt_zrtt(flags))) {
841 "failed to parse max data frame"); 854 "failed to parse max data frame");
842 return NGX_ERROR; 855 return NGX_ERROR;
843 } 856 }
844 857
845 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 858 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
846 "MAX_DATA frame { Maximum Data %ui }", 859 "quic frame in: MAX_DATA max_data:%ui",
847 f->u.max_data.max_data); 860 f->u.max_data.max_data);
848 break; 861 break;
849 862
850 case NGX_QUIC_FT_RESET_STREAM: 863 case NGX_QUIC_FT_RESET_STREAM:
851 864
862 "failed to parse reset stream frame"); 875 "failed to parse reset stream frame");
863 return NGX_ERROR; 876 return NGX_ERROR;
864 } 877 }
865 878
866 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 879 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
867 "RESET STREAM frame" 880 "quic frame in: RESET_STREAM"
868 " { id 0x%xi error_code 0x%xi final_size 0x%xi }", 881 " id:0x%xi error_code:0x%xi final_size:0x%xi",
869 f->u.reset_stream.id, f->u.reset_stream.error_code, 882 f->u.reset_stream.id, f->u.reset_stream.error_code,
870 f->u.reset_stream.final_size); 883 f->u.reset_stream.final_size);
871 break; 884 break;
872 885
873 case NGX_QUIC_FT_STOP_SENDING: 886 case NGX_QUIC_FT_STOP_SENDING:
889 "failed to parse stop sending frame error code"); 902 "failed to parse stop sending frame error code");
890 return NGX_ERROR; 903 return NGX_ERROR;
891 } 904 }
892 905
893 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 906 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
894 "STOP SENDING frame { id 0x%xi error_code 0x%xi}", 907 "quic frame in: STOP_SENDING id:0x%xi error_code:0x%xi",
895 f->u.stop_sending.id, f->u.stop_sending.error_code); 908 f->u.stop_sending.id, f->u.stop_sending.error_code);
896 909
897 break; 910 break;
898 911
899 case NGX_QUIC_FT_STREAMS_BLOCKED: 912 case NGX_QUIC_FT_STREAMS_BLOCKED:
912 925
913 f->u.streams_blocked.bidi = 926 f->u.streams_blocked.bidi =
914 (f->type == NGX_QUIC_FT_STREAMS_BLOCKED) ? 1 : 0; 927 (f->type == NGX_QUIC_FT_STREAMS_BLOCKED) ? 1 : 0;
915 928
916 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 929 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
917 "STREAMS BLOCKED frame { limit %ui bidi: %d }", 930 "quic frame in: STREAMS_BLOCKED limit:%ui bidi:%d",
918 f->u.streams_blocked.limit, 931 f->u.streams_blocked.limit,
919 f->u.streams_blocked.bidi); 932 f->u.streams_blocked.bidi);
920 933
921 break; 934 break;
922 935
952 } 965 }
953 966
954 f->u.max_streams.bidi = (f->type == NGX_QUIC_FT_MAX_STREAMS) ? 1 : 0; 967 f->u.max_streams.bidi = (f->type == NGX_QUIC_FT_MAX_STREAMS) ? 1 : 0;
955 968
956 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 969 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
957 "MAX STREAMS frame { limit %ui bidi: %d }", 970 "quic frame in: MAX_STREAMS limit:%ui bidi:%d",
958 f->u.max_streams.limit, 971 f->u.max_streams.limit,
959 f->u.max_streams.bidi); 972 f->u.max_streams.bidi);
960 break; 973 break;
961 974
962 case NGX_QUIC_FT_MAX_STREAM_DATA: 975 case NGX_QUIC_FT_MAX_STREAM_DATA:
978 "failed to parse max stream data frame data limit"); 991 "failed to parse max stream data frame data limit");
979 return NGX_ERROR; 992 return NGX_ERROR;
980 } 993 }
981 994
982 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 995 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
983 "MAX STREAM DATA frame { id: %ui limit: %ui }", 996 "quic frame in: MAX_STREAM_DATA id:%ui limit:%ui",
984 f->u.max_stream_data.id, 997 f->u.max_stream_data.id,
985 f->u.max_stream_data.limit); 998 f->u.max_stream_data.limit);
986 break; 999 break;
987 1000
988 case NGX_QUIC_FT_DATA_BLOCKED: 1001 case NGX_QUIC_FT_DATA_BLOCKED:
997 "failed to parse data blocked frame limit"); 1010 "failed to parse data blocked frame limit");
998 return NGX_ERROR; 1011 return NGX_ERROR;
999 } 1012 }
1000 1013
1001 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 1014 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1002 "DATA BLOCKED frame { limit %ui }", 1015 "quic frame in: DATA_BLOCKED limit:%ui",
1003 f->u.data_blocked.limit); 1016 f->u.data_blocked.limit);
1004 break; 1017 break;
1005 1018
1006 case NGX_QUIC_FT_STREAM_DATA_BLOCKED: 1019 case NGX_QUIC_FT_STREAM_DATA_BLOCKED:
1007 1020
1022 "failed to parse tream data blocked frame limit"); 1035 "failed to parse tream data blocked frame limit");
1023 return NGX_ERROR; 1036 return NGX_ERROR;
1024 } 1037 }
1025 1038
1026 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 1039 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1027 "STREAM DATA BLOCKED frame { id: %ui limit: %ui }", 1040 "quic frame in: STREAM_DATA_BLOCKED"
1041 " id:%ui limit:%ui",
1028 f->u.stream_data_blocked.id, 1042 f->u.stream_data_blocked.id,
1029 f->u.stream_data_blocked.limit); 1043 f->u.stream_data_blocked.limit);
1030 break; 1044 break;
1031 1045
1032 case NGX_QUIC_FT_RETIRE_CONNECTION_ID: 1046 case NGX_QUIC_FT_RETIRE_CONNECTION_ID:
1042 " frame sequence number"); 1056 " frame sequence number");
1043 return NGX_ERROR; 1057 return NGX_ERROR;
1044 } 1058 }
1045 1059
1046 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 1060 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1047 "RETIRE CONNECTION ID frame { sequence_number %ui }", 1061 "quic frame in: RETIRE_CONNECTION_ID"
1062 " sequence_number:%ui",
1048 f->u.retire_cid.sequence_number); 1063 f->u.retire_cid.sequence_number);
1049 break; 1064 break;
1050 1065
1051 case NGX_QUIC_FT_PATH_CHALLENGE: 1066 case NGX_QUIC_FT_PATH_CHALLENGE:
1052 1067
1060 "failed to get path challenge frame data"); 1075 "failed to get path challenge frame data");
1061 return NGX_ERROR; 1076 return NGX_ERROR;
1062 } 1077 }
1063 1078
1064 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 1079 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1065 "PATH CHALLENGE frame"); 1080 "quic frame in: PATH_CHALLENGE");
1066 1081
1082 #ifdef NGX_QUIC_DEBUG_FRAMES
1067 ngx_quic_hexdump0(pkt->log, "path challenge data", 1083 ngx_quic_hexdump0(pkt->log, "path challenge data",
1068 f->u.path_challenge.data, 8); 1084 f->u.path_challenge.data, 8);
1085 #endif
1069 break; 1086 break;
1070 1087
1071 case NGX_QUIC_FT_PATH_RESPONSE: 1088 case NGX_QUIC_FT_PATH_RESPONSE:
1072 1089
1073 if (!(ngx_quic_short_pkt(flags) || ngx_quic_pkt_zrtt(flags))) { 1090 if (!(ngx_quic_short_pkt(flags) || ngx_quic_pkt_zrtt(flags))) {
1080 "failed to get path response frame data"); 1097 "failed to get path response frame data");
1081 return NGX_ERROR; 1098 return NGX_ERROR;
1082 } 1099 }
1083 1100
1084 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 1101 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1085 "PATH RESPONSE frame"); 1102 "quic frame in: PATH_RESPONSE");
1086 1103
1104 #ifdef NGX_QUIC_DEBUG_FRAMES
1087 ngx_quic_hexdump0(pkt->log, "path response data", 1105 ngx_quic_hexdump0(pkt->log, "path response data",
1088 f->u.path_response.data, 8); 1106 f->u.path_response.data, 8);
1107 #endif
1089 break; 1108 break;
1090 1109
1091 default: 1110 default:
1092 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, 1111 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
1093 "unknown frame type 0x%xi in packet", f->type); 1112 "unknown frame type 0x%xi in packet", f->type);
1128 "failed to parse ack frame range"); 1147 "failed to parse ack frame range");
1129 return NGX_ERROR; 1148 return NGX_ERROR;
1130 } 1149 }
1131 1150
1132 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 1151 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1133 "ACK range: gap %ui range %ui", *gap, *range); 1152 "quic ACK range: gap %ui range %ui", *gap, *range);
1134 1153
1135 return p - start; 1154 return p - start;
1136 } 1155 }
1137 1156
1138 1157
1470 end - p); 1489 end - p);
1471 return NGX_ERROR; 1490 return NGX_ERROR;
1472 } 1491 }
1473 1492
1474 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, log, 0, 1493 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, log, 0,
1475 "client transport parameters parsed successfully"); 1494 "quic transport parameters parsed ok");
1476 1495
1477 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, 1496 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0,
1478 "disable active migration: %ui", 1497 "quic tp disable active migration: %ui",
1479 tp->disable_active_migration); 1498 tp->disable_active_migration);
1480 1499
1481 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "idle timeout: %ui", 1500 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp idle_timeout: %ui",
1482 tp->max_idle_timeout); 1501 tp->max_idle_timeout);
1483 1502
1484 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "max packet size: %ui", 1503 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp max_packet_size: %ui",
1485 tp->max_packet_size); 1504 tp->max_packet_size);
1486 1505
1487 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "max data: %ui", 1506 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp max_data: %ui",
1488 tp->initial_max_data); 1507 tp->initial_max_data);
1489 1508
1490 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, 1509 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0,
1491 "max stream data bidi local: %ui", 1510 "quic tp max_stream_data_bidi_local: %ui",
1492 tp->initial_max_stream_data_bidi_local); 1511 tp->initial_max_stream_data_bidi_local);
1493 1512
1494 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, 1513 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0,
1495 "max stream data bidi remote: %ui", 1514 "quic tp max_stream_data_bidi_remote: %ui",
1496 tp->initial_max_stream_data_bidi_remote); 1515 tp->initial_max_stream_data_bidi_remote);
1497 1516
1498 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "max stream data uni: %ui", 1517 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0,
1518 "quic tp max_stream_data_uni: %ui",
1499 tp->initial_max_stream_data_uni); 1519 tp->initial_max_stream_data_uni);
1500 1520
1501 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, 1521 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0,
1502 "initial max streams bidi: %ui", 1522 "quic tp initial_max_streams_bidi: %ui",
1503 tp->initial_max_streams_bidi); 1523 tp->initial_max_streams_bidi);
1504 1524
1505 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "initial max streams uni: %ui", 1525 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0,
1526 "quic tp initial_max_streams_uni: %ui",
1506 tp->initial_max_streams_uni); 1527 tp->initial_max_streams_uni);
1507 1528
1508 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "ack delay exponent: %ui", 1529 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0,
1530 "quic tp ack_delay_exponent: %ui",
1509 tp->ack_delay_exponent); 1531 tp->ack_delay_exponent);
1510 1532
1511 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "max ack delay: %ui", 1533 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, "quic tp max_ack_delay: %ui",
1512 tp->max_ack_delay); 1534 tp->max_ack_delay);
1513 1535
1514 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0, 1536 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, log, 0,
1515 "active connection id limit: %ui", 1537 "quic tp active_connection_id_limit: %ui",
1516 tp->active_connection_id_limit); 1538 tp->active_connection_id_limit);
1517 1539
1518 return NGX_OK; 1540 return NGX_OK;
1519 } 1541 }
1520 1542
1566 ssize_t 1588 ssize_t
1567 ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp) 1589 ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp)
1568 { 1590 {
1569 u_char *p; 1591 u_char *p;
1570 size_t len; 1592 size_t len;
1571
1572 /* recent drafts with variable integer transport parameters encoding */
1573 1593
1574 #define ngx_quic_tp_len(id, value) \ 1594 #define ngx_quic_tp_len(id, value) \
1575 ngx_quic_varint_len(id) \ 1595 ngx_quic_varint_len(id) \
1576 + ngx_quic_varint_len(value) \ 1596 + ngx_quic_varint_len(value) \
1577 + ngx_quic_varint_len(ngx_quic_varint_len(value)) 1597 + ngx_quic_varint_len(ngx_quic_varint_len(value))
1634 tp->initial_max_stream_data_uni); 1654 tp->initial_max_stream_data_uni);
1635 1655
1636 ngx_quic_tp_vint(NGX_QUIC_TP_MAX_IDLE_TIMEOUT, 1656 ngx_quic_tp_vint(NGX_QUIC_TP_MAX_IDLE_TIMEOUT,
1637 tp->max_idle_timeout); 1657 tp->max_idle_timeout);
1638 1658
1639 ngx_quic_hexdump0(ngx_cycle->log, "transport parameters", pos, p - pos);
1640
1641 return p - pos; 1659 return p - pos;
1642 } 1660 }
1643 1661
1644 1662
1645 static size_t 1663 static size_t