comparison src/event/ngx_event_quic_transport.c @ 8604:b3d9e57d0f62 quic

QUIC: single function for frame debug logging. The function may be called for any initialized frame, both rx and tx. While there, shortened level names.
author Vladimir Homutov <vl@nginx.com>
date Tue, 27 Oct 2020 14:32:08 +0300
parents 38c7dd720774
children eed49b83e18f
comparison
equal deleted inserted replaced
8603:c5ea341f705a 8604:b3d9e57d0f62
697 p = ngx_quic_read_bytes(p, end, f->u.crypto.length, &f->u.crypto.data); 697 p = ngx_quic_read_bytes(p, end, f->u.crypto.length, &f->u.crypto.data);
698 if (p == NULL) { 698 if (p == NULL) {
699 goto error; 699 goto error;
700 } 700 }
701 701
702 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
703 "quic frame in: CRYPTO length: %uL off:%uL",
704 f->u.crypto.length, f->u.crypto.offset);
705
706 break; 702 break;
707 703
708 case NGX_QUIC_FT_PADDING: 704 case NGX_QUIC_FT_PADDING:
709 705
710 while (p < end && *p == NGX_QUIC_FT_PADDING) { 706 while (p < end && *p == NGX_QUIC_FT_PADDING) {
738 goto error; 734 goto error;
739 } 735 }
740 } 736 }
741 737
742 f->u.ack.ranges_end = p; 738 f->u.ack.ranges_end = p;
743
744 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
745 "quic frame in ACK largest:%uL delay:%uL"
746 " count:%uL first:%uL", f->u.ack.largest,
747 f->u.ack.delay,
748 f->u.ack.range_count,
749 f->u.ack.first_range);
750 739
751 if (f->type == NGX_QUIC_FT_ACK_ECN) { 740 if (f->type == NGX_QUIC_FT_ACK_ECN) {
752 741
753 if (!((p = ngx_quic_parse_int(p, end, &f->u.ack.ect0)) 742 if (!((p = ngx_quic_parse_int(p, end, &f->u.ack.ect0))
754 && (p = ngx_quic_parse_int(p, end, &f->u.ack.ect1)) 743 && (p = ngx_quic_parse_int(p, end, &f->u.ack.ect1))
800 p = ngx_quic_copy_bytes(p, end, NGX_QUIC_SR_TOKEN_LEN, f->u.ncid.srt); 789 p = ngx_quic_copy_bytes(p, end, NGX_QUIC_SR_TOKEN_LEN, f->u.ncid.srt);
801 if (p == NULL) { 790 if (p == NULL) {
802 goto error; 791 goto error;
803 } 792 }
804 793
805 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
806 "quic frame in: NCID seq:%uL retire:%uL len:%ud",
807 f->u.ncid.seqnum, f->u.ncid.retire, f->u.ncid.len);
808 break; 794 break;
809 795
810 case NGX_QUIC_FT_RETIRE_CONNECTION_ID: 796 case NGX_QUIC_FT_RETIRE_CONNECTION_ID:
811 797
812 p = ngx_quic_parse_int(p, end, &f->u.retire_cid.sequence_number); 798 p = ngx_quic_parse_int(p, end, &f->u.retire_cid.sequence_number);
813 if (p == NULL) { 799 if (p == NULL) {
814 goto error; 800 goto error;
815 } 801 }
816 802
817 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
818 "quic frame in: RETIRE_CONNECTION_ID"
819 " sequence_number:%uL",
820 f->u.retire_cid.sequence_number);
821 break; 803 break;
822 804
823 case NGX_QUIC_FT_CONNECTION_CLOSE: 805 case NGX_QUIC_FT_CONNECTION_CLOSE:
824 case NGX_QUIC_FT_CONNECTION_CLOSE_APP: 806 case NGX_QUIC_FT_CONNECTION_CLOSE_APP:
825 807
844 826
845 p = ngx_quic_read_bytes(p, end, f->u.close.reason.len, 827 p = ngx_quic_read_bytes(p, end, f->u.close.reason.len,
846 &f->u.close.reason.data); 828 &f->u.close.reason.data);
847 if (p == NULL) { 829 if (p == NULL) {
848 goto error; 830 goto error;
849 }
850
851 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) {
852
853 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
854 "quic frame in CONNECTION_CLOSE"
855 " err:%s code:0x%xL type:0x%xL reason:'%V'",
856 ngx_quic_error_text(f->u.close.error_code),
857 f->u.close.error_code, f->u.close.frame_type,
858 &f->u.close.reason);
859 } else {
860
861 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
862 "quic frame in: CONNECTION_CLOSE_APP:"
863 " code:0x%xL reason:'%V'",
864 f->u.close.error_code, &f->u.close.reason);
865 } 831 }
866 832
867 break; 833 break;
868 834
869 case NGX_QUIC_FT_STREAM0: 835 case NGX_QUIC_FT_STREAM0:
910 &f->u.stream.data); 876 &f->u.stream.data);
911 if (p == NULL) { 877 if (p == NULL) {
912 goto error; 878 goto error;
913 } 879 }
914 880
915 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
916 "quic frame in: STREAM type:0x%xi id:0x%xL offset:0x%xL "
917 "len:0x%xL bits off:%d len:%d fin:%d",
918 f->type, f->u.stream.stream_id, f->u.stream.offset,
919 f->u.stream.length, f->u.stream.off, f->u.stream.len,
920 f->u.stream.fin);
921
922 #ifdef NGX_QUIC_DEBUG_FRAMES 881 #ifdef NGX_QUIC_DEBUG_FRAMES
923 ngx_quic_hexdump(pkt->log, "quic STREAM frame", 882 ngx_quic_hexdump(pkt->log, "quic STREAM frame",
924 f->u.stream.data, f->u.stream.length); 883 f->u.stream.data, f->u.stream.length);
925 #endif 884 #endif
926 break; 885 break;
927 886
928 case NGX_QUIC_FT_MAX_DATA: 887 case NGX_QUIC_FT_MAX_DATA:
929 888
930 p = ngx_quic_parse_int(p, end, &f->u.max_data.max_data); 889 p = ngx_quic_parse_int(p, end, &f->u.max_data.max_data);
931 if (p == NULL) { 890 if (p == NULL) {
932 goto error; 891 goto error;
933 } 892 }
934 893
935 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
936 "quic frame in: MAX_DATA max_data:%uL",
937 f->u.max_data.max_data);
938 break; 894 break;
939 895
940 case NGX_QUIC_FT_RESET_STREAM: 896 case NGX_QUIC_FT_RESET_STREAM:
941 897
942 if (!((p = ngx_quic_parse_int(p, end, &f->u.reset_stream.id)) 898 if (!((p = ngx_quic_parse_int(p, end, &f->u.reset_stream.id))
945 &f->u.reset_stream.final_size)))) 901 &f->u.reset_stream.final_size))))
946 { 902 {
947 goto error; 903 goto error;
948 } 904 }
949 905
950 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
951 "quic frame in: RESET_STREAM"
952 " id:0x%xL error_code:0x%xL final_size:0x%xL",
953 f->u.reset_stream.id, f->u.reset_stream.error_code,
954 f->u.reset_stream.final_size);
955 break; 906 break;
956 907
957 case NGX_QUIC_FT_STOP_SENDING: 908 case NGX_QUIC_FT_STOP_SENDING:
958 909
959 p = ngx_quic_parse_int(p, end, &f->u.stop_sending.id); 910 p = ngx_quic_parse_int(p, end, &f->u.stop_sending.id);
963 914
964 p = ngx_quic_parse_int(p, end, &f->u.stop_sending.error_code); 915 p = ngx_quic_parse_int(p, end, &f->u.stop_sending.error_code);
965 if (p == NULL) { 916 if (p == NULL) {
966 goto error; 917 goto error;
967 } 918 }
968
969 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
970 "quic frame in: STOP_SENDING id:0x%xL error_code:0x%xL",
971 f->u.stop_sending.id, f->u.stop_sending.error_code);
972 919
973 break; 920 break;
974 921
975 case NGX_QUIC_FT_STREAMS_BLOCKED: 922 case NGX_QUIC_FT_STREAMS_BLOCKED:
976 case NGX_QUIC_FT_STREAMS_BLOCKED2: 923 case NGX_QUIC_FT_STREAMS_BLOCKED2:
980 goto error; 927 goto error;
981 } 928 }
982 929
983 f->u.streams_blocked.bidi = 930 f->u.streams_blocked.bidi =
984 (f->type == NGX_QUIC_FT_STREAMS_BLOCKED) ? 1 : 0; 931 (f->type == NGX_QUIC_FT_STREAMS_BLOCKED) ? 1 : 0;
985
986 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
987 "quic frame in: STREAMS_BLOCKED limit:%uL bidi:%ui",
988 f->u.streams_blocked.limit,
989 f->u.streams_blocked.bidi);
990
991 break; 932 break;
992 933
993 case NGX_QUIC_FT_MAX_STREAMS: 934 case NGX_QUIC_FT_MAX_STREAMS:
994 case NGX_QUIC_FT_MAX_STREAMS2: 935 case NGX_QUIC_FT_MAX_STREAMS2:
995 936
998 goto error; 939 goto error;
999 } 940 }
1000 941
1001 f->u.max_streams.bidi = (f->type == NGX_QUIC_FT_MAX_STREAMS) ? 1 : 0; 942 f->u.max_streams.bidi = (f->type == NGX_QUIC_FT_MAX_STREAMS) ? 1 : 0;
1002 943
1003 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1004 "quic frame in: MAX_STREAMS limit:%uL bidi:%ui",
1005 f->u.max_streams.limit,
1006 f->u.max_streams.bidi);
1007 break; 944 break;
1008 945
1009 case NGX_QUIC_FT_MAX_STREAM_DATA: 946 case NGX_QUIC_FT_MAX_STREAM_DATA:
1010 947
1011 p = ngx_quic_parse_int(p, end, &f->u.max_stream_data.id); 948 p = ngx_quic_parse_int(p, end, &f->u.max_stream_data.id);
1016 p = ngx_quic_parse_int(p, end, &f->u.max_stream_data.limit); 953 p = ngx_quic_parse_int(p, end, &f->u.max_stream_data.limit);
1017 if (p == NULL) { 954 if (p == NULL) {
1018 goto error; 955 goto error;
1019 } 956 }
1020 957
1021 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1022 "quic frame in: MAX_STREAM_DATA id:0x%xL limit:%uL",
1023 f->u.max_stream_data.id,
1024 f->u.max_stream_data.limit);
1025 break; 958 break;
1026 959
1027 case NGX_QUIC_FT_DATA_BLOCKED: 960 case NGX_QUIC_FT_DATA_BLOCKED:
1028 961
1029 p = ngx_quic_parse_int(p, end, &f->u.data_blocked.limit); 962 p = ngx_quic_parse_int(p, end, &f->u.data_blocked.limit);
1030 if (p == NULL) { 963 if (p == NULL) {
1031 goto error; 964 goto error;
1032 } 965 }
1033 966
1034 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1035 "quic frame in: DATA_BLOCKED limit:%uL",
1036 f->u.data_blocked.limit);
1037 break; 967 break;
1038 968
1039 case NGX_QUIC_FT_STREAM_DATA_BLOCKED: 969 case NGX_QUIC_FT_STREAM_DATA_BLOCKED:
1040 970
1041 p = ngx_quic_parse_int(p, end, &f->u.stream_data_blocked.id); 971 p = ngx_quic_parse_int(p, end, &f->u.stream_data_blocked.id);
1046 p = ngx_quic_parse_int(p, end, &f->u.stream_data_blocked.limit); 976 p = ngx_quic_parse_int(p, end, &f->u.stream_data_blocked.limit);
1047 if (p == NULL) { 977 if (p == NULL) {
1048 goto error; 978 goto error;
1049 } 979 }
1050 980
1051 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1052 "quic frame in: STREAM_DATA_BLOCKED"
1053 " id:0x%xL limit:%uL",
1054 f->u.stream_data_blocked.id,
1055 f->u.stream_data_blocked.limit);
1056 break; 981 break;
1057 982
1058 case NGX_QUIC_FT_PATH_CHALLENGE: 983 case NGX_QUIC_FT_PATH_CHALLENGE:
1059 984
1060 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_challenge.data); 985 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_challenge.data);
1061 if (p == NULL) { 986 if (p == NULL) {
1062 goto error; 987 goto error;
1063 } 988 }
1064 989
1065 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1066 "quic frame in: PATH_CHALLENGE data:0x%xL",
1067 *(uint64_t *) &f->u.path_challenge.data);
1068 break; 990 break;
1069 991
1070 case NGX_QUIC_FT_PATH_RESPONSE: 992 case NGX_QUIC_FT_PATH_RESPONSE:
1071 993
1072 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_response.data); 994 p = ngx_quic_copy_bytes(p, end, 8, f->u.path_response.data);
1073 if (p == NULL) { 995 if (p == NULL) {
1074 goto error; 996 goto error;
1075 } 997 }
1076 998
1077 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1078 "quic frame in: PATH_RESPONSE data:0x%xL",
1079 *(uint64_t *) &f->u.path_response.data);
1080 break; 999 break;
1081 1000
1082 default: 1001 default:
1083 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, 1002 ngx_log_error(NGX_LOG_INFO, pkt->log, 0,
1084 "quic unknown frame type 0x%xi", f->type); 1003 "quic unknown frame type 0x%xi", f->type);
1085 return NGX_ERROR; 1004 return NGX_ERROR;
1086 } 1005 }
1006
1007 f->level = pkt->level;
1087 1008
1088 return p - start; 1009 return p - start;
1089 1010
1090 error: 1011 error:
1091 1012
1171 return NGX_DECLINED; 1092 return NGX_DECLINED;
1172 } 1093 }
1173 1094
1174 1095
1175 ssize_t 1096 ssize_t
1176 ngx_quic_parse_ack_range(ngx_quic_header_t *pkt, u_char *start, u_char *end, 1097 ngx_quic_parse_ack_range(ngx_log_t *log, u_char *start, u_char *end,
1177 uint64_t *gap, uint64_t *range) 1098 uint64_t *gap, uint64_t *range)
1178 { 1099 {
1179 u_char *p; 1100 u_char *p;
1180 1101
1181 p = start; 1102 p = start;
1182 1103
1183 p = ngx_quic_parse_int(p, end, gap); 1104 p = ngx_quic_parse_int(p, end, gap);
1184 if (p == NULL) { 1105 if (p == NULL) {
1185 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, 1106 ngx_log_error(NGX_LOG_INFO, log, 0,
1186 "quic failed to parse ack frame gap"); 1107 "quic failed to parse ack frame gap");
1187 return NGX_ERROR; 1108 return NGX_ERROR;
1188 } 1109 }
1189 1110
1190 p = ngx_quic_parse_int(p, end, range); 1111 p = ngx_quic_parse_int(p, end, range);
1191 if (p == NULL) { 1112 if (p == NULL) {
1192 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, 1113 ngx_log_error(NGX_LOG_INFO, log, 0,
1193 "quic failed to parse ack frame range"); 1114 "quic failed to parse ack frame range");
1194 return NGX_ERROR; 1115 return NGX_ERROR;
1195 } 1116 }
1196
1197 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
1198 "quic ACK range: gap %uL range %uL", *gap, *range);
1199 1117
1200 return p - start; 1118 return p - start;
1201 } 1119 }
1202 1120
1203 1121