Mercurial > hg > nginx-quic
annotate src/event/quic/ngx_event_quic.c @ 8358:265062a99043 quic
HTTP/3: send GOAWAY when last request is accepted.
The last request in connection is determined according to the keepalive_requests
directive. Requests beyond keepalive_requests are rejected.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Mon, 15 Mar 2021 19:26:04 +0300 |
parents | 0a0b1de9ccab |
children | fc64ab301bad |
rev | line source |
---|---|
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
1 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
2 /* |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
4 */ |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
5 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
6 |
7637 | 7 #include <ngx_config.h> |
8 #include <ngx_core.h> | |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
9 #include <ngx_event.h> |
8004
d0ac4449a07f
QUIC: fixed bulding perl module by reducing header pollution.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8001
diff
changeset
|
10 #include <ngx_event_quic_transport.h> |
d0ac4449a07f
QUIC: fixed bulding perl module by reducing header pollution.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8001
diff
changeset
|
11 #include <ngx_event_quic_protection.h> |
8279 | 12 #include <ngx_sha1.h> |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
13 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
14 |
7773
dc7ac778aafe
Introduced packet namespace in QUIC connection.
Vladimir Homutov <vl@nginx.com>
parents:
7772
diff
changeset
|
15 /* 0-RTT and 1-RTT data exist in the same packet number space, |
dc7ac778aafe
Introduced packet namespace in QUIC connection.
Vladimir Homutov <vl@nginx.com>
parents:
7772
diff
changeset
|
16 * so we have 3 packet number spaces: |
dc7ac778aafe
Introduced packet namespace in QUIC connection.
Vladimir Homutov <vl@nginx.com>
parents:
7772
diff
changeset
|
17 * |
dc7ac778aafe
Introduced packet namespace in QUIC connection.
Vladimir Homutov <vl@nginx.com>
parents:
7772
diff
changeset
|
18 * 0 - Initial |
dc7ac778aafe
Introduced packet namespace in QUIC connection.
Vladimir Homutov <vl@nginx.com>
parents:
7772
diff
changeset
|
19 * 1 - Handshake |
dc7ac778aafe
Introduced packet namespace in QUIC connection.
Vladimir Homutov <vl@nginx.com>
parents:
7772
diff
changeset
|
20 * 2 - 0-RTT and 1-RTT |
dc7ac778aafe
Introduced packet namespace in QUIC connection.
Vladimir Homutov <vl@nginx.com>
parents:
7772
diff
changeset
|
21 */ |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
22 #define ngx_quic_get_send_ctx(qc, level) \ |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
23 ((level) == ssl_encryption_initial) ? &((qc)->send_ctx[0]) \ |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
24 : (((level) == ssl_encryption_handshake) ? &((qc)->send_ctx[1]) \ |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
25 : &((qc)->send_ctx[2])) |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
26 |
8290
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
27 #define ngx_quic_lost_threshold(qc) \ |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
28 ngx_max(NGX_QUIC_TIME_THR * ngx_max((qc)->latest_rtt, (qc)->avg_rtt), \ |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
29 NGX_QUIC_TIME_GRANULARITY) |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
30 |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
31 #define NGX_QUIC_SEND_CTX_LAST (NGX_QUIC_ENCRYPTION_LAST - 1) |
7773
dc7ac778aafe
Introduced packet namespace in QUIC connection.
Vladimir Homutov <vl@nginx.com>
parents:
7772
diff
changeset
|
32 |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
33 /* |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
34 * 7.4. Cryptographic Message Buffering |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
35 * Implementations MUST support buffering at least 4096 bytes of data |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
36 */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
37 #define NGX_QUIC_MAX_BUFFERED 65535 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
38 |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
39 #define NGX_QUIC_STREAM_GONE (void *) -1 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
40 |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
41 #define NGX_QUIC_UNSET_PN (uint64_t) -1 |
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
42 |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
43 /* |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
44 * Endpoints MUST discard packets that are too small to be valid QUIC |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
45 * packets. With the set of AEAD functions defined in [QUIC-TLS], |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
46 * packets that are smaller than 21 bytes are never valid. |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
47 */ |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
48 #define NGX_QUIC_MIN_PKT_LEN 21 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
49 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
50 #define NGX_QUIC_MIN_SR_PACKET 43 /* 5 random + 16 srt + 22 padding */ |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
51 #define NGX_QUIC_MAX_SR_PACKET 1200 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
52 |
8162
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
53 #define NGX_QUIC_MAX_ACK_GAP 2 |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
54 |
7773
dc7ac778aafe
Introduced packet namespace in QUIC connection.
Vladimir Homutov <vl@nginx.com>
parents:
7772
diff
changeset
|
55 |
7691 | 56 typedef struct { |
57 ngx_rbtree_t tree; | |
58 ngx_rbtree_node_t sentinel; | |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
59 |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
60 uint64_t received; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
61 uint64_t sent; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
62 uint64_t recv_max_data; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
63 uint64_t send_max_data; |
8013
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
64 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
65 uint64_t server_max_streams_uni; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
66 uint64_t server_max_streams_bidi; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
67 uint64_t server_streams_uni; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
68 uint64_t server_streams_bidi; |
8014
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
69 |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
70 uint64_t client_max_streams_uni; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
71 uint64_t client_max_streams_bidi; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
72 uint64_t client_streams_uni; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
73 uint64_t client_streams_bidi; |
7691 | 74 } ngx_quic_streams_t; |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
75 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
76 |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
77 typedef struct { |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
78 size_t in_flight; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
79 size_t window; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
80 size_t ssthresh; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
81 ngx_msec_t recovery_start; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
82 } ngx_quic_congestion_t; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
83 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
84 |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
85 /* |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
86 * 12.3. Packet Numbers |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
87 * |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
88 * Conceptually, a packet number space is the context in which a packet |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
89 * can be processed and acknowledged. Initial packets can only be sent |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
90 * with Initial packet protection keys and acknowledged in packets which |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
91 * are also Initial packets. |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
92 */ |
7773
dc7ac778aafe
Introduced packet namespace in QUIC connection.
Vladimir Homutov <vl@nginx.com>
parents:
7772
diff
changeset
|
93 typedef struct { |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
94 enum ssl_encryption_level_t level; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
95 |
7878 | 96 uint64_t pnum; /* to be sent */ |
97 uint64_t largest_ack; /* received from peer */ | |
98 uint64_t largest_pn; /* received from peer */ | |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
99 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
100 ngx_queue_t frames; |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
101 ngx_queue_t sent; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
102 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
103 uint64_t pending_ack; /* non sent ack-eliciting */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
104 uint64_t largest_range; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
105 uint64_t first_range; |
8162
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
106 ngx_msec_t largest_received; |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
107 ngx_msec_t ack_delay_start; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
108 ngx_uint_t nranges; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
109 ngx_quic_ack_range_t ranges[NGX_QUIC_MAX_RANGES]; |
8162
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
110 ngx_uint_t send_ack; |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
111 } ngx_quic_send_ctx_t; |
7773
dc7ac778aafe
Introduced packet namespace in QUIC connection.
Vladimir Homutov <vl@nginx.com>
parents:
7772
diff
changeset
|
112 |
dc7ac778aafe
Introduced packet namespace in QUIC connection.
Vladimir Homutov <vl@nginx.com>
parents:
7772
diff
changeset
|
113 |
8208
d1cf691a82e8
Core: hide "struct ngx_quic_connection_s" and further reduce diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8204
diff
changeset
|
114 typedef struct { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
115 ngx_udp_connection_t udp; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
116 |
8194
340cd26158fb
QUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8193
diff
changeset
|
117 uint32_t version; |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
118 ngx_str_t scid; /* initial client ID */ |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
119 ngx_str_t dcid; /* server (our own) ID */ |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
120 ngx_str_t odcid; /* original server ID */ |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
121 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
122 struct sockaddr *sockaddr; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
123 socklen_t socklen; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
124 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
125 ngx_queue_t client_ids; |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
126 ngx_queue_t server_ids; |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
127 ngx_queue_t free_client_ids; |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
128 ngx_queue_t free_server_ids; |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
129 ngx_uint_t nclient_ids; |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
130 ngx_uint_t nserver_ids; |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
131 uint64_t max_retired_seqnum; |
8197
405b6e8eb523
QUIC: renamed field and function related to client ids.
Roman Arutyunyan <arut@nginx.com>
parents:
8196
diff
changeset
|
132 uint64_t client_seqnum; |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
133 uint64_t server_seqnum; |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
134 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7725
diff
changeset
|
135 ngx_uint_t client_tp_done; |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
136 ngx_quic_tp_t tp; |
7731
d45325e90221
Limit output QUIC packets with client max_packet_size.
Roman Arutyunyan <arut@nginx.com>
parents:
7729
diff
changeset
|
137 ngx_quic_tp_t ctp; |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
138 |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
139 ngx_quic_send_ctx_t send_ctx[NGX_QUIC_SEND_CTX_LAST]; |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
140 |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
141 ngx_quic_frames_stream_t crypto[NGX_QUIC_ENCRYPTION_LAST]; |
7772
058a5af7ddfc
Refactored QUIC secrets storage.
Vladimir Homutov <vl@nginx.com>
parents:
7771
diff
changeset
|
142 |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
143 ngx_quic_keys_t *keys; |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
144 |
7999
0d2b2664b41c
QUIC: added "quic" listen parameter.
Roman Arutyunyan <arut@nginx.com>
parents:
7998
diff
changeset
|
145 ngx_quic_conf_t *conf; |
0d2b2664b41c
QUIC: added "quic" listen parameter.
Roman Arutyunyan <arut@nginx.com>
parents:
7998
diff
changeset
|
146 |
7775 | 147 ngx_event_t push; |
7990 | 148 ngx_event_t pto; |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
149 ngx_event_t close; |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
150 ngx_msec_t last_cc; |
7752 | 151 |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
152 ngx_msec_t latest_rtt; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
153 ngx_msec_t avg_rtt; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
154 ngx_msec_t min_rtt; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
155 ngx_msec_t rttvar; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
156 |
8056
f9b1a4e52597
QUIC: changed c->quic->pto_count type to ngx_uint_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8055
diff
changeset
|
157 ngx_uint_t pto_count; |
7993
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
158 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
159 ngx_queue_t free_frames; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
160 ngx_chain_t *free_bufs; |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
161 ngx_buf_t *free_shadow_bufs; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
162 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
163 #ifdef NGX_QUIC_DEBUG_ALLOC |
7752 | 164 ngx_uint_t nframes; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
165 ngx_uint_t nbufs; |
7752 | 166 #endif |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
167 |
7691 | 168 ngx_quic_streams_t streams; |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
169 ngx_quic_congestion_t congestion; |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
170 off_t received; |
7747
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
171 |
7862
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
172 ngx_uint_t error; |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
173 enum ssl_encryption_level_t error_level; |
7876
ffd362e87eb2
Added more context to CONNECTION CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7875
diff
changeset
|
174 ngx_uint_t error_ftype; |
ffd362e87eb2
Added more context to CONNECTION CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7875
diff
changeset
|
175 const char *error_reason; |
7862
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
176 |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
177 unsigned error_app:1; |
7747
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
178 unsigned send_timer_set:1; |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
179 unsigned closing:1; |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
180 unsigned draining:1; |
7785
29354c6fc5f2
TLS Key Update in QUIC.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7782
diff
changeset
|
181 unsigned key_phase:1; |
7995
031918df51c0
QUIC: added anti-amplification limit.
Vladimir Homutov <vl@nginx.com>
parents:
7994
diff
changeset
|
182 unsigned validated:1; |
8208
d1cf691a82e8
Core: hide "struct ngx_quic_connection_s" and further reduce diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8204
diff
changeset
|
183 } ngx_quic_connection_t; |
7672
8d6ac639feac
Added support of multiple QUIC packets in single datagram.
Vladimir Homutov <vl@nginx.com>
parents:
7671
diff
changeset
|
184 |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
185 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
186 typedef struct { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
187 ngx_queue_t queue; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
188 uint64_t seqnum; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
189 size_t len; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
190 u_char id[NGX_QUIC_CID_LEN_MAX]; |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
191 u_char sr_token[NGX_QUIC_SR_TOKEN_LEN]; |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
192 } ngx_quic_client_id_t; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
193 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
194 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
195 typedef struct { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
196 ngx_udp_connection_t udp; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
197 ngx_queue_t queue; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
198 uint64_t seqnum; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
199 size_t len; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
200 u_char id[NGX_QUIC_CID_LEN_MAX]; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
201 } ngx_quic_server_id_t; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
202 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
203 |
7812
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
204 typedef ngx_int_t (*ngx_quic_frame_handler_pt)(ngx_connection_t *c, |
7855
81a4f98a2556
Cleaned up reordering code.
Vladimir Homutov <vl@nginx.com>
parents:
7854
diff
changeset
|
205 ngx_quic_frame_t *frame, void *data); |
7812
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
206 |
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
207 |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
208 #if BORINGSSL_API_VERSION >= 10 |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
209 static int ngx_quic_set_read_secret(ngx_ssl_conn_t *ssl_conn, |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
210 enum ssl_encryption_level_t level, const SSL_CIPHER *cipher, |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
211 const uint8_t *secret, size_t secret_len); |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
212 static int ngx_quic_set_write_secret(ngx_ssl_conn_t *ssl_conn, |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
213 enum ssl_encryption_level_t level, const SSL_CIPHER *cipher, |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
214 const uint8_t *secret, size_t secret_len); |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
215 #else |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
216 static int ngx_quic_set_encryption_secrets(ngx_ssl_conn_t *ssl_conn, |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
217 enum ssl_encryption_level_t level, const uint8_t *read_secret, |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
218 const uint8_t *write_secret, size_t secret_len); |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
219 #endif |
7691 | 220 |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
221 static int ngx_quic_add_handshake_data(ngx_ssl_conn_t *ssl_conn, |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
222 enum ssl_encryption_level_t level, const uint8_t *data, size_t len); |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
223 static int ngx_quic_flush_flight(ngx_ssl_conn_t *ssl_conn); |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
224 static int ngx_quic_send_alert(ngx_ssl_conn_t *ssl_conn, |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
225 enum ssl_encryption_level_t level, uint8_t alert); |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
226 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
227 |
8294
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
228 static ngx_int_t ngx_quic_apply_transport_params(ngx_connection_t *c, |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
229 ngx_quic_tp_t *ctp); |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
230 static ngx_quic_connection_t *ngx_quic_new_connection(ngx_connection_t *c, |
8101
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
231 ngx_quic_conf_t *conf, ngx_quic_header_t *pkt); |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
232 static ngx_int_t ngx_quic_send_stateless_reset(ngx_connection_t *c, |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
233 ngx_quic_conf_t *conf, ngx_quic_header_t *pkt); |
8287
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
234 static ngx_int_t ngx_quic_new_sr_token(ngx_connection_t *c, ngx_str_t *cid, |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
235 u_char *secret, u_char *token); |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
236 static ngx_int_t ngx_quic_process_stateless_reset(ngx_connection_t *c, |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
237 ngx_quic_header_t *pkt); |
8060
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
238 static ngx_int_t ngx_quic_negotiate_version(ngx_connection_t *c, |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
239 ngx_quic_header_t *inpkt); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
240 static ngx_int_t ngx_quic_create_server_id(ngx_connection_t *c, u_char *id); |
8269
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
241 #if (NGX_QUIC_BPF) |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
242 static ngx_int_t ngx_quic_bpf_attach_id(ngx_connection_t *c, u_char *id); |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
243 #endif |
8279 | 244 static ngx_int_t ngx_quic_send_retry(ngx_connection_t *c, |
245 ngx_quic_conf_t *conf, ngx_quic_header_t *pkt); | |
246 static ngx_int_t ngx_quic_new_token(ngx_connection_t *c, u_char *key, | |
247 ngx_str_t *token, ngx_str_t *odcid, time_t expires, ngx_uint_t is_retry); | |
248 static void ngx_quic_address_hash(ngx_connection_t *c, ngx_uint_t no_port, | |
249 u_char buf[20]); | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
250 static ngx_int_t ngx_quic_validate_token(ngx_connection_t *c, |
8279 | 251 u_char *key, ngx_quic_header_t *pkt); |
7691 | 252 static ngx_int_t ngx_quic_init_connection(ngx_connection_t *c); |
7931
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
253 static ngx_inline size_t ngx_quic_max_udp_payload(ngx_connection_t *c); |
7729
1295b293d09a
Connection states code cleanup.
Vladimir Homutov <vl@nginx.com>
parents:
7726
diff
changeset
|
254 static void ngx_quic_input_handler(ngx_event_t *rev); |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
255 |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
256 static void ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc); |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
257 static ngx_int_t ngx_quic_close_quic(ngx_connection_t *c, ngx_int_t rc); |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
258 static void ngx_quic_close_timer_handler(ngx_event_t *ev); |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
259 static ngx_int_t ngx_quic_close_streams(ngx_connection_t *c, |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
260 ngx_quic_connection_t *qc); |
7691 | 261 |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
262 static ngx_int_t ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b, |
8101
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
263 ngx_quic_conf_t *conf); |
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
264 static ngx_int_t ngx_quic_process_packet(ngx_connection_t *c, |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
265 ngx_quic_conf_t *conf, ngx_quic_header_t *pkt); |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
266 static ngx_int_t ngx_quic_process_payload(ngx_connection_t *c, |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
267 ngx_quic_header_t *pkt); |
8279 | 268 static ngx_int_t ngx_quic_send_early_cc(ngx_connection_t *c, |
269 ngx_quic_header_t *inpkt, ngx_uint_t err, const char *reason); | |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
270 static void ngx_quic_discard_ctx(ngx_connection_t *c, |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
271 enum ssl_encryption_level_t level); |
8281
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
272 static ngx_int_t ngx_quic_check_csid(ngx_quic_connection_t *qc, |
7838 | 273 ngx_quic_header_t *pkt); |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
274 static ngx_int_t ngx_quic_handle_frames(ngx_connection_t *c, |
7691 | 275 ngx_quic_header_t *pkt); |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
276 static ngx_int_t ngx_quic_ack_packet(ngx_connection_t *c, |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
277 ngx_quic_header_t *pkt); |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
278 static ngx_int_t ngx_quic_send_ack_range(ngx_connection_t *c, |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
279 ngx_quic_send_ctx_t *ctx, uint64_t smallest, uint64_t largest); |
8156
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
280 static void ngx_quic_drop_ack_ranges(ngx_connection_t *c, |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
281 ngx_quic_send_ctx_t *ctx, uint64_t pn); |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
282 static ngx_int_t ngx_quic_send_ack(ngx_connection_t *c, |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
283 ngx_quic_send_ctx_t *ctx); |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
284 static ngx_int_t ngx_quic_send_cc(ngx_connection_t *c); |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
285 static ngx_int_t ngx_quic_send_new_token(ngx_connection_t *c); |
7691 | 286 |
287 static ngx_int_t ngx_quic_handle_ack_frame(ngx_connection_t *c, | |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
288 ngx_quic_header_t *pkt, ngx_quic_frame_t *f); |
7792 | 289 static ngx_int_t ngx_quic_handle_ack_frame_range(ngx_connection_t *c, |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
290 ngx_quic_send_ctx_t *ctx, uint64_t min, uint64_t max, |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
291 ngx_msec_t *send_time); |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
292 static void ngx_quic_rtt_sample(ngx_connection_t *c, ngx_quic_ack_frame_t *ack, |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
293 enum ssl_encryption_level_t level, ngx_msec_t send_time); |
7993
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
294 static ngx_inline ngx_msec_t ngx_quic_pto(ngx_connection_t *c, |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
295 ngx_quic_send_ctx_t *ctx); |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
296 static void ngx_quic_handle_stream_ack(ngx_connection_t *c, |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
297 ngx_quic_frame_t *f); |
7812
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
298 |
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
299 static ngx_int_t ngx_quic_handle_ordered_frame(ngx_connection_t *c, |
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
300 ngx_quic_frames_stream_t *fs, ngx_quic_frame_t *frame, |
7855
81a4f98a2556
Cleaned up reordering code.
Vladimir Homutov <vl@nginx.com>
parents:
7854
diff
changeset
|
301 ngx_quic_frame_handler_pt handler, void *data); |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
302 static ngx_int_t ngx_quic_adjust_frame_offset(ngx_connection_t *c, |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
303 ngx_quic_frame_t *f, uint64_t offset_in); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
304 static ngx_int_t ngx_quic_buffer_frame(ngx_connection_t *c, |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
305 ngx_quic_frames_stream_t *stream, ngx_quic_frame_t *f); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
306 |
7812
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
307 static ngx_int_t ngx_quic_handle_crypto_frame(ngx_connection_t *c, |
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
308 ngx_quic_header_t *pkt, ngx_quic_frame_t *frame); |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
309 static ngx_int_t ngx_quic_crypto_input(ngx_connection_t *c, |
7855
81a4f98a2556
Cleaned up reordering code.
Vladimir Homutov <vl@nginx.com>
parents:
7854
diff
changeset
|
310 ngx_quic_frame_t *frame, void *data); |
7691 | 311 static ngx_int_t ngx_quic_handle_stream_frame(ngx_connection_t *c, |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
312 ngx_quic_header_t *pkt, ngx_quic_frame_t *frame); |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
313 static ngx_int_t ngx_quic_stream_input(ngx_connection_t *c, |
7855
81a4f98a2556
Cleaned up reordering code.
Vladimir Homutov <vl@nginx.com>
parents:
7854
diff
changeset
|
314 ngx_quic_frame_t *frame, void *data); |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
315 |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
316 static ngx_int_t ngx_quic_handle_max_data_frame(ngx_connection_t *c, |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
317 ngx_quic_max_data_frame_t *f); |
7711
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
318 static ngx_int_t ngx_quic_handle_streams_blocked_frame(ngx_connection_t *c, |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
319 ngx_quic_header_t *pkt, ngx_quic_streams_blocked_frame_t *f); |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
320 static ngx_int_t ngx_quic_handle_stream_data_blocked_frame(ngx_connection_t *c, |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
321 ngx_quic_header_t *pkt, ngx_quic_stream_data_blocked_frame_t *f); |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
322 static ngx_int_t ngx_quic_handle_max_stream_data_frame(ngx_connection_t *c, |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
323 ngx_quic_header_t *pkt, ngx_quic_max_stream_data_frame_t *f); |
7923
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
324 static ngx_int_t ngx_quic_handle_reset_stream_frame(ngx_connection_t *c, |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
325 ngx_quic_header_t *pkt, ngx_quic_reset_stream_frame_t *f); |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
326 static ngx_int_t ngx_quic_handle_stop_sending_frame(ngx_connection_t *c, |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
327 ngx_quic_header_t *pkt, ngx_quic_stop_sending_frame_t *f); |
8013
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
328 static ngx_int_t ngx_quic_handle_max_streams_frame(ngx_connection_t *c, |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
329 ngx_quic_header_t *pkt, ngx_quic_max_streams_frame_t *f); |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
330 static ngx_int_t ngx_quic_handle_path_challenge_frame(ngx_connection_t *c, |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
331 ngx_quic_header_t *pkt, ngx_quic_path_challenge_frame_t *f); |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
332 static ngx_int_t ngx_quic_handle_new_connection_id_frame(ngx_connection_t *c, |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
333 ngx_quic_header_t *pkt, ngx_quic_new_conn_id_frame_t *f); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
334 static ngx_int_t ngx_quic_retire_connection_id(ngx_connection_t *c, |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
335 enum ssl_encryption_level_t level, uint64_t seqnum); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
336 static ngx_int_t ngx_quic_handle_retire_connection_id_frame(ngx_connection_t *c, |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
337 ngx_quic_header_t *pkt, ngx_quic_retire_cid_frame_t *f); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
338 static ngx_int_t ngx_quic_issue_server_ids(ngx_connection_t *c); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
339 static void ngx_quic_clear_temp_server_ids(ngx_connection_t *c); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
340 static ngx_quic_server_id_t *ngx_quic_insert_server_id(ngx_connection_t *c, |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
341 ngx_str_t *id); |
8197
405b6e8eb523
QUIC: renamed field and function related to client ids.
Roman Arutyunyan <arut@nginx.com>
parents:
8196
diff
changeset
|
342 static ngx_quic_client_id_t *ngx_quic_alloc_client_id(ngx_connection_t *c, |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
343 ngx_quic_connection_t *qc); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
344 static ngx_quic_server_id_t *ngx_quic_alloc_server_id(ngx_connection_t *c, |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
345 ngx_quic_connection_t *qc); |
7691 | 346 |
347 static void ngx_quic_queue_frame(ngx_quic_connection_t *qc, | |
348 ngx_quic_frame_t *frame); | |
349 | |
350 static ngx_int_t ngx_quic_output(ngx_connection_t *c); | |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
351 static ngx_uint_t ngx_quic_get_padding_level(ngx_connection_t *c); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
352 static ngx_int_t ngx_quic_generate_ack(ngx_connection_t *c, |
7809
6ad871b63422
Cleaned up magic numbers in ngx_quic_output_frames().
Vladimir Homutov <vl@nginx.com>
parents:
7808
diff
changeset
|
353 ngx_quic_send_ctx_t *ctx); |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
354 static ssize_t ngx_quic_output_packet(ngx_connection_t *c, |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
355 ngx_quic_send_ctx_t *ctx, u_char *data, size_t max, size_t min); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
356 static ngx_int_t ngx_quic_split_frame(ngx_connection_t *c, ngx_quic_frame_t *f, |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
357 size_t len); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
358 static void ngx_quic_free_frames(ngx_connection_t *c, ngx_queue_t *frames); |
8240
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
359 static ssize_t ngx_quic_send(ngx_connection_t *c, u_char *buf, size_t len); |
7781
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
360 |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
361 static void ngx_quic_set_packet_number(ngx_quic_header_t *pkt, |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
362 ngx_quic_send_ctx_t *ctx); |
7990 | 363 static void ngx_quic_pto_handler(ngx_event_t *ev); |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
364 static void ngx_quic_lost_handler(ngx_event_t *ev); |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
365 static ngx_int_t ngx_quic_detect_lost(ngx_connection_t *c); |
8290
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
366 static void ngx_quic_set_lost_timer(ngx_connection_t *c); |
8094
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
367 static void ngx_quic_resend_frames(ngx_connection_t *c, |
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
368 ngx_quic_send_ctx_t *ctx); |
7775 | 369 static void ngx_quic_push_handler(ngx_event_t *ev); |
7691 | 370 |
371 static void ngx_quic_rbtree_insert_stream(ngx_rbtree_node_t *temp, | |
372 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel); | |
7746
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
373 static ngx_quic_stream_t *ngx_quic_find_stream(ngx_rbtree_t *rbtree, |
7750
2935a11c55b6
Fixed QUIC stream insert and find.
Roman Arutyunyan <arut@nginx.com>
parents:
7748
diff
changeset
|
374 uint64_t id); |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
375 static ngx_quic_stream_t *ngx_quic_create_client_stream(ngx_connection_t *c, |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
376 uint64_t id); |
7746
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
377 static ngx_quic_stream_t *ngx_quic_create_stream(ngx_connection_t *c, |
7748
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
378 uint64_t id, size_t rcvbuf_size); |
7677
6bc18966b8c1
Stream "connection" read/write methods.
Vladimir Homutov <vl@nginx.com>
parents:
7675
diff
changeset
|
379 static ssize_t ngx_quic_stream_recv(ngx_connection_t *c, u_char *buf, |
6bc18966b8c1
Stream "connection" read/write methods.
Vladimir Homutov <vl@nginx.com>
parents:
7675
diff
changeset
|
380 size_t size); |
6bc18966b8c1
Stream "connection" read/write methods.
Vladimir Homutov <vl@nginx.com>
parents:
7675
diff
changeset
|
381 static ssize_t ngx_quic_stream_send(ngx_connection_t *c, u_char *buf, |
6bc18966b8c1
Stream "connection" read/write methods.
Vladimir Homutov <vl@nginx.com>
parents:
7675
diff
changeset
|
382 size_t size); |
6bc18966b8c1
Stream "connection" read/write methods.
Vladimir Homutov <vl@nginx.com>
parents:
7675
diff
changeset
|
383 static ngx_chain_t *ngx_quic_stream_send_chain(ngx_connection_t *c, |
6bc18966b8c1
Stream "connection" read/write methods.
Vladimir Homutov <vl@nginx.com>
parents:
7675
diff
changeset
|
384 ngx_chain_t *in, off_t limit); |
8027
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
385 static size_t ngx_quic_max_stream_flow(ngx_connection_t *c); |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
386 static void ngx_quic_stream_cleanup_handler(void *data); |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
387 static ngx_quic_frame_t *ngx_quic_alloc_frame(ngx_connection_t *c); |
7752 | 388 static void ngx_quic_free_frame(ngx_connection_t *c, ngx_quic_frame_t *frame); |
7677
6bc18966b8c1
Stream "connection" read/write methods.
Vladimir Homutov <vl@nginx.com>
parents:
7675
diff
changeset
|
389 |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
390 static void ngx_quic_congestion_ack(ngx_connection_t *c, |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
391 ngx_quic_frame_t *frame); |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
392 static void ngx_quic_congestion_lost(ngx_connection_t *c, |
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
393 ngx_quic_frame_t *frame); |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
394 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
395 static ngx_chain_t *ngx_quic_alloc_buf(ngx_connection_t *c); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
396 static void ngx_quic_free_bufs(ngx_connection_t *c, ngx_chain_t *in); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
397 static ngx_chain_t *ngx_quic_copy_buf(ngx_connection_t *c, u_char *data, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
398 size_t len); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
399 static ngx_chain_t *ngx_quic_copy_chain(ngx_connection_t *c, ngx_chain_t *in, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
400 size_t limit); |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
401 static ngx_chain_t *ngx_quic_split_bufs(ngx_connection_t *c, ngx_chain_t *in, |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
402 size_t len); |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
403 |
7691 | 404 |
8267 | 405 static ngx_core_module_t ngx_quic_module_ctx = { |
406 ngx_string("quic"), | |
407 NULL, | |
408 NULL | |
409 }; | |
410 | |
411 | |
412 ngx_module_t ngx_quic_module = { | |
413 NGX_MODULE_V1, | |
414 &ngx_quic_module_ctx, /* module context */ | |
415 NULL, /* module directives */ | |
416 NGX_CORE_MODULE, /* module type */ | |
417 NULL, /* init master */ | |
418 NULL, /* init module */ | |
419 NULL, /* init process */ | |
420 NULL, /* init thread */ | |
421 NULL, /* exit thread */ | |
422 NULL, /* exit process */ | |
423 NULL, /* exit master */ | |
424 NGX_MODULE_V1_PADDING | |
425 }; | |
426 | |
427 | |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
428 static SSL_QUIC_METHOD quic_method = { |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
429 #if BORINGSSL_API_VERSION >= 10 |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
430 ngx_quic_set_read_secret, |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
431 ngx_quic_set_write_secret, |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
432 #else |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
433 ngx_quic_set_encryption_secrets, |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
434 #endif |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
435 ngx_quic_add_handshake_data, |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
436 ngx_quic_flush_flight, |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
437 ngx_quic_send_alert, |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
438 }; |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
439 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
440 |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
441 #if (NGX_DEBUG) |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
442 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
443 static void |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
444 ngx_quic_log_frame(ngx_log_t *log, ngx_quic_frame_t *f, ngx_uint_t tx) |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
445 { |
8172
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
446 u_char *p, *last, *pos, *end; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
447 ssize_t n; |
8173
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
448 uint64_t gap, range, largest, smallest; |
8172
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
449 ngx_uint_t i; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
450 u_char buf[NGX_MAX_ERROR_STR]; |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
451 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
452 p = buf; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
453 last = buf + sizeof(buf); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
454 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
455 switch (f->type) { |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
456 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
457 case NGX_QUIC_FT_CRYPTO: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
458 p = ngx_slprintf(p, last, "CRYPTO len:%uL off:%uL", |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
459 f->u.crypto.length, f->u.crypto.offset); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
460 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
461 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
462 case NGX_QUIC_FT_PADDING: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
463 p = ngx_slprintf(p, last, "PADDING"); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
464 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
465 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
466 case NGX_QUIC_FT_ACK: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
467 case NGX_QUIC_FT_ACK_ECN: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
468 |
8173
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
469 p = ngx_slprintf(p, last, "ACK n:%ui delay:%uL ", |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
470 f->u.ack.range_count, f->u.ack.delay); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
471 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
472 if (f->data) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
473 pos = f->data->buf->pos; |
8288
0b3d70fbba99
QUIC: fixed logging ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8287
diff
changeset
|
474 end = f->data->buf->last; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
475 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
476 } else { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
477 pos = NULL; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
478 end = NULL; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
479 } |
8172
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
480 |
8173
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
481 largest = f->u.ack.largest; |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
482 smallest = f->u.ack.largest - f->u.ack.first_range; |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
483 |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
484 if (largest == smallest) { |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
485 p = ngx_slprintf(p, last, "%uL", largest); |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
486 |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
487 } else { |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
488 p = ngx_slprintf(p, last, "%uL-%uL", largest, smallest); |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
489 } |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
490 |
8172
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
491 for (i = 0; i < f->u.ack.range_count; i++) { |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
492 n = ngx_quic_parse_ack_range(log, pos, end, &gap, &range); |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
493 if (n == NGX_ERROR) { |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
494 break; |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
495 } |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
496 |
8172
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
497 pos += n; |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
498 |
8173
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
499 largest = smallest - gap - 2; |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
500 smallest = largest - range; |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
501 |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
502 if (largest == smallest) { |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
503 p = ngx_slprintf(p, last, " %uL", largest); |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
504 |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
505 } else { |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
506 p = ngx_slprintf(p, last, " %uL-%uL", largest, smallest); |
3d79c08bb0f1
QUIC: changed ACK frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8172
diff
changeset
|
507 } |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
508 } |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
509 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
510 if (f->type == NGX_QUIC_FT_ACK_ECN) { |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
511 p = ngx_slprintf(p, last, " ECN counters ect0:%uL ect1:%uL ce:%uL", |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
512 f->u.ack.ect0, f->u.ack.ect1, f->u.ack.ce); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
513 } |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
514 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
515 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
516 case NGX_QUIC_FT_PING: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
517 p = ngx_slprintf(p, last, "PING"); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
518 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
519 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
520 case NGX_QUIC_FT_NEW_CONNECTION_ID: |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
521 p = ngx_slprintf(p, last, |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
522 "NEW_CONNECTION_ID seq:%uL retire:%uL len:%ud", |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
523 f->u.ncid.seqnum, f->u.ncid.retire, f->u.ncid.len); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
524 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
525 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
526 case NGX_QUIC_FT_RETIRE_CONNECTION_ID: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
527 p = ngx_slprintf(p, last, "RETIRE_CONNECTION_ID seqnum:%uL", |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
528 f->u.retire_cid.sequence_number); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
529 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
530 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
531 case NGX_QUIC_FT_CONNECTION_CLOSE: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
532 case NGX_QUIC_FT_CONNECTION_CLOSE_APP: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
533 p = ngx_slprintf(p, last, "CONNECTION_CLOSE%s err:%ui", |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8281
diff
changeset
|
534 f->type == NGX_QUIC_FT_CONNECTION_CLOSE ? "" : "_APP", |
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8281
diff
changeset
|
535 f->u.close.error_code); |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
536 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
537 if (f->u.close.reason.len) { |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
538 p = ngx_slprintf(p, last, " %V", &f->u.close.reason); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
539 } |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
540 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
541 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) { |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
542 p = ngx_slprintf(p, last, " ft:%ui", f->u.close.frame_type); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
543 } |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
544 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
545 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
546 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
547 case NGX_QUIC_FT_STREAM0: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
548 case NGX_QUIC_FT_STREAM1: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
549 case NGX_QUIC_FT_STREAM2: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
550 case NGX_QUIC_FT_STREAM3: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
551 case NGX_QUIC_FT_STREAM4: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
552 case NGX_QUIC_FT_STREAM5: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
553 case NGX_QUIC_FT_STREAM6: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
554 case NGX_QUIC_FT_STREAM7: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
555 |
8174
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
556 p = ngx_slprintf(p, last, "STREAM id:0x%xL", f->u.stream.stream_id); |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
557 |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
558 if (f->u.stream.off) { |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
559 p = ngx_slprintf(p, last, " off:%uL", f->u.stream.offset); |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
560 } |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
561 |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
562 if (f->u.stream.len) { |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
563 p = ngx_slprintf(p, last, " len:%uL", f->u.stream.length); |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
564 } |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
565 |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
566 if (f->u.stream.fin) { |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
567 p = ngx_slprintf(p, last, " fin:1"); |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
568 } |
27e305834078
QUIC: changed STREAM frame debugging.
Roman Arutyunyan <arut@nginx.com>
parents:
8173
diff
changeset
|
569 |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
570 #ifdef NGX_QUIC_DEBUG_FRAMES |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
571 { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
572 ngx_chain_t *cl; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
573 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
574 p = ngx_slprintf(p, last, " data:"); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
575 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
576 for (cl = f->data; cl; cl = cl->next) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
577 p = ngx_slprintf(p, last, "%*xs", |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
578 cl->buf->last - cl->buf->pos, cl->buf->pos); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
579 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
580 } |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
581 #endif |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
582 |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
583 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
584 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
585 case NGX_QUIC_FT_MAX_DATA: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
586 p = ngx_slprintf(p, last, "MAX_DATA max_data:%uL on recv", |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
587 f->u.max_data.max_data); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
588 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
589 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
590 case NGX_QUIC_FT_RESET_STREAM: |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
591 p = ngx_slprintf(p, last, "RESET_STREAM" |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
592 " id:0x%xL error_code:0x%xL final_size:0x%xL", |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
593 f->u.reset_stream.id, f->u.reset_stream.error_code, |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
594 f->u.reset_stream.final_size); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
595 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
596 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
597 case NGX_QUIC_FT_STOP_SENDING: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
598 p = ngx_slprintf(p, last, "STOP_SENDING id:0x%xL err:0x%xL", |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
599 f->u.stop_sending.id, f->u.stop_sending.error_code); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
600 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
601 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
602 case NGX_QUIC_FT_STREAMS_BLOCKED: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
603 case NGX_QUIC_FT_STREAMS_BLOCKED2: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
604 p = ngx_slprintf(p, last, "STREAMS_BLOCKED limit:%uL bidi:%ui", |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
605 f->u.streams_blocked.limit, f->u.streams_blocked.bidi); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
606 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
607 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
608 case NGX_QUIC_FT_MAX_STREAMS: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
609 case NGX_QUIC_FT_MAX_STREAMS2: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
610 p = ngx_slprintf(p, last, "MAX_STREAMS limit:%uL bidi:%ui", |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
611 f->u.max_streams.limit, f->u.max_streams.bidi); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
612 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
613 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
614 case NGX_QUIC_FT_MAX_STREAM_DATA: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
615 p = ngx_slprintf(p, last, "MAX_STREAM_DATA id:0x%xL limit:%uL", |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
616 f->u.max_stream_data.id, f->u.max_stream_data.limit); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
617 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
618 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
619 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
620 case NGX_QUIC_FT_DATA_BLOCKED: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
621 p = ngx_slprintf(p, last, "DATA_BLOCKED limit:%uL", |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
622 f->u.data_blocked.limit); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
623 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
624 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
625 case NGX_QUIC_FT_STREAM_DATA_BLOCKED: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
626 p = ngx_slprintf(p, last, "STREAM_DATA_BLOCKED id:0x%xL limit:%uL", |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
627 f->u.stream_data_blocked.id, |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
628 f->u.stream_data_blocked.limit); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
629 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
630 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
631 case NGX_QUIC_FT_PATH_CHALLENGE: |
8263
b14338acbf9d
QUIC: fixed logging PATH_CHALLENGE/RESPONSE and build with GCC < 5.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8247
diff
changeset
|
632 p = ngx_slprintf(p, last, "PATH_CHALLENGE data:0x%*xs", |
b14338acbf9d
QUIC: fixed logging PATH_CHALLENGE/RESPONSE and build with GCC < 5.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8247
diff
changeset
|
633 sizeof(f->u.path_challenge.data), |
b14338acbf9d
QUIC: fixed logging PATH_CHALLENGE/RESPONSE and build with GCC < 5.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8247
diff
changeset
|
634 f->u.path_challenge.data); |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
635 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
636 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
637 case NGX_QUIC_FT_PATH_RESPONSE: |
8263
b14338acbf9d
QUIC: fixed logging PATH_CHALLENGE/RESPONSE and build with GCC < 5.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8247
diff
changeset
|
638 p = ngx_slprintf(p, last, "PATH_RESPONSE data:0x%*xs", |
b14338acbf9d
QUIC: fixed logging PATH_CHALLENGE/RESPONSE and build with GCC < 5.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8247
diff
changeset
|
639 sizeof(f->u.path_challenge.data), |
b14338acbf9d
QUIC: fixed logging PATH_CHALLENGE/RESPONSE and build with GCC < 5.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8247
diff
changeset
|
640 f->u.path_challenge.data); |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
641 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
642 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
643 case NGX_QUIC_FT_NEW_TOKEN: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
644 p = ngx_slprintf(p, last, "NEW_TOKEN"); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
645 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
646 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
647 case NGX_QUIC_FT_HANDSHAKE_DONE: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
648 p = ngx_slprintf(p, last, "HANDSHAKE DONE"); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
649 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
650 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
651 default: |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
652 p = ngx_slprintf(p, last, "unknown type 0x%xi", f->type); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
653 break; |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
654 } |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
655 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
656 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, log, 0, "quic frame %s %s %*s", |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
657 tx ? "tx" : "rx", ngx_quic_level_name(f->level), |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
658 p - buf, buf); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
659 } |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
660 |
8166
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
661 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
662 static void |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
663 ngx_quic_connstate_dbg(ngx_connection_t *c) |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
664 { |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
665 u_char *p, *last; |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
666 ngx_quic_connection_t *qc; |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
667 u_char buf[NGX_MAX_ERROR_STR]; |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
668 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
669 p = buf; |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
670 last = p + sizeof(buf); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
671 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
672 qc = ngx_quic_get_connection(c); |
8166
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
673 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
674 p = ngx_slprintf(p, last, "state:"); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
675 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
676 if (qc) { |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
677 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
678 if (qc->error) { |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
679 p = ngx_slprintf(p, last, "%s", qc->error_app ? " app" : ""); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
680 p = ngx_slprintf(p, last, " error:%ui", qc->error); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
681 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
682 if (qc->error_reason) { |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
683 p = ngx_slprintf(p, last, " \"%s\"", qc->error_reason); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
684 } |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
685 } |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
686 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
687 p = ngx_slprintf(p, last, "%s", qc->closing ? " closing" : ""); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
688 p = ngx_slprintf(p, last, "%s", qc->draining ? " draining" : ""); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
689 p = ngx_slprintf(p, last, "%s", qc->key_phase ? " kp" : ""); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
690 p = ngx_slprintf(p, last, "%s", qc->validated? " valid" : ""); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
691 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
692 } else { |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
693 p = ngx_slprintf(p, last, " early"); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
694 } |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
695 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
696 if (c->read->timer_set) { |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
697 p = ngx_slprintf(p, last, |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
698 qc && qc->send_timer_set ? " send:%M" : " read:%M", |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
699 c->read->timer.key - ngx_current_msec); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
700 } |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
701 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
702 if (qc) { |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
703 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
704 if (qc->push.timer_set) { |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
705 p = ngx_slprintf(p, last, " push:%M", |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
706 qc->push.timer.key - ngx_current_msec); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
707 } |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
708 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
709 if (qc->pto.timer_set) { |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
710 p = ngx_slprintf(p, last, " pto:%M", |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
711 qc->pto.timer.key - ngx_current_msec); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
712 } |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
713 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
714 if (qc->close.timer_set) { |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
715 p = ngx_slprintf(p, last, " close:%M", |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
716 qc->close.timer.key - ngx_current_msec); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
717 } |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
718 } |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
719 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
720 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
721 "quic %*s", p - buf, buf); |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
722 } |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
723 |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
724 #else |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
725 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
726 #define ngx_quic_log_frame(log, f, tx) |
8166
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
727 #define ngx_quic_connstate_dbg(c) |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
728 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
729 #endif |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
730 |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
731 |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
732 #if BORINGSSL_API_VERSION >= 10 |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
733 |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
734 static int |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
735 ngx_quic_set_read_secret(ngx_ssl_conn_t *ssl_conn, |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
736 enum ssl_encryption_level_t level, const SSL_CIPHER *cipher, |
7687
69345a26ba69
Split transport and crypto parts into separate files.
Vladimir Homutov <vl@nginx.com>
parents:
7686
diff
changeset
|
737 const uint8_t *rsecret, size_t secret_len) |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
738 { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
739 ngx_connection_t *c; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
740 ngx_quic_connection_t *qc; |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
741 |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
742 c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn); |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
743 qc = ngx_quic_get_connection(c); |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
744 |
7837
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
7836
diff
changeset
|
745 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
7836
diff
changeset
|
746 "quic ngx_quic_set_read_secret() level:%d", level); |
8137
52ad697f9d1c
QUIC: enabled more key-related debug by default.
Vladimir Homutov <vl@nginx.com>
parents:
8136
diff
changeset
|
747 #ifdef NGX_QUIC_DEBUG_CRYPTO |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
748 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
749 "quic read secret len:%uz %*xs", secret_len, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
750 secret_len, rsecret); |
7836 | 751 #endif |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
752 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
753 return ngx_quic_keys_set_encryption_secret(c->pool, 0, qc->keys, level, |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
754 cipher, rsecret, secret_len); |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
755 } |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
756 |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
757 |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
758 static int |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
759 ngx_quic_set_write_secret(ngx_ssl_conn_t *ssl_conn, |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
760 enum ssl_encryption_level_t level, const SSL_CIPHER *cipher, |
7687
69345a26ba69
Split transport and crypto parts into separate files.
Vladimir Homutov <vl@nginx.com>
parents:
7686
diff
changeset
|
761 const uint8_t *wsecret, size_t secret_len) |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
762 { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
763 ngx_connection_t *c; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
764 ngx_quic_connection_t *qc; |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
765 |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
766 c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn); |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
767 qc = ngx_quic_get_connection(c); |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
768 |
7837
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
7836
diff
changeset
|
769 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
7836
diff
changeset
|
770 "quic ngx_quic_set_write_secret() level:%d", level); |
8137
52ad697f9d1c
QUIC: enabled more key-related debug by default.
Vladimir Homutov <vl@nginx.com>
parents:
8136
diff
changeset
|
771 #ifdef NGX_QUIC_DEBUG_CRYPTO |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
772 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
773 "quic write secret len:%uz %*xs", secret_len, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
774 secret_len, wsecret); |
7836 | 775 #endif |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
776 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
777 return ngx_quic_keys_set_encryption_secret(c->pool, 1, qc->keys, level, |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
778 cipher, wsecret, secret_len); |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
779 } |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
780 |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
781 #else |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
782 |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
783 static int |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
784 ngx_quic_set_encryption_secrets(ngx_ssl_conn_t *ssl_conn, |
7687
69345a26ba69
Split transport and crypto parts into separate files.
Vladimir Homutov <vl@nginx.com>
parents:
7686
diff
changeset
|
785 enum ssl_encryption_level_t level, const uint8_t *rsecret, |
69345a26ba69
Split transport and crypto parts into separate files.
Vladimir Homutov <vl@nginx.com>
parents:
7686
diff
changeset
|
786 const uint8_t *wsecret, size_t secret_len) |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
787 { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
788 ngx_connection_t *c; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
789 const SSL_CIPHER *cipher; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
790 ngx_quic_connection_t *qc; |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
791 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
792 c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn); |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
793 qc = ngx_quic_get_connection(c); |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
794 |
7837
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
7836
diff
changeset
|
795 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
7836
diff
changeset
|
796 "quic ngx_quic_set_encryption_secrets() level:%d", level); |
8137
52ad697f9d1c
QUIC: enabled more key-related debug by default.
Vladimir Homutov <vl@nginx.com>
parents:
8136
diff
changeset
|
797 #ifdef NGX_QUIC_DEBUG_CRYPTO |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
798 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
799 "quic read secret len:%uz %*xs", secret_len, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
800 secret_len, rsecret); |
7836 | 801 #endif |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
802 |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
803 cipher = SSL_get_current_cipher(ssl_conn); |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
804 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
805 if (ngx_quic_keys_set_encryption_secret(c->pool, 0, qc->keys, level, |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
806 cipher, rsecret, secret_len) |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
807 != 1) |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
808 { |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
809 return 0; |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
810 } |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
811 |
7769
2ac03e80d013
TLS Early Data key derivation support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7768
diff
changeset
|
812 if (level == ssl_encryption_early_data) { |
2ac03e80d013
TLS Early Data key derivation support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7768
diff
changeset
|
813 return 1; |
2ac03e80d013
TLS Early Data key derivation support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7768
diff
changeset
|
814 } |
2ac03e80d013
TLS Early Data key derivation support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7768
diff
changeset
|
815 |
7836 | 816 #ifdef NGX_QUIC_DEBUG_CRYPTO |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
817 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
818 "quic write secret len:%uz %*xs", secret_len, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
819 secret_len, wsecret); |
7836 | 820 #endif |
7769
2ac03e80d013
TLS Early Data key derivation support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7768
diff
changeset
|
821 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
822 return ngx_quic_keys_set_encryption_secret(c->pool, 1, qc->keys, level, |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
823 cipher, wsecret, secret_len); |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
824 } |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
825 |
7670
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
826 #endif |
9e0c30e1f7fb
Compatibility with BoringSSL revised QUIC encryption secret APIs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7669
diff
changeset
|
827 |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
828 |
7650
ec1f84996990
Split frame and packet generation into separate steps.
Vladimir Homutov <vl@nginx.com>
parents:
7649
diff
changeset
|
829 static int |
ec1f84996990
Split frame and packet generation into separate steps.
Vladimir Homutov <vl@nginx.com>
parents:
7649
diff
changeset
|
830 ngx_quic_add_handshake_data(ngx_ssl_conn_t *ssl_conn, |
ec1f84996990
Split frame and packet generation into separate steps.
Vladimir Homutov <vl@nginx.com>
parents:
7649
diff
changeset
|
831 enum ssl_encryption_level_t level, const uint8_t *data, size_t len) |
ec1f84996990
Split frame and packet generation into separate steps.
Vladimir Homutov <vl@nginx.com>
parents:
7649
diff
changeset
|
832 { |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
833 u_char *p, *end; |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
834 size_t client_params_len; |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
835 const uint8_t *client_params; |
8294
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
836 ngx_quic_tp_t ctp; |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
837 ngx_quic_frame_t *frame; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
838 ngx_connection_t *c; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
839 ngx_quic_connection_t *qc; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
840 ngx_quic_frames_stream_t *fs; |
7650
ec1f84996990
Split frame and packet generation into separate steps.
Vladimir Homutov <vl@nginx.com>
parents:
7649
diff
changeset
|
841 |
ec1f84996990
Split frame and packet generation into separate steps.
Vladimir Homutov <vl@nginx.com>
parents:
7649
diff
changeset
|
842 c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn); |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
843 qc = ngx_quic_get_connection(c); |
7650
ec1f84996990
Split frame and packet generation into separate steps.
Vladimir Homutov <vl@nginx.com>
parents:
7649
diff
changeset
|
844 |
7652
0a2683df5f11
Implemented improved version of quic_output().
Vladimir Homutov <vl@nginx.com>
parents:
7651
diff
changeset
|
845 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
7836 | 846 "quic ngx_quic_add_handshake_data"); |
7650
ec1f84996990
Split frame and packet generation into separate steps.
Vladimir Homutov <vl@nginx.com>
parents:
7649
diff
changeset
|
847 |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7725
diff
changeset
|
848 if (!qc->client_tp_done) { |
7933 | 849 /* |
850 * things to do once during handshake: check ALPN and transport | |
851 * parameters; we want to break handshake if something is wrong | |
852 * here; | |
853 */ | |
854 | |
855 #if defined(TLSEXT_TYPE_application_layer_protocol_negotiation) | |
8000
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
856 if (qc->conf->require_alpn) { |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
857 unsigned int len; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
858 const unsigned char *data; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
859 |
8189
bb3f4f669417
QUIC: passing ssl_conn to SSL_get0_alpn_selected() directly.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8176
diff
changeset
|
860 SSL_get0_alpn_selected(ssl_conn, &data, &len); |
8000
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
861 |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
862 if (len == 0) { |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
863 qc->error = 0x100 + SSL_AD_NO_APPLICATION_PROTOCOL; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
864 qc->error_reason = "unsupported protocol in ALPN extension"; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
865 |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
866 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
867 "quic unsupported protocol in ALPN extension"); |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
868 return 0; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
869 } |
7933 | 870 } |
871 #endif | |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7725
diff
changeset
|
872 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7725
diff
changeset
|
873 SSL_get_peer_quic_transport_params(ssl_conn, &client_params, |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7725
diff
changeset
|
874 &client_params_len); |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7725
diff
changeset
|
875 |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7725
diff
changeset
|
876 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
7836 | 877 "quic SSL_get_peer_quic_transport_params():" |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
878 " params_len:%ui", client_params_len); |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7725
diff
changeset
|
879 |
7930
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
880 if (client_params_len == 0) { |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
881 /* quic-tls 8.2 */ |
7942
97adb87f149b
Get rid of hardcoded numbers used for quic handshake errors.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7941
diff
changeset
|
882 qc->error = NGX_QUIC_ERR_CRYPTO(SSL_AD_MISSING_EXTENSION); |
7930
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
883 qc->error_reason = "missing transport parameters"; |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
884 |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
885 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
886 "missing transport parameters"); |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
887 return 0; |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
888 } |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
889 |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
890 p = (u_char *) client_params; |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
891 end = p + client_params_len; |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
892 |
8294
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
893 /* defaults for parameters not sent by client */ |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
894 ngx_memcpy(&ctp, &qc->ctp, sizeof(ngx_quic_tp_t)); |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
895 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
896 if (ngx_quic_parse_transport_params(p, end, &ctp, c->log) |
7930
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
897 != NGX_OK) |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
898 { |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
899 qc->error = NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR; |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
900 qc->error_reason = "failed to process transport parameters"; |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
901 |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
902 return 0; |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
903 } |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
904 |
8294
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
905 if (ngx_quic_apply_transport_params(c, &ctp) != NGX_OK) { |
7930
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
906 return 0; |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
907 } |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
908 |
5bc9229ec4cf
QUIC: raise error on missing transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7929
diff
changeset
|
909 qc->client_tp_done = 1; |
7726
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7725
diff
changeset
|
910 } |
f388c0ad3477
Added processing of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7725
diff
changeset
|
911 |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
912 fs = &qc->crypto[level]; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
913 |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
914 frame = ngx_quic_alloc_frame(c); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
915 if (frame == NULL) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
916 return 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
917 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
918 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
919 frame->data = ngx_quic_copy_buf(c, (u_char *) data, len); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
920 if (frame->data == NGX_CHAIN_ERROR) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
921 return 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
922 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
923 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
924 frame->level = level; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
925 frame->type = NGX_QUIC_FT_CRYPTO; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
926 frame->u.crypto.offset = fs->sent; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
927 frame->u.crypto.length = len; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
928 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
929 fs->sent += len; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
930 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
931 ngx_quic_queue_frame(qc, frame); |
7650
ec1f84996990
Split frame and packet generation into separate steps.
Vladimir Homutov <vl@nginx.com>
parents:
7649
diff
changeset
|
932 |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
933 return 1; |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
934 } |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
935 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
936 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
937 static int |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
938 ngx_quic_flush_flight(ngx_ssl_conn_t *ssl_conn) |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
939 { |
7837
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
7836
diff
changeset
|
940 #if (NGX_DEBUG) |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
941 ngx_connection_t *c; |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
942 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
943 c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn); |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
944 |
7836 | 945 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
946 "quic ngx_quic_flush_flight()"); | |
7837
f175006124d0
Cleaned up hexdumps in debug output.
Vladimir Homutov <vl@nginx.com>
parents:
7836
diff
changeset
|
947 #endif |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
948 return 1; |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
949 } |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
950 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
951 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
952 static int |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
953 ngx_quic_send_alert(ngx_ssl_conn_t *ssl_conn, enum ssl_encryption_level_t level, |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
954 uint8_t alert) |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
955 { |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
956 ngx_connection_t *c; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
957 ngx_quic_connection_t *qc; |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
958 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
959 c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn); |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
960 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
961 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
962 "quic ngx_quic_send_alert() lvl:%d alert:%d", |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
963 (int) level, (int) alert); |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
964 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
965 qc = ngx_quic_get_connection(c); |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
966 if (qc == NULL) { |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
967 return 1; |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7700
diff
changeset
|
968 } |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7700
diff
changeset
|
969 |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
970 qc->error_level = level; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
971 qc->error = NGX_QUIC_ERR_CRYPTO(alert); |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
972 qc->error_reason = "TLS alert"; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
973 qc->error_app = 0; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
974 qc->error_ftype = 0; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
975 |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
976 if (ngx_quic_send_cc(c) != NGX_OK) { |
7701
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7700
diff
changeset
|
977 return 0; |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7700
diff
changeset
|
978 } |
552d6868091b
Implemented send_alert callback, CONNECTION_CLOSE writer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7700
diff
changeset
|
979 |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
980 return 1; |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
981 } |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
982 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
983 |
8294
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
984 static ngx_int_t |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
985 ngx_quic_apply_transport_params(ngx_connection_t *c, ngx_quic_tp_t *ctp) |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
986 { |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
987 ngx_quic_connection_t *qc; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
988 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
989 qc = ngx_quic_get_connection(c); |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
990 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
991 if (qc->scid.len != ctp->initial_scid.len |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
992 || ngx_memcmp(qc->scid.data, ctp->initial_scid.data, qc->scid.len) != 0) |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
993 { |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
994 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
995 "quic client initial_source_connection_id mismatch"); |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
996 return NGX_ERROR; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
997 } |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
998 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
999 if (ctp->max_udp_payload_size < NGX_QUIC_MIN_INITIAL_SIZE |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1000 || ctp->max_udp_payload_size > NGX_QUIC_MAX_UDP_PAYLOAD_SIZE) |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1001 { |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1002 qc->error = NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1003 qc->error_reason = "invalid maximum packet size"; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1004 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1005 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1006 "quic maximum packet size is invalid"); |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1007 return NGX_ERROR; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1008 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1009 } else if (ctp->max_udp_payload_size > ngx_quic_max_udp_payload(c)) { |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1010 ctp->max_udp_payload_size = ngx_quic_max_udp_payload(c); |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1011 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
1012 "quic client maximum packet size truncated"); |
8294
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1013 } |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1014 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1015 if (ctp->active_connection_id_limit < 2) { |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1016 qc->error = NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1017 qc->error_reason = "invalid active_connection_id_limit"; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1018 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1019 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1020 "quic active_connection_id_limit is invalid"); |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1021 return NGX_ERROR; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1022 } |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1023 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1024 if (ctp->ack_delay_exponent > 20) { |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1025 qc->error = NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1026 qc->error_reason = "invalid ack_delay_exponent"; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1027 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1028 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1029 "quic ack_delay_exponent is invalid"); |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1030 return NGX_ERROR; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1031 } |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1032 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1033 if (ctp->max_ack_delay > 16384) { |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1034 qc->error = NGX_QUIC_ERR_TRANSPORT_PARAMETER_ERROR; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1035 qc->error_reason = "invalid max_ack_delay"; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1036 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1037 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1038 "quic max_ack_delay is invalid"); |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1039 return NGX_ERROR; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1040 } |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1041 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1042 if (ctp->max_idle_timeout > 0 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1043 && ctp->max_idle_timeout < qc->tp.max_idle_timeout) |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1044 { |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1045 qc->tp.max_idle_timeout = ctp->max_idle_timeout; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1046 } |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1047 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1048 qc->streams.server_max_streams_bidi = ctp->initial_max_streams_bidi; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1049 qc->streams.server_max_streams_uni = ctp->initial_max_streams_uni; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1050 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1051 ngx_memcpy(&qc->ctp, ctp, sizeof(ngx_quic_tp_t)); |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1052 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1053 return NGX_OK; |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1054 } |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1055 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1056 |
7691 | 1057 void |
8101
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
1058 ngx_quic_run(ngx_connection_t *c, ngx_quic_conf_t *conf) |
7691 | 1059 { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
1060 ngx_int_t rc; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
1061 ngx_quic_connection_t *qc; |
7691 | 1062 |
7729
1295b293d09a
Connection states code cleanup.
Vladimir Homutov <vl@nginx.com>
parents:
7726
diff
changeset
|
1063 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic run"); |
7691 | 1064 |
8101
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
1065 rc = ngx_quic_input(c, c->buffer, conf); |
8074
c6b963de0c00
QUIC: pass return code from ngx_quic_decrypt() to the caller.
Vladimir Homutov <vl@nginx.com>
parents:
8073
diff
changeset
|
1066 if (rc != NGX_OK) { |
c6b963de0c00
QUIC: pass return code from ngx_quic_decrypt() to the caller.
Vladimir Homutov <vl@nginx.com>
parents:
8073
diff
changeset
|
1067 ngx_quic_close_connection(c, rc == NGX_DECLINED ? NGX_DONE : NGX_ERROR); |
7691 | 1068 return; |
1069 } | |
1070 | |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
1071 qc = ngx_quic_get_connection(c); |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
1072 |
8279 | 1073 if (qc == NULL) { |
1074 ngx_quic_close_connection(c, NGX_DONE); | |
1075 return; | |
1076 } | |
1077 | |
1078 ngx_add_timer(c->read, qc->tp.max_idle_timeout); | |
1079 ngx_quic_connstate_dbg(c); | |
7691 | 1080 |
7729
1295b293d09a
Connection states code cleanup.
Vladimir Homutov <vl@nginx.com>
parents:
7726
diff
changeset
|
1081 c->read->handler = ngx_quic_input_handler; |
7691 | 1082 |
1083 return; | |
1084 } | |
1085 | |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1086 |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
1087 static ngx_quic_connection_t * |
8101
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
1088 ngx_quic_new_connection(ngx_connection_t *c, ngx_quic_conf_t *conf, |
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
1089 ngx_quic_header_t *pkt) |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1090 { |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1091 ngx_uint_t i; |
7731
d45325e90221
Limit output QUIC packets with client max_packet_size.
Roman Arutyunyan <arut@nginx.com>
parents:
7729
diff
changeset
|
1092 ngx_quic_tp_t *ctp; |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1093 ngx_quic_client_id_t *cid; |
7691 | 1094 ngx_quic_connection_t *qc; |
7864
eebdda507ec3
Added tests for connection id lengths in initial packet.
Vladimir Homutov <vl@nginx.com>
parents:
7863
diff
changeset
|
1095 |
7691 | 1096 qc = ngx_pcalloc(c->pool, sizeof(ngx_quic_connection_t)); |
1097 if (qc == NULL) { | |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
1098 return NULL; |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1099 } |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1100 |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
1101 qc->keys = ngx_quic_keys_new(c->pool); |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
1102 if (qc->keys == NULL) { |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
1103 return NULL; |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
1104 } |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
1105 |
8194
340cd26158fb
QUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8193
diff
changeset
|
1106 qc->version = pkt->version; |
340cd26158fb
QUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8193
diff
changeset
|
1107 |
7691 | 1108 ngx_rbtree_init(&qc->streams.tree, &qc->streams.sentinel, |
1109 ngx_quic_rbtree_insert_stream); | |
1110 | |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
1111 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
1112 ngx_queue_init(&qc->send_ctx[i].frames); |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
1113 ngx_queue_init(&qc->send_ctx[i].sent); |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
1114 qc->send_ctx[i].largest_pn = NGX_QUIC_UNSET_PN; |
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
1115 qc->send_ctx[i].largest_ack = NGX_QUIC_UNSET_PN; |
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
1116 qc->send_ctx[i].largest_range = NGX_QUIC_UNSET_PN; |
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
1117 qc->send_ctx[i].pending_ack = NGX_QUIC_UNSET_PN; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
1118 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
1119 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
1120 qc->send_ctx[0].level = ssl_encryption_initial; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
1121 qc->send_ctx[1].level = ssl_encryption_handshake; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
1122 qc->send_ctx[2].level = ssl_encryption_application; |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
1123 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
1124 for (i = 0; i < NGX_QUIC_ENCRYPTION_LAST; i++) { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
1125 ngx_queue_init(&qc->crypto[i].frames); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
1126 } |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1127 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1128 ngx_queue_init(&qc->free_frames); |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1129 ngx_queue_init(&qc->client_ids); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1130 ngx_queue_init(&qc->server_ids); |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1131 ngx_queue_init(&qc->free_client_ids); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1132 ngx_queue_init(&qc->free_server_ids); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1133 |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
1134 qc->avg_rtt = NGX_QUIC_INITIAL_RTT; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
1135 qc->rttvar = NGX_QUIC_INITIAL_RTT / 2; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
1136 qc->min_rtt = NGX_TIMER_INFINITE; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
1137 |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
1138 /* |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
1139 * qc->latest_rtt = 0 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1140 * qc->nclient_ids = 0 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1141 * qc->nserver_ids = 0 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1142 * qc->max_retired_seqnum = 0 |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
1143 */ |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
1144 |
7995
031918df51c0
QUIC: added anti-amplification limit.
Vladimir Homutov <vl@nginx.com>
parents:
7994
diff
changeset
|
1145 qc->received = pkt->raw->last - pkt->raw->start; |
031918df51c0
QUIC: added anti-amplification limit.
Vladimir Homutov <vl@nginx.com>
parents:
7994
diff
changeset
|
1146 |
7990 | 1147 qc->pto.log = c->log; |
1148 qc->pto.data = c; | |
1149 qc->pto.handler = ngx_quic_pto_handler; | |
1150 qc->pto.cancelable = 1; | |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
1151 |
7775 | 1152 qc->push.log = c->log; |
1153 qc->push.data = c; | |
1154 qc->push.handler = ngx_quic_push_handler; | |
1155 qc->push.cancelable = 1; | |
1156 | |
7999
0d2b2664b41c
QUIC: added "quic" listen parameter.
Roman Arutyunyan <arut@nginx.com>
parents:
7998
diff
changeset
|
1157 qc->conf = conf; |
0d2b2664b41c
QUIC: added "quic" listen parameter.
Roman Arutyunyan <arut@nginx.com>
parents:
7998
diff
changeset
|
1158 qc->tp = conf->tp; |
7691 | 1159 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1160 if (qc->tp.disable_active_migration) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1161 qc->sockaddr = ngx_palloc(c->pool, c->socklen); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1162 if (qc->sockaddr == NULL) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1163 return NULL; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1164 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1165 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1166 ngx_memcpy(qc->sockaddr, c->sockaddr, c->socklen); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1167 qc->socklen = c->socklen; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1168 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1169 |
7731
d45325e90221
Limit output QUIC packets with client max_packet_size.
Roman Arutyunyan <arut@nginx.com>
parents:
7729
diff
changeset
|
1170 ctp = &qc->ctp; |
8294
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1171 |
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1172 /* defaults to be used before actual client parameters are received */ |
7931
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1173 ctp->max_udp_payload_size = ngx_quic_max_udp_payload(c); |
7731
d45325e90221
Limit output QUIC packets with client max_packet_size.
Roman Arutyunyan <arut@nginx.com>
parents:
7729
diff
changeset
|
1174 ctp->ack_delay_exponent = NGX_QUIC_DEFAULT_ACK_DELAY_EXPONENT; |
d45325e90221
Limit output QUIC packets with client max_packet_size.
Roman Arutyunyan <arut@nginx.com>
parents:
7729
diff
changeset
|
1175 ctp->max_ack_delay = NGX_QUIC_DEFAULT_MAX_ACK_DELAY; |
8294
ba9e34c03968
QUIC: added check of client transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
8291
diff
changeset
|
1176 ctp->active_connection_id_limit = 2; |
7731
d45325e90221
Limit output QUIC packets with client max_packet_size.
Roman Arutyunyan <arut@nginx.com>
parents:
7729
diff
changeset
|
1177 |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
1178 qc->streams.recv_max_data = qc->tp.initial_max_data; |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
1179 |
8014
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
1180 qc->streams.client_max_streams_uni = qc->tp.initial_max_streams_uni; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
1181 qc->streams.client_max_streams_bidi = qc->tp.initial_max_streams_bidi; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
1182 |
7910
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7908
diff
changeset
|
1183 qc->congestion.window = ngx_min(10 * qc->tp.max_udp_payload_size, |
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7908
diff
changeset
|
1184 ngx_max(2 * qc->tp.max_udp_payload_size, |
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7908
diff
changeset
|
1185 14720)); |
8193
8550b91e8e35
QUIC: added proper logging of special values.
Vladimir Homutov <vl@nginx.com>
parents:
8192
diff
changeset
|
1186 qc->congestion.ssthresh = (size_t) -1; |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
1187 qc->congestion.recovery_start = ngx_current_msec; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
1188 |
8279 | 1189 qc->odcid.len = pkt->odcid.len; |
1190 qc->odcid.data = ngx_pstrdup(c->pool, &pkt->odcid); | |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1191 if (qc->odcid.data == NULL) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1192 return NULL; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1193 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1194 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1195 qc->dcid.len = NGX_QUIC_SERVER_CID_LEN; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1196 qc->dcid.data = ngx_pnalloc(c->pool, qc->dcid.len); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1197 if (qc->dcid.data == NULL) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1198 return NULL; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1199 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1200 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1201 if (ngx_quic_create_server_id(c, qc->dcid.data) != NGX_OK) { |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
1202 return NULL; |
7691 | 1203 } |
7845 | 1204 |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
1205 qc->tp.original_dcid = qc->odcid; |
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
1206 qc->tp.initial_scid = qc->dcid; |
7912
6633f17044eb
QUIC draft-28 transport parameters support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7910
diff
changeset
|
1207 |
8279 | 1208 if (pkt->validated && pkt->retried) { |
1209 qc->tp.retry_scid.len = pkt->dcid.len; | |
1210 qc->tp.retry_scid.data = ngx_pstrdup(c->pool, &pkt->dcid); | |
1211 if (qc->tp.retry_scid.data == NULL) { | |
1212 return NULL; | |
1213 } | |
1214 } | |
1215 | |
7691 | 1216 qc->scid.len = pkt->scid.len; |
8279 | 1217 qc->scid.data = ngx_pstrdup(c->pool, &pkt->scid); |
7691 | 1218 if (qc->scid.data == NULL) { |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
1219 return NULL; |
7691 | 1220 } |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1221 |
8197
405b6e8eb523
QUIC: renamed field and function related to client ids.
Roman Arutyunyan <arut@nginx.com>
parents:
8196
diff
changeset
|
1222 cid = ngx_quic_alloc_client_id(c, qc); |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1223 if (cid == NULL) { |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
1224 return NULL; |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1225 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1226 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1227 cid->seqnum = 0; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1228 cid->len = pkt->scid.len; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1229 ngx_memcpy(cid->id, pkt->scid.data, pkt->scid.len); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1230 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1231 ngx_queue_insert_tail(&qc->client_ids, &cid->queue); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1232 qc->nclient_ids++; |
8197
405b6e8eb523
QUIC: renamed field and function related to client ids.
Roman Arutyunyan <arut@nginx.com>
parents:
8196
diff
changeset
|
1233 qc->client_seqnum = 0; |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
1234 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1235 qc->server_seqnum = NGX_QUIC_UNSET_PN; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1236 |
8322
44b4c6180106
QUIC: multiple versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8321
diff
changeset
|
1237 if (ngx_quic_keys_set_initial_secret(c->pool, qc->keys, &pkt->dcid, |
44b4c6180106
QUIC: multiple versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8321
diff
changeset
|
1238 qc->version) |
8279 | 1239 != NGX_OK) |
1240 { | |
1241 return NULL; | |
1242 } | |
1243 | |
1244 c->udp = &qc->udp; | |
1245 | |
1246 if (ngx_quic_insert_server_id(c, &qc->odcid) == NULL) { | |
1247 return NULL; | |
1248 } | |
1249 | |
1250 qc->server_seqnum = 0; | |
1251 | |
1252 if (ngx_quic_insert_server_id(c, &qc->dcid) == NULL) { | |
1253 return NULL; | |
1254 } | |
1255 | |
1256 qc->validated = pkt->validated; | |
1257 | |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
1258 return qc; |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1259 } |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1260 |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1261 |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1262 static ngx_int_t |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1263 ngx_quic_send_stateless_reset(ngx_connection_t *c, ngx_quic_conf_t *conf, |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1264 ngx_quic_header_t *pkt) |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1265 { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1266 u_char *token; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1267 size_t len, max; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1268 uint16_t rndbytes; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1269 u_char buf[NGX_QUIC_MAX_SR_PACKET]; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1270 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1271 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1272 "quic handle stateless reset output"); |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1273 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1274 if (pkt->len <= NGX_QUIC_MIN_PKT_LEN) { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1275 return NGX_DECLINED; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1276 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1277 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1278 if (pkt->len <= NGX_QUIC_MIN_SR_PACKET) { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1279 len = pkt->len - 1; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1280 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1281 } else { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1282 max = ngx_min(NGX_QUIC_MAX_SR_PACKET, pkt->len * 3); |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1283 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1284 if (RAND_bytes((u_char *) &rndbytes, sizeof(rndbytes)) != 1) { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1285 return NGX_ERROR; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1286 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1287 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1288 len = (rndbytes % (max - NGX_QUIC_MIN_SR_PACKET + 1)) |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1289 + NGX_QUIC_MIN_SR_PACKET; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1290 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1291 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1292 if (RAND_bytes(buf, len - NGX_QUIC_SR_TOKEN_LEN) != 1) { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1293 return NGX_ERROR; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1294 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1295 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1296 buf[0] &= ~NGX_QUIC_PKT_LONG; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1297 buf[0] |= NGX_QUIC_PKT_FIXED_BIT; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1298 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1299 token = &buf[len - NGX_QUIC_SR_TOKEN_LEN]; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1300 |
8287
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1301 if (ngx_quic_new_sr_token(c, &pkt->dcid, conf->sr_token_key, token) |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1302 != NGX_OK) |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1303 { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1304 return NGX_ERROR; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1305 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1306 |
8240
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
1307 (void) ngx_quic_send(c, buf, len); |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1308 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1309 return NGX_DECLINED; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1310 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1311 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1312 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1313 static ngx_int_t |
8287
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1314 ngx_quic_new_sr_token(ngx_connection_t *c, ngx_str_t *cid, u_char *secret, |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1315 u_char *token) |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1316 { |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1317 ngx_str_t tmp; |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1318 |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1319 tmp.data = secret; |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1320 tmp.len = NGX_QUIC_SR_KEY_LEN; |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1321 |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1322 if (ngx_quic_derive_key(c->log, "sr_token_key", &tmp, cid, token, |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1323 NGX_QUIC_SR_TOKEN_LEN) |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1324 != NGX_OK) |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1325 { |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1326 return NGX_ERROR; |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1327 } |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1328 |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1329 #if (NGX_DEBUG) |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1330 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1331 "quic stateless reset token %*xs", |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1332 (size_t) NGX_QUIC_SR_TOKEN_LEN, token); |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1333 #endif |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1334 |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1335 return NGX_OK; |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1336 } |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1337 |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1338 |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1339 static ngx_int_t |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1340 ngx_quic_process_stateless_reset(ngx_connection_t *c, ngx_quic_header_t *pkt) |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1341 { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1342 u_char *tail, ch; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1343 ngx_uint_t i; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1344 ngx_queue_t *q; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1345 ngx_quic_client_id_t *cid; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1346 ngx_quic_connection_t *qc; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1347 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
1348 qc = ngx_quic_get_connection(c); |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1349 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1350 /* A stateless reset uses an entire UDP datagram */ |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1351 if (pkt->raw->start != pkt->data) { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1352 return NGX_DECLINED; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1353 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1354 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1355 tail = pkt->raw->last - NGX_QUIC_SR_TOKEN_LEN; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1356 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1357 for (q = ngx_queue_head(&qc->client_ids); |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1358 q != ngx_queue_sentinel(&qc->client_ids); |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1359 q = ngx_queue_next(q)) |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1360 { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1361 cid = ngx_queue_data(q, ngx_quic_client_id_t, queue); |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1362 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1363 if (cid->seqnum == 0) { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1364 /* no stateless reset token in initial connection id */ |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1365 continue; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1366 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1367 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1368 /* constant time comparison */ |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1369 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1370 for (ch = 0, i = 0; i < NGX_QUIC_SR_TOKEN_LEN; i++) { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1371 ch |= tail[i] ^ cid->sr_token[i]; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1372 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1373 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1374 if (ch == 0) { |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1375 return NGX_OK; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1376 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1377 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1378 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1379 return NGX_DECLINED; |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1380 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1381 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1382 |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1383 static ngx_int_t |
8060
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1384 ngx_quic_negotiate_version(ngx_connection_t *c, ngx_quic_header_t *inpkt) |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1385 { |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1386 size_t len; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1387 ngx_quic_header_t pkt; |
8195
4416b7ab0a27
QUIC: multiple versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8194
diff
changeset
|
1388 static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; |
8060
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1389 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1390 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1391 "sending version negotiation packet"); |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1392 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1393 pkt.log = c->log; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1394 pkt.flags = NGX_QUIC_PKT_LONG | NGX_QUIC_PKT_FIXED_BIT; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1395 pkt.dcid = inpkt->scid; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1396 pkt.scid = inpkt->dcid; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1397 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1398 len = ngx_quic_create_version_negotiation(&pkt, buf); |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1399 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1400 #ifdef NGX_QUIC_DEBUG_PACKETS |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1401 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1402 "quic vnego packet to send len:%uz %*xs", len, len, buf); |
8060
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1403 #endif |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1404 |
8240
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
1405 (void) ngx_quic_send(c, buf, len); |
8060
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1406 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1407 return NGX_ERROR; |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1408 } |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1409 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1410 |
fc89d02bdca2
QUIC: added version negotiation support.
Vladimir Homutov <vl@nginx.com>
parents:
8057
diff
changeset
|
1411 static ngx_int_t |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1412 ngx_quic_create_server_id(ngx_connection_t *c, u_char *id) |
7845 | 1413 { |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1414 if (RAND_bytes(id, NGX_QUIC_SERVER_CID_LEN) != 1) { |
7859
b7704303a7e5
Server CID change refactored.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7858
diff
changeset
|
1415 return NGX_ERROR; |
b7704303a7e5
Server CID change refactored.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7858
diff
changeset
|
1416 } |
b7704303a7e5
Server CID change refactored.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7858
diff
changeset
|
1417 |
8269
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1418 #if (NGX_QUIC_BPF) |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1419 if (ngx_quic_bpf_attach_id(c, id) != NGX_OK) { |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1420 ngx_log_error(NGX_LOG_ERR, c->log, 0, |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1421 "quic bpf failed to generate socket key"); |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1422 /* ignore error, things still may work */ |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1423 } |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1424 #endif |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1425 |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1426 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1427 "quic create server id %*xs", |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1428 (size_t) NGX_QUIC_SERVER_CID_LEN, id); |
7845 | 1429 return NGX_OK; |
1430 } | |
1431 | |
1432 | |
8269
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1433 #if (NGX_QUIC_BPF) |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1434 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1435 static ngx_int_t |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1436 ngx_quic_bpf_attach_id(ngx_connection_t *c, u_char *id) |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1437 { |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1438 int fd; |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1439 uint64_t cookie; |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1440 socklen_t optlen; |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1441 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1442 fd = c->listening->fd; |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1443 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1444 optlen = sizeof(cookie); |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1445 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1446 if (getsockopt(fd, SOL_SOCKET, SO_COOKIE, &cookie, &optlen) == -1) { |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1447 ngx_log_error(NGX_LOG_ERR, c->log, ngx_socket_errno, |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1448 "quic getsockopt(SO_COOKIE) failed"); |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1449 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1450 return NGX_ERROR; |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1451 } |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1452 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1453 ngx_quic_dcid_encode_key(id, cookie); |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1454 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1455 return NGX_OK; |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1456 } |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1457 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1458 #endif |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1459 |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
8267
diff
changeset
|
1460 |
7845 | 1461 static ngx_int_t |
8279 | 1462 ngx_quic_send_retry(ngx_connection_t *c, ngx_quic_conf_t *conf, |
1463 ngx_quic_header_t *inpkt) | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1464 { |
8279 | 1465 time_t expires; |
1466 ssize_t len; | |
1467 ngx_str_t res, token; | |
1468 ngx_quic_header_t pkt; | |
1469 | |
1470 u_char buf[NGX_QUIC_RETRY_BUFFER_SIZE]; | |
1471 u_char dcid[NGX_QUIC_SERVER_CID_LEN]; | |
1472 | |
8287
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1473 expires = ngx_time() + NGX_QUIC_RETRY_TOKEN_LIFETIME; |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1474 |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1475 if (ngx_quic_new_token(c, conf->av_token_key, &token, &inpkt->dcid, |
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1476 expires, 1) |
8279 | 1477 != NGX_OK) |
1478 { | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1479 return NGX_ERROR; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1480 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1481 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1482 ngx_memzero(&pkt, sizeof(ngx_quic_header_t)); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1483 pkt.flags = NGX_QUIC_PKT_FIXED_BIT | NGX_QUIC_PKT_LONG | NGX_QUIC_PKT_RETRY; |
8279 | 1484 pkt.version = inpkt->version; |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1485 pkt.log = c->log; |
8279 | 1486 |
1487 pkt.odcid = inpkt->dcid; | |
1488 pkt.dcid = inpkt->scid; | |
1489 | |
1490 /* TODO: generate routable dcid */ | |
1491 if (RAND_bytes(dcid, NGX_QUIC_SERVER_CID_LEN) != 1) { | |
1492 return NGX_ERROR; | |
1493 } | |
1494 | |
1495 pkt.scid.len = NGX_QUIC_SERVER_CID_LEN; | |
1496 pkt.scid.data = dcid; | |
1497 | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1498 pkt.token = token; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1499 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1500 res.data = buf; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1501 |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
1502 if (ngx_quic_encrypt(&pkt, &res) != NGX_OK) { |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1503 return NGX_ERROR; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1504 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1505 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1506 #ifdef NGX_QUIC_DEBUG_PACKETS |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1507 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1508 "quic packet to send len:%uz %xV", res.len, &res); |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1509 #endif |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1510 |
8240
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
1511 len = ngx_quic_send(c, res.data, res.len); |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
1512 if (len == NGX_ERROR) { |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1513 return NGX_ERROR; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1514 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1515 |
8279 | 1516 ngx_log_debug(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
1517 "quic retry packet sent to %xV", &pkt.dcid); |
8279 | 1518 |
1519 /* | |
1520 * quic-transport 17.2.5.1: A server MUST NOT send more than one Retry | |
1521 * packet in response to a single UDP datagram. | |
1522 * NGX_DONE will stop quic_input() from processing further | |
1523 */ | |
1524 return NGX_DONE; | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1525 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1526 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1527 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1528 static ngx_int_t |
8279 | 1529 ngx_quic_new_token(ngx_connection_t *c, u_char *key, ngx_str_t *token, |
1530 ngx_str_t *odcid, time_t exp, ngx_uint_t is_retry) | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1531 { |
8279 | 1532 int len, iv_len; |
1533 u_char *p, *iv; | |
1534 EVP_CIPHER_CTX *ctx; | |
1535 const EVP_CIPHER *cipher; | |
1536 | |
1537 u_char in[NGX_QUIC_MAX_TOKEN_SIZE]; | |
1538 | |
1539 ngx_quic_address_hash(c, !is_retry, in); | |
1540 | |
1541 p = in + 20; | |
1542 | |
1543 p = ngx_cpymem(p, &exp, sizeof(time_t)); | |
1544 | |
1545 *p++ = is_retry ? 1 : 0; | |
1546 | |
1547 if (odcid) { | |
1548 *p++ = odcid->len; | |
1549 p = ngx_cpymem(p, odcid->data, odcid->len); | |
1550 | |
1551 } else { | |
1552 *p++ = 0; | |
1553 } | |
1554 | |
1555 len = p - in; | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1556 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1557 cipher = EVP_aes_256_cbc(); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1558 iv_len = EVP_CIPHER_iv_length(cipher); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1559 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1560 token->len = iv_len + len + EVP_CIPHER_block_size(cipher); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1561 token->data = ngx_pnalloc(c->pool, token->len); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1562 if (token->data == NULL) { |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1563 return NGX_ERROR; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1564 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1565 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1566 ctx = EVP_CIPHER_CTX_new(); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1567 if (ctx == NULL) { |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1568 return NGX_ERROR; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1569 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1570 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1571 iv = token->data; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1572 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1573 if (RAND_bytes(iv, iv_len) <= 0 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1574 || !EVP_EncryptInit_ex(ctx, cipher, NULL, key, iv)) |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1575 { |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1576 EVP_CIPHER_CTX_free(ctx); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1577 return NGX_ERROR; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1578 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1579 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1580 token->len = iv_len; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1581 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1582 if (EVP_EncryptUpdate(ctx, token->data + token->len, &len, in, len) != 1) { |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1583 EVP_CIPHER_CTX_free(ctx); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1584 return NGX_ERROR; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1585 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1586 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1587 token->len += len; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1588 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1589 if (EVP_EncryptFinal_ex(ctx, token->data + token->len, &len) <= 0) { |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1590 EVP_CIPHER_CTX_free(ctx); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1591 return NGX_ERROR; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1592 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1593 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1594 token->len += len; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1595 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1596 EVP_CIPHER_CTX_free(ctx); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1597 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1598 #ifdef NGX_QUIC_DEBUG_PACKETS |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1599 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1600 "quic new token len:%uz %xV", token->len, token); |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1601 #endif |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1602 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1603 return NGX_OK; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1604 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1605 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1606 |
8279 | 1607 static void |
1608 ngx_quic_address_hash(ngx_connection_t *c, ngx_uint_t no_port, u_char buf[20]) | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1609 { |
8279 | 1610 size_t len; |
1611 u_char *data; | |
1612 ngx_sha1_t sha1; | |
1613 struct sockaddr_in *sin; | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1614 #if (NGX_HAVE_INET6) |
8279 | 1615 struct sockaddr_in6 *sin6; |
1616 #endif | |
1617 | |
1618 len = (size_t) c->socklen; | |
1619 data = (u_char *) c->sockaddr; | |
1620 | |
1621 if (no_port) { | |
1622 switch (c->sockaddr->sa_family) { | |
1623 | |
1624 #if (NGX_HAVE_INET6) | |
1625 case AF_INET6: | |
1626 sin6 = (struct sockaddr_in6 *) c->sockaddr; | |
1627 | |
1628 len = sizeof(struct in6_addr); | |
1629 data = sin6->sin6_addr.s6_addr; | |
1630 | |
1631 break; | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1632 #endif |
8279 | 1633 |
1634 case AF_INET: | |
1635 sin = (struct sockaddr_in *) c->sockaddr; | |
1636 | |
1637 len = sizeof(in_addr_t); | |
1638 data = (u_char *) &sin->sin_addr; | |
1639 | |
1640 break; | |
1641 } | |
1642 } | |
1643 | |
1644 ngx_sha1_init(&sha1); | |
1645 ngx_sha1_update(&sha1, data, len); | |
1646 ngx_sha1_final(buf, &sha1); | |
1647 } | |
1648 | |
1649 | |
1650 static ngx_int_t | |
1651 ngx_quic_validate_token(ngx_connection_t *c, u_char *key, | |
1652 ngx_quic_header_t *pkt) | |
1653 { | |
1654 int len, tlen, iv_len; | |
1655 u_char *iv, *p; | |
1656 time_t now, exp; | |
1657 size_t total; | |
1658 ngx_str_t odcid; | |
1659 EVP_CIPHER_CTX *ctx; | |
1660 const EVP_CIPHER *cipher; | |
1661 | |
1662 u_char addr_hash[20]; | |
1663 u_char tdec[NGX_QUIC_MAX_TOKEN_SIZE]; | |
1664 | |
1665 /* Retry token or NEW_TOKEN in a previous connection */ | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1666 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1667 cipher = EVP_aes_256_cbc(); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1668 iv = pkt->token.data; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1669 iv_len = EVP_CIPHER_iv_length(cipher); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1670 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1671 /* sanity checks */ |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1672 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1673 if (pkt->token.len < (size_t) iv_len + EVP_CIPHER_block_size(cipher)) { |
8279 | 1674 goto garbage; |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1675 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1676 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1677 if (pkt->token.len > (size_t) iv_len + NGX_QUIC_MAX_TOKEN_SIZE) { |
8279 | 1678 goto garbage; |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1679 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1680 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1681 ctx = EVP_CIPHER_CTX_new(); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1682 if (ctx == NULL) { |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1683 return NGX_ERROR; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1684 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1685 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1686 if (!EVP_DecryptInit_ex(ctx, cipher, NULL, key, iv)) { |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1687 EVP_CIPHER_CTX_free(ctx); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1688 return NGX_ERROR; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1689 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1690 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1691 p = pkt->token.data + iv_len; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1692 len = pkt->token.len - iv_len; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1693 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1694 if (EVP_DecryptUpdate(ctx, tdec, &len, p, len) != 1) { |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1695 EVP_CIPHER_CTX_free(ctx); |
8279 | 1696 goto garbage; |
1697 } | |
1698 total = len; | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1699 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1700 if (EVP_DecryptFinal_ex(ctx, tdec + len, &tlen) <= 0) { |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1701 EVP_CIPHER_CTX_free(ctx); |
8279 | 1702 goto garbage; |
1703 } | |
1704 total += tlen; | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1705 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1706 EVP_CIPHER_CTX_free(ctx); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1707 |
8279 | 1708 if (total < (20 + sizeof(time_t) + 2)) { |
1709 goto garbage; | |
1710 } | |
1711 | |
1712 p = tdec + 20; | |
1713 | |
1714 ngx_memcpy(&exp, p, sizeof(time_t)); | |
1715 p += sizeof(time_t); | |
1716 | |
1717 pkt->retried = (*p++ == 1); | |
1718 | |
1719 ngx_quic_address_hash(c, !pkt->retried, addr_hash); | |
1720 | |
1721 if (ngx_memcmp(tdec, addr_hash, 20) != 0) { | |
7876
ffd362e87eb2
Added more context to CONNECTION CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7875
diff
changeset
|
1722 goto bad_token; |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1723 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1724 |
8279 | 1725 odcid.len = *p++; |
1726 if (odcid.len) { | |
1727 if (odcid.len > NGX_QUIC_MAX_CID_LEN) { | |
1728 goto bad_token; | |
1729 } | |
1730 | |
1731 if ((size_t)(tdec + total - p) < odcid.len) { | |
1732 goto bad_token; | |
1733 } | |
1734 | |
1735 odcid.data = p; | |
1736 p += odcid.len; | |
1737 } | |
1738 | |
1739 now = ngx_time(); | |
1740 | |
1741 if (now > exp) { | |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
1742 ngx_log_error(NGX_LOG_INFO, c->log, 0, "quic expired token"); |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1743 return NGX_DECLINED; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1744 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1745 |
8279 | 1746 if (odcid.len) { |
1747 pkt->odcid.len = odcid.len; | |
1748 pkt->odcid.data = ngx_pstrdup(c->pool, &odcid); | |
1749 if (pkt->odcid.data == NULL) { | |
1750 return NGX_ERROR; | |
1751 } | |
1752 | |
1753 } else { | |
1754 pkt->odcid = pkt->dcid; | |
1755 } | |
1756 | |
1757 pkt->validated = 1; | |
1758 | |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1759 return NGX_OK; |
7876
ffd362e87eb2
Added more context to CONNECTION CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7875
diff
changeset
|
1760 |
8279 | 1761 garbage: |
1762 | |
1763 ngx_log_error(NGX_LOG_INFO, c->log, 0, "quic garbage token"); | |
1764 | |
1765 return NGX_ABORT; | |
1766 | |
7876
ffd362e87eb2
Added more context to CONNECTION CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7875
diff
changeset
|
1767 bad_token: |
ffd362e87eb2
Added more context to CONNECTION CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7875
diff
changeset
|
1768 |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
1769 ngx_log_error(NGX_LOG_INFO, c->log, 0, "quic invalid token"); |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
1770 |
8192
183275308d9a
QUIC: fixed address validation issues in a new connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8191
diff
changeset
|
1771 return NGX_DECLINED; |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1772 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1773 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1774 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1775 static ngx_int_t |
7687
69345a26ba69
Split transport and crypto parts into separate files.
Vladimir Homutov <vl@nginx.com>
parents:
7686
diff
changeset
|
1776 ngx_quic_init_connection(ngx_connection_t *c) |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1777 { |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1778 u_char *p; |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1779 size_t clen; |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1780 ssize_t len; |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1781 ngx_ssl_conn_t *ssl_conn; |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1782 ngx_quic_connection_t *qc; |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1783 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
1784 qc = ngx_quic_get_connection(c); |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1785 |
8101
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
1786 if (ngx_ssl_create_connection(qc->conf->ssl, c, NGX_SSL_BUFFER) != NGX_OK) { |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1787 return NGX_ERROR; |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1788 } |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1789 |
8239
f596a4e5794b
QUIC: disabling bidirectional SSL shutdown earlier.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8236
diff
changeset
|
1790 c->ssl->no_wait_shutdown = 1; |
f596a4e5794b
QUIC: disabling bidirectional SSL shutdown earlier.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8236
diff
changeset
|
1791 |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1792 ssl_conn = c->ssl->connection; |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1793 |
7698
253cf267f95a
Moved setting QUIC methods to runtime.
Roman Arutyunyan <arut@nginx.com>
parents:
7697
diff
changeset
|
1794 if (SSL_set_quic_method(ssl_conn, &quic_method) == 0) { |
253cf267f95a
Moved setting QUIC methods to runtime.
Roman Arutyunyan <arut@nginx.com>
parents:
7697
diff
changeset
|
1795 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
7838 | 1796 "quic SSL_set_quic_method() failed"); |
7698
253cf267f95a
Moved setting QUIC methods to runtime.
Roman Arutyunyan <arut@nginx.com>
parents:
7697
diff
changeset
|
1797 return NGX_ERROR; |
253cf267f95a
Moved setting QUIC methods to runtime.
Roman Arutyunyan <arut@nginx.com>
parents:
7697
diff
changeset
|
1798 } |
253cf267f95a
Moved setting QUIC methods to runtime.
Roman Arutyunyan <arut@nginx.com>
parents:
7697
diff
changeset
|
1799 |
7770
90f94413177e
TLS Early Data support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7769
diff
changeset
|
1800 #ifdef SSL_READ_EARLY_DATA_SUCCESS |
8102
b52b2a33b0e5
QUIC: fixed build with OpenSSL after bed310672f39.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8101
diff
changeset
|
1801 if (SSL_CTX_get_max_early_data(qc->conf->ssl->ctx)) { |
7770
90f94413177e
TLS Early Data support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7769
diff
changeset
|
1802 SSL_set_quic_early_data_enabled(ssl_conn, 1); |
90f94413177e
TLS Early Data support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7769
diff
changeset
|
1803 } |
90f94413177e
TLS Early Data support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7769
diff
changeset
|
1804 #endif |
90f94413177e
TLS Early Data support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7769
diff
changeset
|
1805 |
8352
0a0b1de9ccab
QUIC: fixed expected TLS codepoint with final draft and BoringSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8322
diff
changeset
|
1806 #if BORINGSSL_API_VERSION >= 13 |
0a0b1de9ccab
QUIC: fixed expected TLS codepoint with final draft and BoringSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8322
diff
changeset
|
1807 SSL_set_quic_use_legacy_codepoint(ssl_conn, qc->version != 1); |
0a0b1de9ccab
QUIC: fixed expected TLS codepoint with final draft and BoringSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8322
diff
changeset
|
1808 #endif |
0a0b1de9ccab
QUIC: fixed expected TLS codepoint with final draft and BoringSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8322
diff
changeset
|
1809 |
8287
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
1810 if (ngx_quic_new_sr_token(c, &qc->dcid, qc->conf->sr_token_key, |
8204
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8201
diff
changeset
|
1811 qc->tp.sr_token) |
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8201
diff
changeset
|
1812 != NGX_OK) |
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8201
diff
changeset
|
1813 { |
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8201
diff
changeset
|
1814 return NGX_ERROR; |
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8201
diff
changeset
|
1815 } |
831d1960826f
QUIC: generate default stateless reset token key.
Roman Arutyunyan <arut@nginx.com>
parents:
8201
diff
changeset
|
1816 |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1817 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1818 "quic stateless reset token %*xs", |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1819 (size_t) NGX_QUIC_SR_TOKEN_LEN, qc->tp.sr_token); |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
1820 |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1821 len = ngx_quic_create_transport_params(NULL, NULL, &qc->tp, &clen); |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1822 /* always succeeds */ |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1823 |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1824 p = ngx_pnalloc(c->pool, len); |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1825 if (p == NULL) { |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1826 return NGX_ERROR; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1827 } |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1828 |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1829 len = ngx_quic_create_transport_params(p, p + len, &qc->tp, NULL); |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1830 if (len < 0) { |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1831 return NGX_ERROR; |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1832 } |
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1833 |
7836 | 1834 #ifdef NGX_QUIC_DEBUG_PACKETS |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1835 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
1836 "quic transport parameters len:%uz %*xs", len, len, p); |
7836 | 1837 #endif |
1838 | |
7713
e9891e8ee975
Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents:
7712
diff
changeset
|
1839 if (SSL_set_quic_transport_params(ssl_conn, p, len) == 0) { |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1840 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
7838 | 1841 "quic SSL_set_quic_transport_params() failed"); |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1842 return NGX_ERROR; |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1843 } |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1844 |
7917
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1845 #if NGX_OPENSSL_QUIC_ZRTT_CTX |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1846 if (SSL_set_quic_early_data_context(ssl_conn, p, clen) == 0) { |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1847 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1848 "quic SSL_set_quic_early_data_context() failed"); |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1849 return NGX_ERROR; |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1850 } |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1851 #endif |
90b02ff6b003
Compatibility with BoringSSL master branch.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7916
diff
changeset
|
1852 |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1853 return NGX_OK; |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1854 } |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1855 |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1856 |
7931
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1857 static ngx_inline size_t |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1858 ngx_quic_max_udp_payload(ngx_connection_t *c) |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1859 { |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1860 /* TODO: path MTU discovery */ |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1861 |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1862 #if (NGX_HAVE_INET6) |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1863 if (c->sockaddr->sa_family == AF_INET6) { |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1864 return NGX_QUIC_MAX_UDP_PAYLOAD_OUT6; |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1865 } |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1866 #endif |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1867 |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1868 return NGX_QUIC_MAX_UDP_PAYLOAD_OUT; |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1869 } |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1870 |
9fe7875ce4bb
QUIC: further limiting maximum QUIC packet size.
Vladimir Homutov <vl@nginx.com>
parents:
7930
diff
changeset
|
1871 |
7691 | 1872 static void |
7729
1295b293d09a
Connection states code cleanup.
Vladimir Homutov <vl@nginx.com>
parents:
7726
diff
changeset
|
1873 ngx_quic_input_handler(ngx_event_t *rev) |
7677
6bc18966b8c1
Stream "connection" read/write methods.
Vladimir Homutov <vl@nginx.com>
parents:
7675
diff
changeset
|
1874 { |
7737
8e54a17dabee
Respect QUIC max_idle_timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
7736
diff
changeset
|
1875 ssize_t n; |
8083
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
1876 ngx_int_t rc; |
7737
8e54a17dabee
Respect QUIC max_idle_timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
7736
diff
changeset
|
1877 ngx_buf_t b; |
8e54a17dabee
Respect QUIC max_idle_timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
7736
diff
changeset
|
1878 ngx_connection_t *c; |
8e54a17dabee
Respect QUIC max_idle_timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
7736
diff
changeset
|
1879 ngx_quic_connection_t *qc; |
7910
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7908
diff
changeset
|
1880 static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; |
7677
6bc18966b8c1
Stream "connection" read/write methods.
Vladimir Homutov <vl@nginx.com>
parents:
7675
diff
changeset
|
1881 |
8135
eacca87c476e
QUIC: updated c->log->action strings to reflect proper state.
Vladimir Homutov <vl@nginx.com>
parents:
8134
diff
changeset
|
1882 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, rev->log, 0, "quic input handler"); |
eacca87c476e
QUIC: updated c->log->action strings to reflect proper state.
Vladimir Homutov <vl@nginx.com>
parents:
8134
diff
changeset
|
1883 |
7871 | 1884 ngx_memzero(&b, sizeof(ngx_buf_t)); |
7691 | 1885 b.start = buf; |
7731
d45325e90221
Limit output QUIC packets with client max_packet_size.
Roman Arutyunyan <arut@nginx.com>
parents:
7729
diff
changeset
|
1886 b.end = buf + sizeof(buf); |
7691 | 1887 b.pos = b.last = b.start; |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
1888 b.memory = 1; |
7677
6bc18966b8c1
Stream "connection" read/write methods.
Vladimir Homutov <vl@nginx.com>
parents:
7675
diff
changeset
|
1889 |
7691 | 1890 c = rev->data; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
1891 qc = ngx_quic_get_connection(c); |
7677
6bc18966b8c1
Stream "connection" read/write methods.
Vladimir Homutov <vl@nginx.com>
parents:
7675
diff
changeset
|
1892 |
8135
eacca87c476e
QUIC: updated c->log->action strings to reflect proper state.
Vladimir Homutov <vl@nginx.com>
parents:
8134
diff
changeset
|
1893 c->log->action = "handling quic input"; |
7678
e3c0b19a3a8a
Implemented ngx_quic_stream_send_chain() method.
Roman Arutyunyan <arut@nginx.com>
parents:
7677
diff
changeset
|
1894 |
7691 | 1895 if (rev->timedout) { |
7838 | 1896 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, |
1897 "quic client timed out"); | |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
1898 ngx_quic_close_connection(c, NGX_DONE); |
7691 | 1899 return; |
7678
e3c0b19a3a8a
Implemented ngx_quic_stream_send_chain() method.
Roman Arutyunyan <arut@nginx.com>
parents:
7677
diff
changeset
|
1900 } |
e3c0b19a3a8a
Implemented ngx_quic_stream_send_chain() method.
Roman Arutyunyan <arut@nginx.com>
parents:
7677
diff
changeset
|
1901 |
7691 | 1902 if (c->close) { |
7937
b9bce2c4fe33
Close QUIC connection with NO_ERROR on c->close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7934
diff
changeset
|
1903 qc->error_reason = "graceful shutdown"; |
b9bce2c4fe33
Close QUIC connection with NO_ERROR on c->close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7934
diff
changeset
|
1904 ngx_quic_close_connection(c, NGX_OK); |
7691 | 1905 return; |
1906 } | |
7686
7ada2feeac18
Added processing of CONNECTION CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7684
diff
changeset
|
1907 |
7691 | 1908 n = c->recv(c, b.start, b.end - b.start); |
7681 | 1909 |
7691 | 1910 if (n == NGX_AGAIN) { |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
1911 if (qc->closing) { |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
1912 ngx_quic_close_connection(c, NGX_OK); |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
1913 } |
7691 | 1914 return; |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1915 } |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1916 |
7691 | 1917 if (n == NGX_ERROR) { |
1918 c->read->eof = 1; | |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
1919 ngx_quic_close_connection(c, NGX_ERROR); |
7691 | 1920 return; |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1921 } |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1922 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1923 if (qc->tp.disable_active_migration) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1924 if (c->socklen != qc->socklen |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1925 || ngx_memcmp(c->sockaddr, qc->sockaddr, c->socklen) != 0) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1926 { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1927 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1928 "quic dropping packet from new address"); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1929 return; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1930 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1931 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
1932 |
7691 | 1933 b.last += n; |
7995
031918df51c0
QUIC: added anti-amplification limit.
Vladimir Homutov <vl@nginx.com>
parents:
7994
diff
changeset
|
1934 qc->received += n; |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1935 |
8101
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
1936 rc = ngx_quic_input(c, &b, NULL); |
8083
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
1937 |
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
1938 if (rc == NGX_ERROR) { |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
1939 ngx_quic_close_connection(c, NGX_ERROR); |
7691 | 1940 return; |
1941 } | |
7737
8e54a17dabee
Respect QUIC max_idle_timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
7736
diff
changeset
|
1942 |
8083
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
1943 if (rc == NGX_DECLINED) { |
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
1944 return; |
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
1945 } |
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
1946 |
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
1947 /* rc == NGX_OK */ |
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
1948 |
7737
8e54a17dabee
Respect QUIC max_idle_timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
7736
diff
changeset
|
1949 qc->send_timer_set = 0; |
8e54a17dabee
Respect QUIC max_idle_timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
7736
diff
changeset
|
1950 ngx_add_timer(rev, qc->tp.max_idle_timeout); |
8166
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
1951 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
1952 ngx_quic_connstate_dbg(c); |
7665
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1953 } |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1954 |
1297dc83a6b9
Generic payload handler for quic packets.
Vladimir Homutov <vl@nginx.com>
parents:
7664
diff
changeset
|
1955 |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
1956 static void |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
1957 ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc) |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
1958 { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
1959 ngx_pool_t *pool; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
1960 ngx_quic_connection_t *qc; |
7747
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
1961 |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
1962 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
1963 "quic ngx_quic_close_connection rc:%i", rc); |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
1964 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
1965 qc = ngx_quic_get_connection(c); |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
1966 |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
1967 if (qc == NULL) { |
8279 | 1968 if (rc == NGX_ERROR) { |
1969 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, | |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
1970 "quic close connection early error"); |
8279 | 1971 } |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
1972 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
1973 } else if (ngx_quic_close_quic(c, rc) == NGX_AGAIN) { |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
1974 return; |
7747
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
1975 } |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
1976 |
7691 | 1977 if (c->ssl) { |
1978 (void) ngx_ssl_shutdown(c); | |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
1979 } |
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
1980 |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
1981 if (c->read->timer_set) { |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
1982 ngx_del_timer(c->read); |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
1983 } |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
1984 |
7691 | 1985 #if (NGX_STAT_STUB) |
1986 (void) ngx_atomic_fetch_add(ngx_stat_active, -1); | |
1987 #endif | |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
1988 |
7691 | 1989 c->destroyed = 1; |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
1990 |
7691 | 1991 pool = c->pool; |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
1992 |
7691 | 1993 ngx_close_connection(c); |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
1994 |
7691 | 1995 ngx_destroy_pool(pool); |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
1996 } |
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
1997 |
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
1998 |
7659
4355efde26d8
Added functions to decrypt long packets.
Vladimir Homutov <vl@nginx.com>
parents:
7658
diff
changeset
|
1999 static ngx_int_t |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2000 ngx_quic_close_quic(ngx_connection_t *c, ngx_int_t rc) |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2001 { |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2002 ngx_uint_t i; |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2003 ngx_queue_t *q; |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2004 ngx_quic_send_ctx_t *ctx; |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2005 ngx_quic_server_id_t *sid; |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2006 ngx_quic_connection_t *qc; |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2007 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2008 qc = ngx_quic_get_connection(c); |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2009 |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2010 if (!qc->closing) { |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2011 |
7875
8bec0ac23cf9
Fixed retransmission of frames after closing connection.
Vladimir Homutov <vl@nginx.com>
parents:
7874
diff
changeset
|
2012 /* drop packets from retransmit queues, no ack is expected */ |
8bec0ac23cf9
Fixed retransmission of frames after closing connection.
Vladimir Homutov <vl@nginx.com>
parents:
7874
diff
changeset
|
2013 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { |
8236
e9bd4305e68b
QUIC: fixed send contexts cleanup.
Vladimir Homutov <vl@nginx.com>
parents:
8235
diff
changeset
|
2014 ngx_quic_free_frames(c, &qc->send_ctx[i].sent); |
7875
8bec0ac23cf9
Fixed retransmission of frames after closing connection.
Vladimir Homutov <vl@nginx.com>
parents:
7874
diff
changeset
|
2015 } |
8bec0ac23cf9
Fixed retransmission of frames after closing connection.
Vladimir Homutov <vl@nginx.com>
parents:
7874
diff
changeset
|
2016 |
7877
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2017 if (rc == NGX_DONE) { |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2018 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2019 /* |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2020 * 10.2. Idle Timeout |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2021 * |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2022 * If the idle timeout is enabled by either peer, a connection is |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2023 * silently closed and its state is discarded when it remains idle |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2024 */ |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2025 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2026 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2027 "quic closing %s connection", |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2028 qc->draining ? "drained" : "idle"); |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2029 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2030 } else { |
7877
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2031 |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2032 /* |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2033 * 10.3. Immediate Close |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2034 * |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2035 * An endpoint sends a CONNECTION_CLOSE frame (Section 19.19) |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2036 * to terminate the connection immediately. |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2037 */ |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2038 |
7993
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
2039 qc->error_level = c->ssl ? SSL_quic_read_level(c->ssl->connection) |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
2040 : ssl_encryption_initial; |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
2041 |
7877
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2042 if (rc == NGX_OK) { |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
2043 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
2044 "quic immediate close drain:%d", |
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
2045 qc->draining); |
7877
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2046 |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2047 qc->close.log = c->log; |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2048 qc->close.data = c; |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2049 qc->close.handler = ngx_quic_close_timer_handler; |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2050 qc->close.cancelable = 1; |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2051 |
7993
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
2052 ctx = ngx_quic_get_send_ctx(qc, qc->error_level); |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
2053 |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
2054 ngx_add_timer(&qc->close, 3 * ngx_quic_pto(c, ctx)); |
7877
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2055 |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2056 qc->error = NGX_QUIC_ERR_NO_ERROR; |
7877
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2057 |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2058 } else { |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2059 if (qc->error == 0 && !qc->error_app) { |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2060 qc->error = NGX_QUIC_ERR_INTERNAL_ERROR; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2061 } |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2062 |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2063 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
2064 "quic immediate close due to %s error: %ui %s", |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2065 qc->error_app ? "app " : "", qc->error, |
7877
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2066 qc->error_reason ? qc->error_reason : ""); |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2067 } |
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2068 |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2069 (void) ngx_quic_send_cc(c); |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2070 |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2071 if (qc->error_level == ssl_encryption_handshake) { |
7877
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2072 /* for clients that might not have handshake keys */ |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2073 qc->error_level = ssl_encryption_initial; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2074 (void) ngx_quic_send_cc(c); |
7877
d96ddef458cd
Added sending of extra CONNECTION_CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7876
diff
changeset
|
2075 } |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2076 } |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2077 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2078 qc->closing = 1; |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2079 } |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2080 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2081 if (rc == NGX_ERROR && qc->close.timer_set) { |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2082 /* do not wait for timer in case of fatal error */ |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2083 ngx_del_timer(&qc->close); |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2084 } |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2085 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2086 if (ngx_quic_close_streams(c, qc) == NGX_AGAIN) { |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2087 return NGX_AGAIN; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2088 } |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2089 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2090 if (qc->push.timer_set) { |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2091 ngx_del_timer(&qc->push); |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2092 } |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2093 |
7990 | 2094 if (qc->pto.timer_set) { |
2095 ngx_del_timer(&qc->pto); | |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2096 } |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2097 |
7929
ea4899591798
QUIC: Fixed connection cleanup.
Vladimir Homutov <vl@nginx.com>
parents:
7928
diff
changeset
|
2098 if (qc->push.posted) { |
ea4899591798
QUIC: Fixed connection cleanup.
Vladimir Homutov <vl@nginx.com>
parents:
7928
diff
changeset
|
2099 ngx_delete_posted_event(&qc->push); |
ea4899591798
QUIC: Fixed connection cleanup.
Vladimir Homutov <vl@nginx.com>
parents:
7928
diff
changeset
|
2100 } |
ea4899591798
QUIC: Fixed connection cleanup.
Vladimir Homutov <vl@nginx.com>
parents:
7928
diff
changeset
|
2101 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2102 while (!ngx_queue_empty(&qc->server_ids)) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2103 q = ngx_queue_head(&qc->server_ids); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2104 sid = ngx_queue_data(q, ngx_quic_server_id_t, queue); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2105 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2106 ngx_queue_remove(q); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2107 ngx_rbtree_delete(&c->listening->rbtree, &sid->udp.node); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2108 qc->nserver_ids--; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2109 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2110 |
8091
dbcb9d0a3df1
QUIC: prevented posted push event while in the draining state.
Vladimir Homutov <vl@nginx.com>
parents:
8084
diff
changeset
|
2111 if (qc->close.timer_set) { |
dbcb9d0a3df1
QUIC: prevented posted push event while in the draining state.
Vladimir Homutov <vl@nginx.com>
parents:
8084
diff
changeset
|
2112 return NGX_AGAIN; |
dbcb9d0a3df1
QUIC: prevented posted push event while in the draining state.
Vladimir Homutov <vl@nginx.com>
parents:
8084
diff
changeset
|
2113 } |
dbcb9d0a3df1
QUIC: prevented posted push event while in the draining state.
Vladimir Homutov <vl@nginx.com>
parents:
8084
diff
changeset
|
2114 |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2115 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2116 "quic part of connection is terminated"); |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2117 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2118 /* may be tested from SSL callback during SSL shutdown */ |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2119 c->udp = NULL; |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2120 |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2121 return NGX_OK; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2122 } |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2123 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2124 |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2125 void |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2126 ngx_quic_finalize_connection(ngx_connection_t *c, ngx_uint_t err, |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2127 const char *reason) |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2128 { |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2129 ngx_quic_connection_t *qc; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2130 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2131 qc = ngx_quic_get_connection(c); |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2132 qc->error = err; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2133 qc->error_reason = reason; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2134 qc->error_app = 1; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2135 qc->error_ftype = 0; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2136 |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2137 ngx_quic_close_connection(c, NGX_ERROR); |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2138 } |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2139 |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2140 |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2141 static void |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2142 ngx_quic_close_timer_handler(ngx_event_t *ev) |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2143 { |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2144 ngx_connection_t *c; |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2145 |
7836 | 2146 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic close timer"); |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2147 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2148 c = ev->data; |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2149 ngx_quic_close_connection(c, NGX_DONE); |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2150 } |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2151 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2152 |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2153 static ngx_int_t |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2154 ngx_quic_close_streams(ngx_connection_t *c, ngx_quic_connection_t *qc) |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2155 { |
8021
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
2156 ngx_event_t *rev, *wev; |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2157 ngx_rbtree_t *tree; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2158 ngx_rbtree_node_t *node; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2159 ngx_quic_stream_t *qs; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2160 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2161 #if (NGX_DEBUG) |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2162 ngx_uint_t ns; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2163 #endif |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2164 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2165 tree = &qc->streams.tree; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2166 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2167 if (tree->root == tree->sentinel) { |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2168 return NGX_OK; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2169 } |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2170 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2171 #if (NGX_DEBUG) |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2172 ns = 0; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2173 #endif |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2174 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2175 for (node = ngx_rbtree_min(tree->root, tree->sentinel); |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2176 node; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2177 node = ngx_rbtree_next(tree, node)) |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2178 { |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2179 qs = (ngx_quic_stream_t *) node; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2180 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2181 rev = qs->c->read; |
8021
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
2182 rev->error = 1; |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2183 rev->ready = 1; |
8021
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
2184 |
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
2185 wev = qs->c->write; |
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
2186 wev->error = 1; |
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
2187 wev->ready = 1; |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2188 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2189 ngx_post_event(rev, &ngx_posted_events); |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2190 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2191 if (rev->timer_set) { |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2192 ngx_del_timer(rev); |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2193 } |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2194 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2195 #if (NGX_DEBUG) |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2196 ns++; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2197 #endif |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2198 } |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2199 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2200 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2201 "quic connection has %ui active streams", ns); |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2202 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2203 return NGX_AGAIN; |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2204 } |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2205 |
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2206 |
8296
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2207 ngx_int_t |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2208 ngx_quic_reset_stream(ngx_connection_t *c, ngx_uint_t err) |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2209 { |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2210 ngx_event_t *wev; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2211 ngx_connection_t *pc; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2212 ngx_quic_frame_t *frame; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2213 ngx_quic_stream_t *qs; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2214 ngx_quic_connection_t *qc; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2215 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2216 qs = c->quic; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2217 pc = qs->parent; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2218 qc = ngx_quic_get_connection(pc); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2219 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2220 frame = ngx_quic_alloc_frame(pc); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2221 if (frame == NULL) { |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2222 return NGX_ERROR; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2223 } |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2224 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2225 frame->level = ssl_encryption_application; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2226 frame->type = NGX_QUIC_FT_RESET_STREAM; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2227 frame->u.reset_stream.id = qs->id; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2228 frame->u.reset_stream.error_code = err; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2229 frame->u.reset_stream.final_size = c->sent; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2230 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2231 ngx_quic_queue_frame(qc, frame); |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2232 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2233 wev = c->write; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2234 wev->error = 1; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2235 wev->ready = 1; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2236 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2237 return NGX_OK; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2238 } |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2239 |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
2240 |
7831
d11bc25fc4c3
Refactored ngx_quic_close_connection().
Vladimir Homutov <vl@nginx.com>
parents:
7827
diff
changeset
|
2241 static ngx_int_t |
8101
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
2242 ngx_quic_input(ngx_connection_t *c, ngx_buf_t *b, ngx_quic_conf_t *conf) |
7659
4355efde26d8
Added functions to decrypt long packets.
Vladimir Homutov <vl@nginx.com>
parents:
7658
diff
changeset
|
2243 { |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2244 u_char *p; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2245 ngx_int_t rc; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2246 ngx_uint_t good; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2247 ngx_quic_header_t pkt; |
7659
4355efde26d8
Added functions to decrypt long packets.
Vladimir Homutov <vl@nginx.com>
parents:
7658
diff
changeset
|
2248 |
8083
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
2249 good = 0; |
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
2250 |
7770
90f94413177e
TLS Early Data support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7769
diff
changeset
|
2251 p = b->pos; |
7674
4ae9ac69ab93
HTTP/QUIC interface reworked.
Vladimir Homutov <vl@nginx.com>
parents:
7673
diff
changeset
|
2252 |
7770
90f94413177e
TLS Early Data support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7769
diff
changeset
|
2253 while (p < b->last) { |
7729
1295b293d09a
Connection states code cleanup.
Vladimir Homutov <vl@nginx.com>
parents:
7726
diff
changeset
|
2254 |
7691 | 2255 ngx_memzero(&pkt, sizeof(ngx_quic_header_t)); |
2256 pkt.raw = b; | |
2257 pkt.data = p; | |
2258 pkt.len = b->last - p; | |
2259 pkt.log = c->log; | |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
2260 pkt.flags = p[0]; |
8097
a89a58c642ef
QUIC: simplified packet header parsing.
Vladimir Homutov <vl@nginx.com>
parents:
8096
diff
changeset
|
2261 pkt.raw->pos++; |
7659
4355efde26d8
Added functions to decrypt long packets.
Vladimir Homutov <vl@nginx.com>
parents:
7658
diff
changeset
|
2262 |
8101
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
2263 rc = ngx_quic_process_packet(c, conf, &pkt); |
7659
4355efde26d8
Added functions to decrypt long packets.
Vladimir Homutov <vl@nginx.com>
parents:
7658
diff
changeset
|
2264 |
8139
07971f870879
QUIC: added debug message with final packet processing status.
Vladimir Homutov <vl@nginx.com>
parents:
8138
diff
changeset
|
2265 #if (NGX_DEBUG) |
07971f870879
QUIC: added debug message with final packet processing status.
Vladimir Homutov <vl@nginx.com>
parents:
8138
diff
changeset
|
2266 if (pkt.parsed) { |
8166
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
2267 ngx_log_debug5(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8168
f32740ddd484
QUIC: got rid of "pkt" abbreviation in logs.
Vladimir Homutov <vl@nginx.com>
parents:
8167
diff
changeset
|
2268 "quic packet %s done decr:%d pn:%L perr:%ui rc:%i", |
8139
07971f870879
QUIC: added debug message with final packet processing status.
Vladimir Homutov <vl@nginx.com>
parents:
8138
diff
changeset
|
2269 ngx_quic_level_name(pkt.level), pkt.decrypted, |
8166
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
2270 pkt.pn, pkt.error, rc); |
8139
07971f870879
QUIC: added debug message with final packet processing status.
Vladimir Homutov <vl@nginx.com>
parents:
8138
diff
changeset
|
2271 } else { |
07971f870879
QUIC: added debug message with final packet processing status.
Vladimir Homutov <vl@nginx.com>
parents:
8138
diff
changeset
|
2272 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8168
f32740ddd484
QUIC: got rid of "pkt" abbreviation in logs.
Vladimir Homutov <vl@nginx.com>
parents:
8167
diff
changeset
|
2273 "quic packet done parse failed rc:%i", rc); |
8139
07971f870879
QUIC: added debug message with final packet processing status.
Vladimir Homutov <vl@nginx.com>
parents:
8138
diff
changeset
|
2274 } |
07971f870879
QUIC: added debug message with final packet processing status.
Vladimir Homutov <vl@nginx.com>
parents:
8138
diff
changeset
|
2275 #endif |
07971f870879
QUIC: added debug message with final packet processing status.
Vladimir Homutov <vl@nginx.com>
parents:
8138
diff
changeset
|
2276 |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2277 if (rc == NGX_ERROR) { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2278 return NGX_ERROR; |
7691 | 2279 } |
7672
8d6ac639feac
Added support of multiple QUIC packets in single datagram.
Vladimir Homutov <vl@nginx.com>
parents:
7671
diff
changeset
|
2280 |
8279 | 2281 if (rc == NGX_DONE) { |
2282 /* stop further processing */ | |
2283 return NGX_DECLINED; | |
2284 } | |
2285 | |
8083
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
2286 if (rc == NGX_OK) { |
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
2287 good = 1; |
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
2288 } |
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
2289 |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2290 /* NGX_OK || NGX_DECLINED */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2291 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2292 /* |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2293 * we get NGX_DECLINED when there are no keys [yet] available |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2294 * to decrypt packet. |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2295 * Instead of queueing it, we ignore it and rely on the sender's |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2296 * retransmission: |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2297 * |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2298 * 12.2. Coalescing Packets: |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2299 * |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2300 * For example, if decryption fails (because the keys are |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2301 * not available or any other reason), the receiver MAY either |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2302 * discard or buffer the packet for later processing and MUST |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2303 * attempt to process the remaining packets. |
8073
eb5aa85294e9
QUIC: discard unrecognized long packes.
Vladimir Homutov <vl@nginx.com>
parents:
8071
diff
changeset
|
2304 * |
eb5aa85294e9
QUIC: discard unrecognized long packes.
Vladimir Homutov <vl@nginx.com>
parents:
8071
diff
changeset
|
2305 * We also skip packets that don't match connection state |
eb5aa85294e9
QUIC: discard unrecognized long packes.
Vladimir Homutov <vl@nginx.com>
parents:
8071
diff
changeset
|
2306 * or cannot be parsed properly. |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2307 */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2308 |
7691 | 2309 /* b->pos is at header end, adjust by actual packet length */ |
8096
0f37b4ef3cd9
QUIC: keep the entire packet size in pkt->len.
Roman Arutyunyan <arut@nginx.com>
parents:
8095
diff
changeset
|
2310 b->pos = pkt.data + pkt.len; |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2311 |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2312 /* firefox workaround: skip zero padding at the end of quic packet */ |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2313 while (b->pos < b->last && *(b->pos) == 0) { |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2314 b->pos++; |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2315 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2316 |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2317 p = b->pos; |
7770
90f94413177e
TLS Early Data support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7769
diff
changeset
|
2318 } |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
2319 |
8083
702f1d2581a4
QUIC: eliminated idle timeout restart for dropped packets.
Roman Arutyunyan <arut@nginx.com>
parents:
8079
diff
changeset
|
2320 return good ? NGX_OK : NGX_DECLINED; |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
2321 } |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
2322 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
2323 |
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
2324 static ngx_int_t |
8101
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
2325 ngx_quic_process_packet(ngx_connection_t *c, ngx_quic_conf_t *conf, |
bed310672f39
QUIC: moved ssl configuration pointer to quic configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8100
diff
changeset
|
2326 ngx_quic_header_t *pkt) |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
2327 { |
8074
c6b963de0c00
QUIC: pass return code from ngx_quic_decrypt() to the caller.
Vladimir Homutov <vl@nginx.com>
parents:
8073
diff
changeset
|
2328 ngx_int_t rc; |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
2329 ngx_quic_connection_t *qc; |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2330 |
8135
eacca87c476e
QUIC: updated c->log->action strings to reflect proper state.
Vladimir Homutov <vl@nginx.com>
parents:
8134
diff
changeset
|
2331 c->log->action = "parsing quic packet"; |
eacca87c476e
QUIC: updated c->log->action strings to reflect proper state.
Vladimir Homutov <vl@nginx.com>
parents:
8134
diff
changeset
|
2332 |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2333 rc = ngx_quic_parse_packet(pkt); |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2334 |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2335 if (rc == NGX_DECLINED || rc == NGX_ERROR) { |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2336 return rc; |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
2337 } |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
2338 |
8139
07971f870879
QUIC: added debug message with final packet processing status.
Vladimir Homutov <vl@nginx.com>
parents:
8138
diff
changeset
|
2339 pkt->parsed = 1; |
07971f870879
QUIC: added debug message with final packet processing status.
Vladimir Homutov <vl@nginx.com>
parents:
8138
diff
changeset
|
2340 |
8135
eacca87c476e
QUIC: updated c->log->action strings to reflect proper state.
Vladimir Homutov <vl@nginx.com>
parents:
8134
diff
changeset
|
2341 c->log->action = "processing quic packet"; |
eacca87c476e
QUIC: updated c->log->action strings to reflect proper state.
Vladimir Homutov <vl@nginx.com>
parents:
8134
diff
changeset
|
2342 |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
2343 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
2344 "quic packet rx dcid len:%uz %xV", |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
2345 pkt->dcid.len, &pkt->dcid); |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
2346 |
8137
52ad697f9d1c
QUIC: enabled more key-related debug by default.
Vladimir Homutov <vl@nginx.com>
parents:
8136
diff
changeset
|
2347 #if (NGX_DEBUG) |
52ad697f9d1c
QUIC: enabled more key-related debug by default.
Vladimir Homutov <vl@nginx.com>
parents:
8136
diff
changeset
|
2348 if (pkt->level != ssl_encryption_application) { |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
2349 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
2350 "quic packet rx scid len:%uz %xV", |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
2351 pkt->scid.len, &pkt->scid); |
8137
52ad697f9d1c
QUIC: enabled more key-related debug by default.
Vladimir Homutov <vl@nginx.com>
parents:
8136
diff
changeset
|
2352 } |
8211
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8209
diff
changeset
|
2353 |
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8209
diff
changeset
|
2354 if (pkt->level == ssl_encryption_initial) { |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
2355 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8287
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
2356 "quic address validation token len:%uz %xV", |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
2357 pkt->token.len, &pkt->token); |
8211
fe53def49945
QUIC: refactored long header parsing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8209
diff
changeset
|
2358 } |
8137
52ad697f9d1c
QUIC: enabled more key-related debug by default.
Vladimir Homutov <vl@nginx.com>
parents:
8136
diff
changeset
|
2359 #endif |
52ad697f9d1c
QUIC: enabled more key-related debug by default.
Vladimir Homutov <vl@nginx.com>
parents:
8136
diff
changeset
|
2360 |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2361 qc = ngx_quic_get_connection(c); |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2362 |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2363 if (qc) { |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2364 |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2365 if (rc == NGX_ABORT) { |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2366 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2367 "quic unsupported version: 0x%xD", pkt->version); |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2368 return NGX_DECLINED; |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2369 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2370 |
8194
340cd26158fb
QUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8193
diff
changeset
|
2371 if (pkt->level != ssl_encryption_application) { |
8281
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2372 |
8194
340cd26158fb
QUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8193
diff
changeset
|
2373 if (pkt->version != qc->version) { |
340cd26158fb
QUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8193
diff
changeset
|
2374 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
340cd26158fb
QUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8193
diff
changeset
|
2375 "quic version mismatch: 0x%xD", pkt->version); |
340cd26158fb
QUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8193
diff
changeset
|
2376 return NGX_DECLINED; |
340cd26158fb
QUIC: preparatory changes for multiple QUIC versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8193
diff
changeset
|
2377 } |
8281
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2378 |
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2379 if (ngx_quic_check_csid(qc, pkt) != NGX_OK) { |
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2380 return NGX_DECLINED; |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
2381 } |
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
2382 |
8281
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2383 } else { |
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2384 |
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2385 if (ngx_quic_process_stateless_reset(c, pkt) == NGX_OK) { |
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2386 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2387 "quic stateless reset packet detected"); |
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2388 |
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2389 qc->draining = 1; |
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2390 ngx_quic_close_connection(c, NGX_OK); |
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2391 |
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2392 return NGX_OK; |
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2393 } |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2394 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2395 |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2396 return ngx_quic_process_payload(c, pkt); |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2397 } |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2398 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2399 /* packet does not belong to a connection */ |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2400 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2401 if (rc == NGX_ABORT) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2402 return ngx_quic_negotiate_version(c, pkt); |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2403 } |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2404 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2405 if (pkt->level == ssl_encryption_application) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2406 return ngx_quic_send_stateless_reset(c, conf, pkt); |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2407 } |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2408 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2409 if (pkt->level != ssl_encryption_initial) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2410 return NGX_ERROR; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2411 } |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2412 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2413 c->log->action = "processing initial packet"; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2414 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2415 if (pkt->dcid.len < NGX_QUIC_CID_LEN_MIN) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2416 /* 7.2. Negotiating Connection IDs */ |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2417 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2418 "quic too short dcid in initial" |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2419 " packet: len:%i", pkt->dcid.len); |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2420 return NGX_ERROR; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2421 } |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2422 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2423 /* process retry and initialize connection IDs */ |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2424 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2425 if (pkt->token.len) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2426 |
8287
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
2427 rc = ngx_quic_validate_token(c, conf->av_token_key, pkt); |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2428 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2429 if (rc == NGX_ERROR) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2430 /* internal error */ |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2431 return NGX_ERROR; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2432 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2433 } else if (rc == NGX_ABORT) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2434 /* token cannot be decrypted */ |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2435 return ngx_quic_send_early_cc(c, pkt, |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2436 NGX_QUIC_ERR_INVALID_TOKEN, |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2437 "cannot decrypt token"); |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2438 } else if (rc == NGX_DECLINED) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2439 /* token is invalid */ |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2440 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2441 if (pkt->retried) { |
8287
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
2442 /* invalid address validation token */ |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2443 return ngx_quic_send_early_cc(c, pkt, |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2444 NGX_QUIC_ERR_INVALID_TOKEN, |
8287
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
2445 "invalid address validation token"); |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2446 } else if (conf->retry) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2447 /* invalid NEW_TOKEN */ |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2448 return ngx_quic_send_retry(c, conf, pkt); |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2449 } |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2450 } |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2451 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2452 /* NGX_OK */ |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2453 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2454 } else if (conf->retry) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2455 return ngx_quic_send_retry(c, conf, pkt); |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2456 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2457 } else { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2458 pkt->odcid = pkt->dcid; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2459 } |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2460 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2461 if (ngx_terminate || ngx_exiting) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2462 if (conf->retry) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2463 return ngx_quic_send_retry(c, conf, pkt); |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2464 } |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2465 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2466 return NGX_ERROR; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2467 } |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2468 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2469 c->log->action = "creating quic connection"; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2470 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2471 qc = ngx_quic_new_connection(c, conf, pkt); |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2472 if (qc == NULL) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2473 return NGX_ERROR; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2474 } |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2475 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2476 return ngx_quic_process_payload(c, pkt); |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2477 } |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2478 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2479 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2480 static ngx_int_t |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2481 ngx_quic_process_payload(ngx_connection_t *c, ngx_quic_header_t *pkt) |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2482 { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2483 ngx_int_t rc; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2484 ngx_quic_send_ctx_t *ctx; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2485 ngx_quic_connection_t *qc; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2486 static u_char buf[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2487 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2488 qc = ngx_quic_get_connection(c); |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2489 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2490 qc->error = 0; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2491 qc->error_reason = 0; |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2492 |
8135
eacca87c476e
QUIC: updated c->log->action strings to reflect proper state.
Vladimir Homutov <vl@nginx.com>
parents:
8134
diff
changeset
|
2493 c->log->action = "decrypting packet"; |
eacca87c476e
QUIC: updated c->log->action strings to reflect proper state.
Vladimir Homutov <vl@nginx.com>
parents:
8134
diff
changeset
|
2494 |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2495 if (!ngx_quic_keys_available(qc->keys, pkt->level)) { |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2496 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2497 "quic no level %d keys yet, ignoring packet", pkt->level); |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2498 return NGX_DECLINED; |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2499 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2500 |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2501 pkt->keys = qc->keys; |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2502 pkt->key_phase = qc->key_phase; |
7860
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
2503 pkt->plaintext = buf; |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
2504 |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
2505 ctx = ngx_quic_get_send_ctx(qc, pkt->level); |
7ea34e13937f
Address validation using Retry packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7859
diff
changeset
|
2506 |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2507 rc = ngx_quic_decrypt(pkt, &ctx->largest_pn); |
8074
c6b963de0c00
QUIC: pass return code from ngx_quic_decrypt() to the caller.
Vladimir Homutov <vl@nginx.com>
parents:
8073
diff
changeset
|
2508 if (rc != NGX_OK) { |
c6b963de0c00
QUIC: pass return code from ngx_quic_decrypt() to the caller.
Vladimir Homutov <vl@nginx.com>
parents:
8073
diff
changeset
|
2509 qc->error = pkt->error; |
c6b963de0c00
QUIC: pass return code from ngx_quic_decrypt() to the caller.
Vladimir Homutov <vl@nginx.com>
parents:
8073
diff
changeset
|
2510 qc->error_reason = "failed to decrypt packet"; |
c6b963de0c00
QUIC: pass return code from ngx_quic_decrypt() to the caller.
Vladimir Homutov <vl@nginx.com>
parents:
8073
diff
changeset
|
2511 return rc; |
7689 | 2512 } |
2513 | |
8139
07971f870879
QUIC: added debug message with final packet processing status.
Vladimir Homutov <vl@nginx.com>
parents:
8138
diff
changeset
|
2514 pkt->decrypted = 1; |
07971f870879
QUIC: added debug message with final packet processing status.
Vladimir Homutov <vl@nginx.com>
parents:
8138
diff
changeset
|
2515 |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2516 if (c->ssl == NULL) { |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2517 if (ngx_quic_init_connection(c) != NGX_OK) { |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2518 return NGX_ERROR; |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2519 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2520 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2521 |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2522 if (pkt->level == ssl_encryption_handshake) { |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2523 /* |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2524 * 4.10.1. The successful use of Handshake packets indicates |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2525 * that no more Initial packets need to be exchanged |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2526 */ |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2527 ngx_quic_discard_ctx(c, ssl_encryption_initial); |
8170
e2086d8181fa
QUIC: added push event afer the address was validated.
Vladimir Homutov <vl@nginx.com>
parents:
8169
diff
changeset
|
2528 |
e2086d8181fa
QUIC: added push event afer the address was validated.
Vladimir Homutov <vl@nginx.com>
parents:
8169
diff
changeset
|
2529 if (qc->validated == 0) { |
e2086d8181fa
QUIC: added push event afer the address was validated.
Vladimir Homutov <vl@nginx.com>
parents:
8169
diff
changeset
|
2530 qc->validated = 1; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2531 ngx_post_event(&qc->push, &ngx_posted_events); |
8170
e2086d8181fa
QUIC: added push event afer the address was validated.
Vladimir Homutov <vl@nginx.com>
parents:
8169
diff
changeset
|
2532 } |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2533 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2534 |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2535 if (qc->closing) { |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2536 /* |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2537 * 10.1 Closing and Draining Connection States |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2538 * ... delayed or reordered packets are properly discarded. |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2539 * |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2540 * An endpoint retains only enough information to generate |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2541 * a packet containing a CONNECTION_CLOSE frame and to identify |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2542 * packets as belonging to the connection. |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2543 */ |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2544 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2545 qc->error_level = pkt->level; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2546 qc->error = NGX_QUIC_ERR_NO_ERROR; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2547 qc->error_reason = "connection is closing, packet discarded"; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2548 qc->error_ftype = 0; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2549 qc->error_app = 0; |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2550 |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2551 return ngx_quic_send_cc(c); |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2552 } |
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2553 |
8162
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
2554 pkt->received = ngx_current_msec; |
8133
1d4417e4f2d0
QUIC: fixed measuring ACK Delay against 0-RTT packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8132
diff
changeset
|
2555 |
8135
eacca87c476e
QUIC: updated c->log->action strings to reflect proper state.
Vladimir Homutov <vl@nginx.com>
parents:
8134
diff
changeset
|
2556 c->log->action = "handling payload"; |
eacca87c476e
QUIC: updated c->log->action strings to reflect proper state.
Vladimir Homutov <vl@nginx.com>
parents:
8134
diff
changeset
|
2557 |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2558 if (pkt->level != ssl_encryption_application) { |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2559 return ngx_quic_handle_frames(c, pkt); |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2560 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2561 |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2562 if (!pkt->key_update) { |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2563 return ngx_quic_handle_frames(c, pkt); |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2564 } |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2565 |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2566 /* switch keys and generate next on Key Phase change */ |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2567 |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2568 qc->key_phase ^= 1; |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2569 ngx_quic_keys_switch(c, qc->keys); |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2570 |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2571 rc = ngx_quic_handle_frames(c, pkt); |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2572 if (rc != NGX_OK) { |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2573 return rc; |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2574 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2575 |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2576 return ngx_quic_keys_update(c, qc->keys); |
7689 | 2577 } |
2578 | |
2579 | |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2580 static ngx_int_t |
8279 | 2581 ngx_quic_send_early_cc(ngx_connection_t *c, ngx_quic_header_t *inpkt, |
2582 ngx_uint_t err, const char *reason) | |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2583 { |
8279 | 2584 ssize_t len; |
2585 ngx_str_t res; | |
2586 ngx_quic_frame_t frame; | |
2587 ngx_quic_header_t pkt; | |
2588 | |
2589 static u_char src[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; | |
2590 static u_char dst[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; | |
2591 | |
2592 ngx_memzero(&frame, sizeof(ngx_quic_frame_t)); | |
2593 ngx_memzero(&pkt, sizeof(ngx_quic_header_t)); | |
2594 | |
2595 frame.level = inpkt->level; | |
2596 frame.type = NGX_QUIC_FT_CONNECTION_CLOSE; | |
2597 frame.u.close.error_code = err; | |
2598 | |
2599 frame.u.close.reason.data = (u_char *) reason; | |
2600 frame.u.close.reason.len = ngx_strlen(reason); | |
2601 | |
2602 len = ngx_quic_create_frame(NULL, &frame); | |
2603 if (len > NGX_QUIC_MAX_UDP_PAYLOAD_SIZE) { | |
2604 return NGX_ERROR; | |
2605 } | |
2606 | |
2607 ngx_quic_log_frame(c->log, &frame, 1); | |
2608 | |
2609 len = ngx_quic_create_frame(src, &frame); | |
2610 if (len == -1) { | |
2611 return NGX_ERROR; | |
2612 } | |
2613 | |
2614 pkt.keys = ngx_quic_keys_new(c->pool); | |
2615 if (pkt.keys == NULL) { | |
2616 return NGX_ERROR; | |
2617 } | |
2618 | |
8322
44b4c6180106
QUIC: multiple versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8321
diff
changeset
|
2619 if (ngx_quic_keys_set_initial_secret(c->pool, pkt.keys, &inpkt->dcid, |
44b4c6180106
QUIC: multiple versions support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8321
diff
changeset
|
2620 inpkt->version) |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2621 != NGX_OK) |
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2622 { |
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2623 return NGX_ERROR; |
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2624 } |
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2625 |
8279 | 2626 pkt.flags = NGX_QUIC_PKT_FIXED_BIT | NGX_QUIC_PKT_LONG |
2627 | NGX_QUIC_PKT_INITIAL; | |
2628 | |
2629 pkt.num_len = 1; | |
2630 /* | |
2631 * pkt.num = 0; | |
2632 * pkt.trunc = 0; | |
2633 */ | |
2634 | |
2635 pkt.version = inpkt->version; | |
2636 pkt.log = c->log; | |
2637 pkt.level = inpkt->level; | |
2638 pkt.dcid = inpkt->scid; | |
2639 pkt.scid = inpkt->dcid; | |
2640 pkt.payload.data = src; | |
2641 pkt.payload.len = len; | |
2642 | |
2643 res.data = dst; | |
2644 | |
2645 if (ngx_quic_encrypt(&pkt, &res) != NGX_OK) { | |
2646 return NGX_ERROR; | |
2647 } | |
2648 | |
2649 if (ngx_quic_send(c, res.data, res.len) == NGX_ERROR) { | |
2650 return NGX_ERROR; | |
2651 } | |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2652 |
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2653 return NGX_OK; |
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2654 } |
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2655 |
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
2656 |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2657 static void |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2658 ngx_quic_discard_ctx(ngx_connection_t *c, enum ssl_encryption_level_t level) |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
2659 { |
8025
7f9938cbcd12
QUIC: fixed leak of bytes_in_flight on keys discard.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8024
diff
changeset
|
2660 ngx_queue_t *q; |
7f9938cbcd12
QUIC: fixed leak of bytes_in_flight on keys discard.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8024
diff
changeset
|
2661 ngx_quic_frame_t *f; |
7816
aba84d9ab256
Parsing of truncated packet numbers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7815
diff
changeset
|
2662 ngx_quic_send_ctx_t *ctx; |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
2663 ngx_quic_connection_t *qc; |
7729
1295b293d09a
Connection states code cleanup.
Vladimir Homutov <vl@nginx.com>
parents:
7726
diff
changeset
|
2664 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2665 qc = ngx_quic_get_connection(c); |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
2666 |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2667 if (!ngx_quic_keys_available(qc->keys, level)) { |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2668 return; |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2669 } |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2670 |
8191
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2671 ngx_quic_keys_discard(qc->keys, level); |
9c3be23ddbe7
QUIC: refactored key handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8190
diff
changeset
|
2672 |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2673 qc->pto_count = 0; |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2674 |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2675 ctx = ngx_quic_get_send_ctx(qc, level); |
8025
7f9938cbcd12
QUIC: fixed leak of bytes_in_flight on keys discard.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8024
diff
changeset
|
2676 |
7f9938cbcd12
QUIC: fixed leak of bytes_in_flight on keys discard.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8024
diff
changeset
|
2677 while (!ngx_queue_empty(&ctx->sent)) { |
7f9938cbcd12
QUIC: fixed leak of bytes_in_flight on keys discard.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8024
diff
changeset
|
2678 q = ngx_queue_head(&ctx->sent); |
7f9938cbcd12
QUIC: fixed leak of bytes_in_flight on keys discard.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8024
diff
changeset
|
2679 ngx_queue_remove(q); |
7f9938cbcd12
QUIC: fixed leak of bytes_in_flight on keys discard.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8024
diff
changeset
|
2680 |
7f9938cbcd12
QUIC: fixed leak of bytes_in_flight on keys discard.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8024
diff
changeset
|
2681 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
7f9938cbcd12
QUIC: fixed leak of bytes_in_flight on keys discard.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8024
diff
changeset
|
2682 ngx_quic_congestion_ack(c, f); |
7f9938cbcd12
QUIC: fixed leak of bytes_in_flight on keys discard.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8024
diff
changeset
|
2683 ngx_quic_free_frame(c, f); |
7f9938cbcd12
QUIC: fixed leak of bytes_in_flight on keys discard.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8024
diff
changeset
|
2684 } |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2685 |
8171
b1676cd64dc9
QUIC: cleanup send context properly.
Vladimir Homutov <vl@nginx.com>
parents:
8170
diff
changeset
|
2686 while (!ngx_queue_empty(&ctx->frames)) { |
b1676cd64dc9
QUIC: cleanup send context properly.
Vladimir Homutov <vl@nginx.com>
parents:
8170
diff
changeset
|
2687 q = ngx_queue_head(&ctx->frames); |
b1676cd64dc9
QUIC: cleanup send context properly.
Vladimir Homutov <vl@nginx.com>
parents:
8170
diff
changeset
|
2688 ngx_queue_remove(q); |
b1676cd64dc9
QUIC: cleanup send context properly.
Vladimir Homutov <vl@nginx.com>
parents:
8170
diff
changeset
|
2689 |
b1676cd64dc9
QUIC: cleanup send context properly.
Vladimir Homutov <vl@nginx.com>
parents:
8170
diff
changeset
|
2690 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
b1676cd64dc9
QUIC: cleanup send context properly.
Vladimir Homutov <vl@nginx.com>
parents:
8170
diff
changeset
|
2691 ngx_quic_congestion_ack(c, f); |
b1676cd64dc9
QUIC: cleanup send context properly.
Vladimir Homutov <vl@nginx.com>
parents:
8170
diff
changeset
|
2692 ngx_quic_free_frame(c, f); |
b1676cd64dc9
QUIC: cleanup send context properly.
Vladimir Homutov <vl@nginx.com>
parents:
8170
diff
changeset
|
2693 } |
b1676cd64dc9
QUIC: cleanup send context properly.
Vladimir Homutov <vl@nginx.com>
parents:
8170
diff
changeset
|
2694 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2695 if (level == ssl_encryption_initial) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2696 ngx_quic_clear_temp_server_ids(c); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2697 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2698 |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2699 ctx->send_ack = 0; |
8290
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
2700 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
2701 ngx_quic_set_lost_timer(c); |
7770
90f94413177e
TLS Early Data support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7769
diff
changeset
|
2702 } |
90f94413177e
TLS Early Data support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7769
diff
changeset
|
2703 |
90f94413177e
TLS Early Data support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7769
diff
changeset
|
2704 |
90f94413177e
TLS Early Data support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7769
diff
changeset
|
2705 static ngx_int_t |
8281
a346905c359f
QUIC: fixed stateless reset recognition and send.
Roman Arutyunyan <arut@nginx.com>
parents:
8280
diff
changeset
|
2706 ngx_quic_check_csid(ngx_quic_connection_t *qc, ngx_quic_header_t *pkt) |
7838 | 2707 { |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2708 ngx_queue_t *q; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2709 ngx_quic_client_id_t *cid; |
7858
6e100d8c138a
Preserve original DCID and unbreak parsing 0-RTT packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7857
diff
changeset
|
2710 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2711 for (q = ngx_queue_head(&qc->client_ids); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2712 q != ngx_queue_sentinel(&qc->client_ids); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2713 q = ngx_queue_next(q)) |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2714 { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2715 cid = ngx_queue_data(q, ngx_quic_client_id_t, queue); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2716 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2717 if (pkt->scid.len == cid->len |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2718 && ngx_memcmp(pkt->scid.data, cid->id, cid->len) == 0) |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2719 { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2720 return NGX_OK; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2721 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2722 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2723 |
8098
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2724 ngx_log_error(NGX_LOG_INFO, pkt->log, 0, "quic unexpected quic scid"); |
d0d3fc0697a0
QUIC: packet processing refactoring.
Vladimir Homutov <vl@nginx.com>
parents:
8097
diff
changeset
|
2725 return NGX_ERROR; |
7648
b28ea685a56e
Moved all QUIC code into ngx_event_quic.c
Vladimir Homutov <vl@nginx.com>
parents:
7646
diff
changeset
|
2726 } |
7637 | 2727 |
2728 | |
7691 | 2729 static ngx_int_t |
8280
1c6343bd7933
QUIC: refactored packet processing.
Roman Arutyunyan <arut@nginx.com>
parents:
8279
diff
changeset
|
2730 ngx_quic_handle_frames(ngx_connection_t *c, ngx_quic_header_t *pkt) |
7691 | 2731 { |
2732 u_char *end, *p; | |
2733 ssize_t len; | |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
2734 ngx_buf_t buf; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2735 ngx_uint_t do_close; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
2736 ngx_chain_t chain; |
7844
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2737 ngx_quic_frame_t frame; |
7691 | 2738 ngx_quic_connection_t *qc; |
2739 | |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2740 qc = ngx_quic_get_connection(c); |
7691 | 2741 |
2742 p = pkt->payload.data; | |
2743 end = p + pkt->payload.len; | |
2744 | |
2745 do_close = 0; | |
2746 | |
2747 while (p < end) { | |
2748 | |
7741 | 2749 c->log->action = "parsing frames"; |
2750 | |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
2751 ngx_memzero(&buf, sizeof(ngx_buf_t)); |
8243
d9f673d18e9b
QUIC: set the temporary flag for input frame buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8242
diff
changeset
|
2752 buf.temporary = 1; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
2753 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
2754 chain.buf = &buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
2755 chain.next = NULL; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
2756 frame.data = &chain; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
2757 |
7706
1f002206a59b
Added boundaries checks into frame parser.
Vladimir Homutov <vl@nginx.com>
parents:
7705
diff
changeset
|
2758 len = ngx_quic_parse_frame(pkt, p, end, &frame); |
7717
c217a907ce42
Added checks for permitted frame types.
Vladimir Homutov <vl@nginx.com>
parents:
7713
diff
changeset
|
2759 |
7691 | 2760 if (len < 0) { |
7862
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
2761 qc->error = pkt->error; |
7691 | 2762 return NGX_ERROR; |
2763 } | |
2764 | |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
2765 ngx_quic_log_frame(c->log, &frame, 0); |
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
2766 |
7741 | 2767 c->log->action = "handling frames"; |
2768 | |
7691 | 2769 p += len; |
2770 | |
2771 switch (frame.type) { | |
2772 | |
2773 case NGX_QUIC_FT_ACK: | |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
2774 if (ngx_quic_handle_ack_frame(c, pkt, &frame) != NGX_OK) { |
7691 | 2775 return NGX_ERROR; |
2776 } | |
2777 | |
7844
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2778 continue; |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2779 |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2780 case NGX_QUIC_FT_PADDING: |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2781 /* no action required */ |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2782 continue; |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2783 |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2784 case NGX_QUIC_FT_CONNECTION_CLOSE: |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
2785 case NGX_QUIC_FT_CONNECTION_CLOSE_APP: |
7844
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2786 do_close = 1; |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2787 continue; |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2788 } |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2789 |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2790 /* got there with ack-eliciting packet */ |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2791 pkt->need_ack = 1; |
7844
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2792 |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2793 switch (frame.type) { |
7691 | 2794 |
2795 case NGX_QUIC_FT_CRYPTO: | |
2796 | |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
2797 if (ngx_quic_handle_crypto_frame(c, pkt, &frame) != NGX_OK) { |
7691 | 2798 return NGX_ERROR; |
2799 } | |
2800 | |
2801 break; | |
2802 | |
2803 case NGX_QUIC_FT_PING: | |
2804 break; | |
2805 | |
2806 case NGX_QUIC_FT_STREAM0: | |
2807 case NGX_QUIC_FT_STREAM1: | |
2808 case NGX_QUIC_FT_STREAM2: | |
2809 case NGX_QUIC_FT_STREAM3: | |
2810 case NGX_QUIC_FT_STREAM4: | |
2811 case NGX_QUIC_FT_STREAM5: | |
2812 case NGX_QUIC_FT_STREAM6: | |
2813 case NGX_QUIC_FT_STREAM7: | |
2814 | |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
2815 if (ngx_quic_handle_stream_frame(c, pkt, &frame) != NGX_OK) { |
7691 | 2816 return NGX_ERROR; |
2817 } | |
2818 | |
2819 break; | |
2820 | |
7703
ff540f13d95d
MAX_DATA frame parser/handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7702
diff
changeset
|
2821 case NGX_QUIC_FT_MAX_DATA: |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2822 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2823 if (ngx_quic_handle_max_data_frame(c, &frame.u.max_data) != NGX_OK) |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2824 { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2825 return NGX_ERROR; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2826 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2827 |
7703
ff540f13d95d
MAX_DATA frame parser/handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7702
diff
changeset
|
2828 break; |
ff540f13d95d
MAX_DATA frame parser/handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7702
diff
changeset
|
2829 |
7702
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
7701
diff
changeset
|
2830 case NGX_QUIC_FT_STREAMS_BLOCKED: |
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
7701
diff
changeset
|
2831 case NGX_QUIC_FT_STREAMS_BLOCKED2: |
7711
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
2832 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
2833 if (ngx_quic_handle_streams_blocked_frame(c, pkt, |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
2834 &frame.u.streams_blocked) |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
2835 != NGX_OK) |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
2836 { |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
2837 return NGX_ERROR; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
2838 } |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
2839 |
7702
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
7701
diff
changeset
|
2840 break; |
d3b26c3bea22
Added parsing of STREAMS BLOCKED frames.
Vladimir Homutov <vl@nginx.com>
parents:
7701
diff
changeset
|
2841 |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
2842 case NGX_QUIC_FT_STREAM_DATA_BLOCKED: |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
2843 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
2844 if (ngx_quic_handle_stream_data_blocked_frame(c, pkt, |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
2845 &frame.u.stream_data_blocked) |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
2846 != NGX_OK) |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
2847 { |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
2848 return NGX_ERROR; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
2849 } |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
2850 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
2851 break; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
2852 |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2853 case NGX_QUIC_FT_MAX_STREAM_DATA: |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2854 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2855 if (ngx_quic_handle_max_stream_data_frame(c, pkt, |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2856 &frame.u.max_stream_data) |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2857 != NGX_OK) |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2858 { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2859 return NGX_ERROR; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2860 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2861 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2862 break; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
2863 |
7923
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2864 case NGX_QUIC_FT_RESET_STREAM: |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2865 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2866 if (ngx_quic_handle_reset_stream_frame(c, pkt, |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2867 &frame.u.reset_stream) |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2868 != NGX_OK) |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2869 { |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2870 return NGX_ERROR; |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2871 } |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2872 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2873 break; |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2874 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2875 case NGX_QUIC_FT_STOP_SENDING: |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2876 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2877 if (ngx_quic_handle_stop_sending_frame(c, pkt, |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2878 &frame.u.stop_sending) |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2879 != NGX_OK) |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2880 { |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2881 return NGX_ERROR; |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2882 } |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2883 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2884 break; |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
2885 |
8013
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
2886 case NGX_QUIC_FT_MAX_STREAMS: |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
2887 case NGX_QUIC_FT_MAX_STREAMS2: |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
2888 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
2889 if (ngx_quic_handle_max_streams_frame(c, pkt, &frame.u.max_streams) |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
2890 != NGX_OK) |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
2891 { |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
2892 return NGX_ERROR; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
2893 } |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
2894 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
2895 break; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
2896 |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
2897 case NGX_QUIC_FT_PATH_CHALLENGE: |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
2898 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
2899 if (ngx_quic_handle_path_challenge_frame(c, pkt, |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
2900 &frame.u.path_challenge) |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
2901 != NGX_OK) |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
2902 { |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
2903 return NGX_ERROR; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
2904 } |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
2905 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
2906 break; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
2907 |
7791
9b9d592c0da3
Ignore non-yet-implemented frames.
Vladimir Homutov <vl@nginx.com>
parents:
7788
diff
changeset
|
2908 case NGX_QUIC_FT_NEW_CONNECTION_ID: |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2909 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2910 if (ngx_quic_handle_new_connection_id_frame(c, pkt, &frame.u.ncid) |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2911 != NGX_OK) |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2912 { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2913 return NGX_ERROR; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2914 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2915 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2916 break; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
2917 |
7791
9b9d592c0da3
Ignore non-yet-implemented frames.
Vladimir Homutov <vl@nginx.com>
parents:
7788
diff
changeset
|
2918 case NGX_QUIC_FT_RETIRE_CONNECTION_ID: |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2919 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2920 if (ngx_quic_handle_retire_connection_id_frame(c, pkt, |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2921 &frame.u.retire_cid) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2922 != NGX_OK) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2923 { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2924 return NGX_ERROR; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2925 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2926 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2927 break; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
2928 |
7791
9b9d592c0da3
Ignore non-yet-implemented frames.
Vladimir Homutov <vl@nginx.com>
parents:
7788
diff
changeset
|
2929 case NGX_QUIC_FT_PATH_RESPONSE: |
9b9d592c0da3
Ignore non-yet-implemented frames.
Vladimir Homutov <vl@nginx.com>
parents:
7788
diff
changeset
|
2930 |
9b9d592c0da3
Ignore non-yet-implemented frames.
Vladimir Homutov <vl@nginx.com>
parents:
7788
diff
changeset
|
2931 /* TODO: handle */ |
9b9d592c0da3
Ignore non-yet-implemented frames.
Vladimir Homutov <vl@nginx.com>
parents:
7788
diff
changeset
|
2932 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
7836 | 2933 "quic frame handler not implemented"); |
7791
9b9d592c0da3
Ignore non-yet-implemented frames.
Vladimir Homutov <vl@nginx.com>
parents:
7788
diff
changeset
|
2934 break; |
9b9d592c0da3
Ignore non-yet-implemented frames.
Vladimir Homutov <vl@nginx.com>
parents:
7788
diff
changeset
|
2935 |
7691 | 2936 default: |
7823
4e4485793418
Added MAX_STREAM_DATA stub handler.
Vladimir Homutov <vl@nginx.com>
parents:
7822
diff
changeset
|
2937 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
7836 | 2938 "quic missing frame handler"); |
7691 | 2939 return NGX_ERROR; |
2940 } | |
2941 } | |
2942 | |
2943 if (p != end) { | |
2944 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
2945 "quic trailing garbage in payload:%ui bytes", end - p); |
7862
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
2946 |
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
2947 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; |
7691 | 2948 return NGX_ERROR; |
2949 } | |
2950 | |
2951 if (do_close) { | |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2952 qc->draining = 1; |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
2953 ngx_quic_close_connection(c, NGX_OK); |
7691 | 2954 } |
2955 | |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2956 if (ngx_quic_ack_packet(c, pkt) != NGX_OK) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2957 return NGX_ERROR; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2958 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2959 |
7844
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2960 return NGX_OK; |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2961 } |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2962 |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2963 |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
2964 static ngx_int_t |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2965 ngx_quic_ack_packet(ngx_connection_t *c, ngx_quic_header_t *pkt) |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2966 { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2967 uint64_t base, largest, smallest, gs, ge, gap, range, pn; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2968 uint64_t prev_pending; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2969 ngx_uint_t i, nr; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2970 ngx_quic_send_ctx_t *ctx; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2971 ngx_quic_ack_range_t *r; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2972 ngx_quic_connection_t *qc; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2973 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2974 c->log->action = "preparing ack"; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2975 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2976 qc = ngx_quic_get_connection(c); |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2977 |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2978 ctx = ngx_quic_get_send_ctx(qc, pkt->level); |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2979 |
8158
c01964fd7b8b
QUIC: fixed dropping output ack ranges on input ack.
Vladimir Homutov <vl@nginx.com>
parents:
8157
diff
changeset
|
2980 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8193
8550b91e8e35
QUIC: added proper logging of special values.
Vladimir Homutov <vl@nginx.com>
parents:
8192
diff
changeset
|
2981 "quic ngx_quic_ack_packet pn:%uL largest %L fr:%uL" |
8550b91e8e35
QUIC: added proper logging of special values.
Vladimir Homutov <vl@nginx.com>
parents:
8192
diff
changeset
|
2982 " nranges:%ui", pkt->pn, (int64_t) ctx->largest_range, |
8158
c01964fd7b8b
QUIC: fixed dropping output ack ranges on input ack.
Vladimir Homutov <vl@nginx.com>
parents:
8157
diff
changeset
|
2983 ctx->first_range, ctx->nranges); |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2984 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2985 prev_pending = ctx->pending_ack; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2986 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2987 if (pkt->need_ack) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2988 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
2989 ngx_post_event(&qc->push, &ngx_posted_events); |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2990 |
8162
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
2991 if (ctx->send_ack == 0) { |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
2992 ctx->ack_delay_start = ngx_current_msec; |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
2993 } |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
2994 |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
2995 ctx->send_ack++; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2996 |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
2997 if (ctx->pending_ack == NGX_QUIC_UNSET_PN |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2998 || ctx->pending_ack < pkt->pn) |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
2999 { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3000 ctx->pending_ack = pkt->pn; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3001 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3002 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3003 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3004 base = ctx->largest_range; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3005 pn = pkt->pn; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3006 |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
3007 if (base == NGX_QUIC_UNSET_PN) { |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3008 ctx->largest_range = pn; |
8162
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3009 ctx->largest_received = pkt->received; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3010 return NGX_OK; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3011 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3012 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3013 if (base == pn) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3014 return NGX_OK; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3015 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3016 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3017 largest = base; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3018 smallest = largest - ctx->first_range; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3019 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3020 if (pn > base) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3021 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3022 if (pn - base == 1) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3023 ctx->first_range++; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3024 ctx->largest_range = pn; |
8162
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3025 ctx->largest_received = pkt->received; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3026 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3027 return NGX_OK; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3028 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3029 } else { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3030 /* new gap in front of current largest */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3031 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3032 /* no place for new range, send current range as is */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3033 if (ctx->nranges == NGX_QUIC_MAX_RANGES) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3034 |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
3035 if (prev_pending != NGX_QUIC_UNSET_PN) { |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3036 if (ngx_quic_send_ack(c, ctx) != NGX_OK) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3037 return NGX_ERROR; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3038 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3039 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3040 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3041 if (prev_pending == ctx->pending_ack || !pkt->need_ack) { |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
3042 ctx->pending_ack = NGX_QUIC_UNSET_PN; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3043 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3044 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3045 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3046 gap = pn - base - 2; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3047 range = ctx->first_range; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3048 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3049 ctx->first_range = 0; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3050 ctx->largest_range = pn; |
8162
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3051 ctx->largest_received = pkt->received; |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3052 |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3053 /* packet is out of order, force send */ |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3054 if (pkt->need_ack) { |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3055 ctx->send_ack = NGX_QUIC_MAX_ACK_GAP; |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3056 } |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3057 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3058 i = 0; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3059 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3060 goto insert; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3061 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3062 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3063 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3064 /* pn < base, perform lookup in existing ranges */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3065 |
8162
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3066 /* packet is out of order */ |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3067 if (pkt->need_ack) { |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3068 ctx->send_ack = NGX_QUIC_MAX_ACK_GAP; |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3069 } |
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3070 |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3071 if (pn >= smallest && pn <= largest) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3072 return NGX_OK; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3073 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3074 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3075 #if (NGX_SUPPRESS_WARN) |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3076 r = NULL; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3077 #endif |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3078 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3079 for (i = 0; i < ctx->nranges; i++) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3080 r = &ctx->ranges[i]; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3081 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3082 ge = smallest - 1; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3083 gs = ge - r->gap; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3084 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3085 if (pn >= gs && pn <= ge) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3086 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3087 if (gs == ge) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3088 /* gap size is exactly one packet, now filled */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3089 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3090 /* data moves to previous range, current is removed */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3091 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3092 if (i == 0) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3093 ctx->first_range += r->range + 2; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3094 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3095 } else { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3096 ctx->ranges[i - 1].range += r->range + 2; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3097 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3098 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3099 nr = ctx->nranges - i - 1; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3100 if (nr) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3101 ngx_memmove(&ctx->ranges[i], &ctx->ranges[i + 1], |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3102 sizeof(ngx_quic_ack_range_t) * nr); |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3103 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3104 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3105 ctx->nranges--; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3106 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3107 } else if (pn == gs) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3108 /* current gap shrinks from tail (current range grows) */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3109 r->gap--; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3110 r->range++; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3111 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3112 } else if (pn == ge) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3113 /* current gap shrinks from head (previous range grows) */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3114 r->gap--; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3115 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3116 if (i == 0) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3117 ctx->first_range++; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3118 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3119 } else { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3120 ctx->ranges[i - 1].range++; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3121 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3122 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3123 } else { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3124 /* current gap is split into two parts */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3125 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3126 gap = ge - pn - 1; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3127 range = 0; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3128 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3129 if (ctx->nranges == NGX_QUIC_MAX_RANGES) { |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
3130 if (prev_pending != NGX_QUIC_UNSET_PN) { |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3131 if (ngx_quic_send_ack(c, ctx) != NGX_OK) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3132 return NGX_ERROR; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3133 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3134 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3135 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3136 if (prev_pending == ctx->pending_ack || !pkt->need_ack) { |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
3137 ctx->pending_ack = NGX_QUIC_UNSET_PN; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3138 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3139 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3140 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3141 r->gap = pn - gs - 1; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3142 goto insert; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3143 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3144 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3145 return NGX_OK; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3146 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3147 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3148 largest = smallest - r->gap - 2; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3149 smallest = largest - r->range; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3150 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3151 if (pn >= smallest && pn <= largest) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3152 /* this packet number is already known */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3153 return NGX_OK; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3154 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3155 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3156 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3157 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3158 if (pn == smallest - 1) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3159 /* extend first or last range */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3160 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3161 if (i == 0) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3162 ctx->first_range++; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3163 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3164 } else { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3165 r->range++; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3166 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3167 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3168 return NGX_OK; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3169 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3170 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3171 /* nothing found, add new range at the tail */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3172 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3173 if (ctx->nranges == NGX_QUIC_MAX_RANGES) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3174 /* packet is too old to keep it */ |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3175 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3176 if (pkt->need_ack) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3177 return ngx_quic_send_ack_range(c, ctx, pn, pn); |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3178 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3179 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3180 return NGX_OK; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3181 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3182 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3183 gap = smallest - 2 - pn; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3184 range = 0; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3185 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3186 insert: |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3187 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3188 if (ctx->nranges < NGX_QUIC_MAX_RANGES) { |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3189 ctx->nranges++; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3190 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3191 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3192 ngx_memmove(&ctx->ranges[i + 1], &ctx->ranges[i], |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3193 sizeof(ngx_quic_ack_range_t) * (ctx->nranges - i - 1)); |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3194 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3195 ctx->ranges[i].gap = gap; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3196 ctx->ranges[i].range = range; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3197 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3198 return NGX_OK; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3199 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3200 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3201 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3202 static ngx_int_t |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3203 ngx_quic_send_ack_range(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx, |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3204 uint64_t smallest, uint64_t largest) |
7844
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
3205 { |
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
3206 ngx_quic_frame_t *frame; |
7691 | 3207 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3208 frame = ngx_quic_alloc_frame(c); |
7844
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
3209 if (frame == NULL) { |
7691 | 3210 return NGX_ERROR; |
3211 } | |
3212 | |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3213 frame->level = ctx->level; |
7844
c10e7d48aa85
Factored out sending ACK from payload handler.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7842
diff
changeset
|
3214 frame->type = NGX_QUIC_FT_ACK; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3215 frame->u.ack.largest = largest; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3216 frame->u.ack.delay = 0; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3217 frame->u.ack.range_count = 0; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3218 frame->u.ack.first_range = largest - smallest; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3219 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3220 return NGX_OK; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3221 } |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3222 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3223 |
8156
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3224 static void |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3225 ngx_quic_drop_ack_ranges(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx, |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3226 uint64_t pn) |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3227 { |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3228 uint64_t base; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3229 ngx_uint_t i, smallest, largest; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3230 ngx_quic_ack_range_t *r; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3231 |
8158
c01964fd7b8b
QUIC: fixed dropping output ack ranges on input ack.
Vladimir Homutov <vl@nginx.com>
parents:
8157
diff
changeset
|
3232 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
3233 "quic ngx_quic_drop_ack_ranges pn:%uL largest:%uL" |
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
3234 " fr:%uL nranges:%ui", pn, ctx->largest_range, |
8158
c01964fd7b8b
QUIC: fixed dropping output ack ranges on input ack.
Vladimir Homutov <vl@nginx.com>
parents:
8157
diff
changeset
|
3235 ctx->first_range, ctx->nranges); |
c01964fd7b8b
QUIC: fixed dropping output ack ranges on input ack.
Vladimir Homutov <vl@nginx.com>
parents:
8157
diff
changeset
|
3236 |
8156
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3237 base = ctx->largest_range; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3238 |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
3239 if (base == NGX_QUIC_UNSET_PN) { |
8156
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3240 return; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3241 } |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3242 |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
3243 if (ctx->pending_ack != NGX_QUIC_UNSET_PN && pn >= ctx->pending_ack) { |
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
3244 ctx->pending_ack = NGX_QUIC_UNSET_PN; |
8156
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3245 } |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3246 |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3247 largest = base; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3248 smallest = largest - ctx->first_range; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3249 |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3250 if (pn >= largest) { |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
3251 ctx->largest_range = NGX_QUIC_UNSET_PN; |
8156
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3252 ctx->first_range = 0; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3253 ctx->nranges = 0; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3254 return; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3255 } |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3256 |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3257 if (pn >= smallest) { |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3258 ctx->first_range = largest - pn - 1; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3259 ctx->nranges = 0; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3260 return; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3261 } |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3262 |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3263 for (i = 0; i < ctx->nranges; i++) { |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3264 r = &ctx->ranges[i]; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3265 |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3266 largest = smallest - r->gap - 2; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3267 smallest = largest - r->range; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3268 |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3269 if (pn >= largest) { |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3270 ctx->nranges = i; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3271 return; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3272 } |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3273 if (pn >= smallest) { |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3274 r->range = largest - pn - 1; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3275 ctx->nranges = i + 1; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3276 return; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3277 } |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3278 } |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3279 } |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3280 |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3281 |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3282 static ngx_int_t |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3283 ngx_quic_send_ack(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx) |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3284 { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3285 size_t len, left; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3286 uint64_t ack_delay; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3287 ngx_buf_t *b; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3288 ngx_uint_t i; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3289 ngx_chain_t *cl, **ll; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3290 ngx_quic_frame_t *frame; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3291 ngx_quic_connection_t *qc; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3292 |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3293 qc = ngx_quic_get_connection(c); |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3294 |
8246
b9ac4752d0e6
QUIC: send and process ack_delay for Initial and Handshake levels.
Roman Arutyunyan <arut@nginx.com>
parents:
8245
diff
changeset
|
3295 ack_delay = ngx_current_msec - ctx->largest_received; |
b9ac4752d0e6
QUIC: send and process ack_delay for Initial and Handshake levels.
Roman Arutyunyan <arut@nginx.com>
parents:
8245
diff
changeset
|
3296 ack_delay *= 1000; |
8286
3956bbf91002
QUIC: use server ack_delay_exponent when sending ack.
Roman Arutyunyan <arut@nginx.com>
parents:
8285
diff
changeset
|
3297 ack_delay >>= qc->tp.ack_delay_exponent; |
8162
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3298 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3299 frame = ngx_quic_alloc_frame(c); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3300 if (frame == NULL) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3301 return NGX_ERROR; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3302 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3303 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3304 ll = &frame->data; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3305 b = NULL; |
8172
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
3306 |
867c189f875d
QUIC: unified range format for rx and tx ACK frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8171
diff
changeset
|
3307 for (i = 0; i < ctx->nranges; i++) { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3308 len = ngx_quic_create_ack_range(NULL, ctx->ranges[i].gap, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3309 ctx->ranges[i].range); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3310 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3311 left = b ? b->end - b->last : 0; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3312 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3313 if (left < len) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3314 cl = ngx_quic_alloc_buf(c); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3315 if (cl == NULL) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3316 return NGX_ERROR; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3317 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3318 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3319 *ll = cl; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3320 ll = &cl->next; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3321 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3322 b = cl->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3323 left = b->end - b->last; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3324 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3325 if (left < len) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3326 return NGX_ERROR; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3327 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3328 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3329 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3330 b->last += ngx_quic_create_ack_range(b->last, ctx->ranges[i].gap, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3331 ctx->ranges[i].range); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3332 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3333 frame->u.ack.ranges_length += len; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3334 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3335 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3336 *ll = NULL; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3337 |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3338 frame->level = ctx->level; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3339 frame->type = NGX_QUIC_FT_ACK; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3340 frame->u.ack.largest = ctx->largest_range; |
8162
c5ea341f705a
QUIC: optimized acknowledgement generation.
Vladimir Homutov <vl@nginx.com>
parents:
8161
diff
changeset
|
3341 frame->u.ack.delay = ack_delay; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3342 frame->u.ack.range_count = ctx->nranges; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3343 frame->u.ack.first_range = ctx->first_range; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
3344 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3345 ngx_quic_queue_frame(qc, frame); |
7691 | 3346 |
7775 | 3347 return NGX_OK; |
7691 | 3348 } |
3349 | |
3350 | |
3351 static ngx_int_t | |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
3352 ngx_quic_send_cc(ngx_connection_t *c) |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3353 { |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3354 ngx_quic_frame_t *frame; |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3355 ngx_quic_connection_t *qc; |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3356 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3357 qc = ngx_quic_get_connection(c); |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3358 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3359 if (qc->draining) { |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3360 return NGX_OK; |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3361 } |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3362 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3363 if (qc->closing |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3364 && ngx_current_msec - qc->last_cc < NGX_QUIC_CC_MIN_INTERVAL) |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3365 { |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3366 /* dot not send CC too often */ |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3367 return NGX_OK; |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3368 } |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3369 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3370 frame = ngx_quic_alloc_frame(c); |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3371 if (frame == NULL) { |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3372 return NGX_ERROR; |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3373 } |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3374 |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
3375 frame->level = qc->error_level; |
8285
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8281
diff
changeset
|
3376 frame->type = qc->error_app ? NGX_QUIC_FT_CONNECTION_CLOSE_APP |
0697294f79a4
QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8281
diff
changeset
|
3377 : NGX_QUIC_FT_CONNECTION_CLOSE; |
7953
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
3378 frame->u.close.error_code = qc->error; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
3379 frame->u.close.frame_type = qc->error_ftype; |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
3380 |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
3381 if (qc->error_reason) { |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
3382 frame->u.close.reason.len = ngx_strlen(qc->error_reason); |
e0f92f68e018
QUIC: Introduced ngx_quic_finalize_connection().
Roman Arutyunyan <arut@nginx.com>
parents:
7945
diff
changeset
|
3383 frame->u.close.reason.data = (u_char *) qc->error_reason; |
7876
ffd362e87eb2
Added more context to CONNECTION CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7875
diff
changeset
|
3384 } |
ffd362e87eb2
Added more context to CONNECTION CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7875
diff
changeset
|
3385 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3386 ngx_quic_queue_frame(qc, frame); |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3387 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3388 qc->last_cc = ngx_current_msec; |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3389 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3390 return ngx_quic_output(c); |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3391 } |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3392 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3393 |
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
3394 static ngx_int_t |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3395 ngx_quic_send_new_token(ngx_connection_t *c) |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3396 { |
8279 | 3397 time_t expires; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3398 ngx_str_t token; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3399 ngx_quic_frame_t *frame; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3400 ngx_quic_connection_t *qc; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3401 |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3402 qc = ngx_quic_get_connection(c); |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3403 |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3404 if (!qc->conf->retry) { |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3405 return NGX_OK; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3406 } |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3407 |
8279 | 3408 expires = ngx_time() + NGX_QUIC_NEW_TOKEN_LIFETIME; |
3409 | |
8287
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
3410 if (ngx_quic_new_token(c, qc->conf->av_token_key, &token, NULL, expires, 0) |
8279 | 3411 != NGX_OK) |
3412 { | |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3413 return NGX_ERROR; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3414 } |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3415 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3416 frame = ngx_quic_alloc_frame(c); |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3417 if (frame == NULL) { |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3418 return NGX_ERROR; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3419 } |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3420 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3421 frame->level = ssl_encryption_application; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3422 frame->type = NGX_QUIC_FT_NEW_TOKEN; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3423 frame->u.token.length = token.len; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3424 frame->u.token.data = token.data; |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
3425 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3426 ngx_quic_queue_frame(qc, frame); |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3427 |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3428 return NGX_OK; |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3429 } |
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3430 |
7945 | 3431 |
7861
52d0c4832570
Address validation using NEW_TOKEN frame.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7860
diff
changeset
|
3432 static ngx_int_t |
7691 | 3433 ngx_quic_handle_ack_frame(ngx_connection_t *c, ngx_quic_header_t *pkt, |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3434 ngx_quic_frame_t *f) |
7691 | 3435 { |
7989
9ed4c12ec948
QUIC: caching c->quic in the ngx_quic_handle_ack_frame() function.
Vladimir Homutov <vl@nginx.com>
parents:
7988
diff
changeset
|
3436 ssize_t n; |
9ed4c12ec948
QUIC: caching c->quic in the ngx_quic_handle_ack_frame() function.
Vladimir Homutov <vl@nginx.com>
parents:
7988
diff
changeset
|
3437 u_char *pos, *end; |
8020
69033a50c3ae
QUIC: fixed ACK Ranges processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8019
diff
changeset
|
3438 uint64_t min, max, gap, range; |
7989
9ed4c12ec948
QUIC: caching c->quic in the ngx_quic_handle_ack_frame() function.
Vladimir Homutov <vl@nginx.com>
parents:
7988
diff
changeset
|
3439 ngx_msec_t send_time; |
8020
69033a50c3ae
QUIC: fixed ACK Ranges processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8019
diff
changeset
|
3440 ngx_uint_t i; |
7989
9ed4c12ec948
QUIC: caching c->quic in the ngx_quic_handle_ack_frame() function.
Vladimir Homutov <vl@nginx.com>
parents:
7988
diff
changeset
|
3441 ngx_quic_send_ctx_t *ctx; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3442 ngx_quic_ack_frame_t *ack; |
7989
9ed4c12ec948
QUIC: caching c->quic in the ngx_quic_handle_ack_frame() function.
Vladimir Homutov <vl@nginx.com>
parents:
7988
diff
changeset
|
3443 ngx_quic_connection_t *qc; |
9ed4c12ec948
QUIC: caching c->quic in the ngx_quic_handle_ack_frame() function.
Vladimir Homutov <vl@nginx.com>
parents:
7988
diff
changeset
|
3444 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3445 qc = ngx_quic_get_connection(c); |
7989
9ed4c12ec948
QUIC: caching c->quic in the ngx_quic_handle_ack_frame() function.
Vladimir Homutov <vl@nginx.com>
parents:
7988
diff
changeset
|
3446 |
9ed4c12ec948
QUIC: caching c->quic in the ngx_quic_handle_ack_frame() function.
Vladimir Homutov <vl@nginx.com>
parents:
7988
diff
changeset
|
3447 ctx = ngx_quic_get_send_ctx(qc, pkt->level); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3448 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3449 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
3450 "quic ngx_quic_handle_ack_frame level:%d", pkt->level); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3451 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3452 ack = &f->u.ack; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3453 |
7792 | 3454 /* |
7862
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
3455 * If any computed packet number is negative, an endpoint MUST |
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
3456 * generate a connection error of type FRAME_ENCODING_ERROR. |
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
3457 * (19.3.1) |
7792 | 3458 */ |
3459 | |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3460 if (ack->first_range > ack->largest) { |
7989
9ed4c12ec948
QUIC: caching c->quic in the ngx_quic_handle_ack_frame() function.
Vladimir Homutov <vl@nginx.com>
parents:
7988
diff
changeset
|
3461 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3462 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
7838 | 3463 "quic invalid first range in ack frame"); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3464 return NGX_ERROR; |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3465 } |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3466 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3467 min = ack->largest - ack->first_range; |
7792 | 3468 max = ack->largest; |
3469 | |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3470 if (ngx_quic_handle_ack_frame_range(c, ctx, min, max, &send_time) |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3471 != NGX_OK) |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3472 { |
7792 | 3473 return NGX_ERROR; |
3474 } | |
3475 | |
3476 /* 13.2.3. Receiver Tracking of ACK Frames */ | |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
3477 if (ctx->largest_ack < max || ctx->largest_ack == NGX_QUIC_UNSET_PN) { |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
3478 ctx->largest_ack = max; |
7792 | 3479 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
3480 "quic updated largest received ack:%uL", max); |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3481 |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3482 /* |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3483 * An endpoint generates an RTT sample on receiving an |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3484 * ACK frame that meets the following two conditions: |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3485 * |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3486 * - the largest acknowledged packet number is newly acknowledged |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3487 * - at least one of the newly acknowledged packets was ack-eliciting. |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3488 */ |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3489 |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3490 if (send_time != NGX_TIMER_INFINITE) { |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3491 ngx_quic_rtt_sample(c, ack, pkt->level, send_time); |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3492 } |
7792 | 3493 } |
3494 | |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3495 if (f->data) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3496 pos = f->data->buf->pos; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3497 end = f->data->buf->last; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3498 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3499 } else { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3500 pos = NULL; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3501 end = NULL; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3502 } |
7792 | 3503 |
3504 for (i = 0; i < ack->range_count; i++) { | |
3505 | |
8163
b3d9e57d0f62
QUIC: single function for frame debug logging.
Vladimir Homutov <vl@nginx.com>
parents:
8162
diff
changeset
|
3506 n = ngx_quic_parse_ack_range(pkt->log, pos, end, &gap, &range); |
7792 | 3507 if (n == NGX_ERROR) { |
3508 return NGX_ERROR; | |
3509 } | |
3510 pos += n; | |
3511 | |
8020
69033a50c3ae
QUIC: fixed ACK Ranges processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8019
diff
changeset
|
3512 if (gap + 2 > min) { |
7989
9ed4c12ec948
QUIC: caching c->quic in the ngx_quic_handle_ack_frame() function.
Vladimir Homutov <vl@nginx.com>
parents:
7988
diff
changeset
|
3513 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; |
7792 | 3514 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
3515 "quic invalid range:%ui in ack frame", i); |
7792 | 3516 return NGX_ERROR; |
3517 } | |
3518 | |
8020
69033a50c3ae
QUIC: fixed ACK Ranges processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8019
diff
changeset
|
3519 max = min - gap - 2; |
69033a50c3ae
QUIC: fixed ACK Ranges processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8019
diff
changeset
|
3520 |
69033a50c3ae
QUIC: fixed ACK Ranges processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8019
diff
changeset
|
3521 if (range > max) { |
7989
9ed4c12ec948
QUIC: caching c->quic in the ngx_quic_handle_ack_frame() function.
Vladimir Homutov <vl@nginx.com>
parents:
7988
diff
changeset
|
3522 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; |
7792 | 3523 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
3524 "quic invalid range:%ui in ack frame", i); |
7792 | 3525 return NGX_ERROR; |
3526 } | |
3527 | |
8020
69033a50c3ae
QUIC: fixed ACK Ranges processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8019
diff
changeset
|
3528 min = max - range; |
7792 | 3529 |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3530 if (ngx_quic_handle_ack_frame_range(c, ctx, min, max, &send_time) |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3531 != NGX_OK) |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3532 { |
7792 | 3533 return NGX_ERROR; |
3534 } | |
3535 } | |
3536 | |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
3537 return ngx_quic_detect_lost(c); |
7792 | 3538 } |
3539 | |
3540 | |
3541 static ngx_int_t | |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
3542 ngx_quic_handle_ack_frame_range(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx, |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3543 uint64_t min, uint64_t max, ngx_msec_t *send_time) |
7792 | 3544 { |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3545 ngx_uint_t found; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3546 ngx_queue_t *q; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3547 ngx_quic_frame_t *f; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3548 ngx_quic_connection_t *qc; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3549 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3550 qc = ngx_quic_get_connection(c); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3551 |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3552 *send_time = NGX_TIMER_INFINITE; |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3553 found = 0; |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3554 |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3555 q = ngx_queue_last(&ctx->sent); |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
3556 |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
3557 while (q != ngx_queue_sentinel(&ctx->sent)) { |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3558 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3559 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3560 q = ngx_queue_prev(q); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3561 |
7792 | 3562 if (f->pnum >= min && f->pnum <= max) { |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3563 ngx_quic_congestion_ack(c, f); |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3564 |
8156
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3565 switch (f->type) { |
8159
06af25901b1a
QUIC: restored proper usage of ngx_quic_drop_ack_ranges().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8158
diff
changeset
|
3566 case NGX_QUIC_FT_ACK: |
06af25901b1a
QUIC: restored proper usage of ngx_quic_drop_ack_ranges().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8158
diff
changeset
|
3567 case NGX_QUIC_FT_ACK_ECN: |
06af25901b1a
QUIC: restored proper usage of ngx_quic_drop_ack_ranges().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8158
diff
changeset
|
3568 ngx_quic_drop_ack_ranges(c, ctx, f->u.ack.largest); |
06af25901b1a
QUIC: restored proper usage of ngx_quic_drop_ack_ranges().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8158
diff
changeset
|
3569 break; |
8156
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3570 |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3571 case NGX_QUIC_FT_STREAM0: |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3572 case NGX_QUIC_FT_STREAM1: |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3573 case NGX_QUIC_FT_STREAM2: |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3574 case NGX_QUIC_FT_STREAM3: |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3575 case NGX_QUIC_FT_STREAM4: |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3576 case NGX_QUIC_FT_STREAM5: |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3577 case NGX_QUIC_FT_STREAM6: |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3578 case NGX_QUIC_FT_STREAM7: |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3579 ngx_quic_handle_stream_ack(c, f); |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3580 break; |
0351fcf52a03
QUIC: drop acknowledged ranges.
Vladimir Homutov <vl@nginx.com>
parents:
8155
diff
changeset
|
3581 } |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3582 |
8247
1823e2152fc4
QUIC: always calculate rtt for largest acknowledged packet.
Roman Arutyunyan <arut@nginx.com>
parents:
8246
diff
changeset
|
3583 if (f->pnum == max) { |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3584 *send_time = f->last; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3585 } |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3586 |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3587 ngx_queue_remove(&f->queue); |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3588 ngx_quic_free_frame(c, f); |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3589 found = 1; |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3590 } |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3591 } |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3592 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3593 if (!found) { |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3594 |
7932
4e75267865de
QUIC: fixed off-by-one in frame range handler.
Vladimir Homutov <vl@nginx.com>
parents:
7931
diff
changeset
|
3595 if (max < ctx->pnum) { |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3596 /* duplicate ACK or ACK for non-ack-eliciting frame */ |
7792 | 3597 return NGX_OK; |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3598 } |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3599 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3600 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
7878 | 3601 "quic ACK for the packet not sent"); |
7862
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
3602 |
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
3603 qc->error = NGX_QUIC_ERR_PROTOCOL_VIOLATION; |
7876
ffd362e87eb2
Added more context to CONNECTION CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7875
diff
changeset
|
3604 qc->error_ftype = NGX_QUIC_FT_ACK; |
ffd362e87eb2
Added more context to CONNECTION CLOSE frames.
Vladimir Homutov <vl@nginx.com>
parents:
7875
diff
changeset
|
3605 qc->error_reason = "unknown packet number"; |
7862
fb7422074258
Added generation of CC frames with error on connection termination.
Vladimir Homutov <vl@nginx.com>
parents:
7861
diff
changeset
|
3606 |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3607 return NGX_ERROR; |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3608 } |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
3609 |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3610 if (!qc->push.timer_set) { |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3611 ngx_post_event(&qc->push, &ngx_posted_events); |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3612 } |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3613 |
7993
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3614 qc->pto_count = 0; |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3615 |
7691 | 3616 return NGX_OK; |
3617 } | |
3618 | |
3619 | |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3620 static void |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3621 ngx_quic_rtt_sample(ngx_connection_t *c, ngx_quic_ack_frame_t *ack, |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3622 enum ssl_encryption_level_t level, ngx_msec_t send_time) |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3623 { |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3624 ngx_msec_t latest_rtt, ack_delay, adjusted_rtt, rttvar_sample; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3625 ngx_quic_connection_t *qc; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3626 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3627 qc = ngx_quic_get_connection(c); |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3628 |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3629 latest_rtt = ngx_current_msec - send_time; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3630 qc->latest_rtt = latest_rtt; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3631 |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3632 if (qc->min_rtt == NGX_TIMER_INFINITE) { |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3633 qc->min_rtt = latest_rtt; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3634 qc->avg_rtt = latest_rtt; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3635 qc->rttvar = latest_rtt / 2; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3636 |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3637 } else { |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3638 qc->min_rtt = ngx_min(qc->min_rtt, latest_rtt); |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3639 |
8246
b9ac4752d0e6
QUIC: send and process ack_delay for Initial and Handshake levels.
Roman Arutyunyan <arut@nginx.com>
parents:
8245
diff
changeset
|
3640 ack_delay = ack->delay * (1 << qc->ctp.ack_delay_exponent) / 1000; |
b9ac4752d0e6
QUIC: send and process ack_delay for Initial and Handshake levels.
Roman Arutyunyan <arut@nginx.com>
parents:
8245
diff
changeset
|
3641 |
b9ac4752d0e6
QUIC: send and process ack_delay for Initial and Handshake levels.
Roman Arutyunyan <arut@nginx.com>
parents:
8245
diff
changeset
|
3642 if (c->ssl->handshaked) { |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3643 ack_delay = ngx_min(ack_delay, qc->ctp.max_ack_delay); |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3644 } |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3645 |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3646 adjusted_rtt = latest_rtt; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3647 |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3648 if (qc->min_rtt + ack_delay < latest_rtt) { |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3649 adjusted_rtt -= ack_delay; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3650 } |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3651 |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3652 qc->avg_rtt = 0.875 * qc->avg_rtt + 0.125 * adjusted_rtt; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3653 rttvar_sample = ngx_abs((ngx_msec_int_t) (qc->avg_rtt - adjusted_rtt)); |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3654 qc->rttvar = 0.75 * qc->rttvar + 0.25 * rttvar_sample; |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3655 } |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3656 |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3657 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
3658 "quic rtt sample latest:%M min:%M avg:%M var:%M", |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3659 latest_rtt, qc->min_rtt, qc->avg_rtt, qc->rttvar); |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3660 } |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3661 |
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3662 |
7993
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3663 static ngx_inline ngx_msec_t |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3664 ngx_quic_pto(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx) |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3665 { |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3666 ngx_msec_t duration; |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3667 ngx_quic_connection_t *qc; |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3668 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3669 qc = ngx_quic_get_connection(c); |
7993
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3670 |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3671 /* PTO calculation: quic-recovery, Appendix 8 */ |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3672 duration = qc->avg_rtt; |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3673 |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3674 duration += ngx_max(4 * qc->rttvar, NGX_QUIC_TIME_GRANULARITY); |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3675 duration <<= qc->pto_count; |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3676 |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3677 if (qc->congestion.in_flight == 0) { /* no in-flight packets */ |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3678 return duration; |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3679 } |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3680 |
8245
49efd27dace6
QUIC: use client max_ack_delay when computing pto timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
3681 if (ctx->level == ssl_encryption_application && c->ssl->handshaked) { |
49efd27dace6
QUIC: use client max_ack_delay when computing pto timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8244
diff
changeset
|
3682 duration += qc->ctp.max_ack_delay << qc->pto_count; |
7993
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3683 } |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3684 |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3685 return duration; |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3686 } |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3687 |
b276833111cf
QUIC: implemented probe timeout (PTO) calculation.
Vladimir Homutov <vl@nginx.com>
parents:
7992
diff
changeset
|
3688 |
7987
3b107aadc9f6
QUIC: added rtt estimation.
Vladimir Homutov <vl@nginx.com>
parents:
7953
diff
changeset
|
3689 static void |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3690 ngx_quic_handle_stream_ack(ngx_connection_t *c, ngx_quic_frame_t *f) |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3691 { |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3692 uint64_t sent, unacked; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3693 ngx_event_t *wev; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3694 ngx_quic_stream_t *sn; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3695 ngx_quic_connection_t *qc; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3696 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3697 qc = ngx_quic_get_connection(c); |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3698 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3699 sn = ngx_quic_find_stream(&qc->streams.tree, f->u.stream.stream_id); |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3700 if (sn == NULL) { |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3701 return; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3702 } |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3703 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3704 wev = sn->c->write; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3705 sent = sn->c->sent; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3706 unacked = sent - sn->acked; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3707 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3708 if (unacked >= NGX_QUIC_STREAM_BUFSIZE && wev->active) { |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3709 wev->ready = 1; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3710 ngx_post_event(wev, &ngx_posted_events); |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3711 } |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3712 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3713 sn->acked += f->u.stream.length; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3714 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3715 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, sn->c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
3716 "quic stream ack len:%uL acked:%uL unacked:%uL", |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3717 f->u.stream.length, sn->acked, sent - sn->acked); |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3718 } |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3719 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
3720 |
7691 | 3721 static ngx_int_t |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3722 ngx_quic_handle_ordered_frame(ngx_connection_t *c, ngx_quic_frames_stream_t *fs, |
7855
81a4f98a2556
Cleaned up reordering code.
Vladimir Homutov <vl@nginx.com>
parents:
7854
diff
changeset
|
3723 ngx_quic_frame_t *frame, ngx_quic_frame_handler_pt handler, void *data) |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3724 { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3725 size_t full_len; |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3726 ngx_int_t rc; |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3727 ngx_queue_t *q; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3728 ngx_quic_ordered_frame_t *f; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3729 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3730 f = &frame->u.ord; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3731 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3732 if (f->offset > fs->received) { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3733 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
3734 "quic out-of-order frame: expecting:%uL got:%uL", |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3735 fs->received, f->offset); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3736 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3737 return ngx_quic_buffer_frame(c, fs, frame); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3738 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3739 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3740 if (f->offset < fs->received) { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3741 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3742 if (ngx_quic_adjust_frame_offset(c, frame, fs->received) |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3743 == NGX_DONE) |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3744 { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3745 /* old/duplicate data range */ |
8104
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3746 return handler == ngx_quic_crypto_input ? NGX_DECLINED : NGX_OK; |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3747 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3748 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3749 /* intersecting data range, frame modified */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3750 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3751 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3752 /* f->offset == fs->received */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3753 |
7855
81a4f98a2556
Cleaned up reordering code.
Vladimir Homutov <vl@nginx.com>
parents:
7854
diff
changeset
|
3754 rc = handler(c, frame, data); |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3755 if (rc == NGX_ERROR) { |
7691 | 3756 return NGX_ERROR; |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3757 |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3758 } else if (rc == NGX_DONE) { |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3759 /* handler destroyed stream, queue no longer exists */ |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3760 return NGX_OK; |
7691 | 3761 } |
3762 | |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3763 /* rc == NGX_OK */ |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3764 |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3765 fs->received += f->length; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3766 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3767 /* now check the queue if we can continue with buffered frames */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3768 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3769 do { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3770 q = ngx_queue_head(&fs->frames); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3771 if (q == ngx_queue_sentinel(&fs->frames)) { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3772 break; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3773 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3774 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3775 frame = ngx_queue_data(q, ngx_quic_frame_t, queue); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3776 f = &frame->u.ord; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3777 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3778 if (f->offset > fs->received) { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3779 /* gap found, nothing more to do */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3780 break; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3781 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3782 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3783 full_len = f->length; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3784 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3785 if (f->offset < fs->received) { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3786 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3787 if (ngx_quic_adjust_frame_offset(c, frame, fs->received) |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3788 == NGX_DONE) |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3789 { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3790 /* old/duplicate data range */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3791 ngx_queue_remove(q); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3792 fs->total -= f->length; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3793 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3794 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
3795 "quic skipped buffered frame, total:%ui", |
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
3796 fs->total); |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3797 ngx_quic_free_frame(c, frame); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3798 continue; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3799 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3800 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3801 /* frame was adjusted, proceed to input */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3802 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3803 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3804 /* f->offset == fs->received */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3805 |
7855
81a4f98a2556
Cleaned up reordering code.
Vladimir Homutov <vl@nginx.com>
parents:
7854
diff
changeset
|
3806 rc = handler(c, frame, data); |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3807 |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3808 if (rc == NGX_ERROR) { |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3809 return NGX_ERROR; |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3810 |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3811 } else if (rc == NGX_DONE) { |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3812 /* handler destroyed stream, queue no longer exists */ |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
3813 return NGX_OK; |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3814 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3815 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3816 fs->received += f->length; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3817 fs->total -= full_len; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3818 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3819 ngx_queue_remove(q); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3820 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3821 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
3822 "quic consumed buffered frame, total:%ui", fs->total); |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3823 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3824 ngx_quic_free_frame(c, frame); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3825 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3826 } while (1); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3827 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3828 return NGX_OK; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3829 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3830 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3831 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3832 static ngx_int_t |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3833 ngx_quic_adjust_frame_offset(ngx_connection_t *c, ngx_quic_frame_t *frame, |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3834 uint64_t offset_in) |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3835 { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3836 size_t tail, n; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3837 ngx_buf_t *b; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3838 ngx_chain_t *cl; |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3839 ngx_quic_ordered_frame_t *f; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3840 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3841 f = &frame->u.ord; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3842 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3843 tail = offset_in - f->offset; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3844 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3845 if (tail >= f->length) { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3846 /* range preceeding already received data or duplicate, ignore */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3847 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3848 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
7836 | 3849 "quic old or duplicate data in ordered frame, ignored"); |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3850 return NGX_DONE; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3851 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3852 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3853 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
7836 | 3854 "quic adjusted ordered frame data start to expected offset"); |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3855 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3856 /* intersecting range: adjust data size */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3857 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3858 f->offset += tail; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3859 f->length -= tail; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3860 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3861 for (cl = frame->data; cl; cl = cl->next) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3862 b = cl->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3863 n = ngx_buf_size(b); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3864 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3865 if (n >= tail) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3866 b->pos += tail; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3867 break; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3868 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3869 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3870 cl->buf->pos = cl->buf->last; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3871 tail -= n; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3872 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3873 |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3874 return NGX_OK; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3875 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3876 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3877 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3878 static ngx_int_t |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3879 ngx_quic_buffer_frame(ngx_connection_t *c, ngx_quic_frames_stream_t *fs, |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3880 ngx_quic_frame_t *frame) |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3881 { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3882 ngx_queue_t *q; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3883 ngx_quic_frame_t *dst, *item; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3884 ngx_quic_ordered_frame_t *f, *df; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3885 |
7836 | 3886 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
3887 "quic ngx_quic_buffer_frame"); | |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3888 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3889 f = &frame->u.ord; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3890 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3891 /* frame start offset is in the future, buffer it */ |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3892 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3893 dst = ngx_quic_alloc_frame(c); |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3894 if (dst == NULL) { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3895 return NGX_ERROR; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3896 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3897 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3898 ngx_memcpy(dst, frame, sizeof(ngx_quic_frame_t)); |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3899 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3900 dst->data = ngx_quic_copy_chain(c, frame->data, 0); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3901 if (dst->data == NGX_CHAIN_ERROR) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3902 return NGX_ERROR; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3903 } |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3904 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3905 df = &dst->u.ord; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3906 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3907 fs->total += f->length; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3908 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3909 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8295
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
3910 "quic ordered frame with unexpected offset:" |
d4e02b3b734f
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8294
diff
changeset
|
3911 " buffered total:%ui", fs->total); |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3912 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3913 if (ngx_queue_empty(&fs->frames)) { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3914 ngx_queue_insert_after(&fs->frames, &dst->queue); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3915 return NGX_OK; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3916 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3917 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3918 for (q = ngx_queue_last(&fs->frames); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3919 q != ngx_queue_sentinel(&fs->frames); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3920 q = ngx_queue_prev(q)) |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3921 { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3922 item = ngx_queue_data(q, ngx_quic_frame_t, queue); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3923 f = &item->u.ord; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3924 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3925 if (f->offset < df->offset) { |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3926 ngx_queue_insert_after(q, &dst->queue); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3927 return NGX_OK; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3928 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3929 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3930 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3931 ngx_queue_insert_after(&fs->frames, &dst->queue); |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3932 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3933 return NGX_OK; |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3934 } |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3935 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3936 |
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3937 static ngx_int_t |
7812
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
3938 ngx_quic_handle_crypto_frame(ngx_connection_t *c, ngx_quic_header_t *pkt, |
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
3939 ngx_quic_frame_t *frame) |
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
3940 { |
8068
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
3941 uint64_t last; |
8104
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3942 ngx_int_t rc; |
8132
6226f834b420
QUIC: do not resend empty queue when speeding up handshake.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8131
diff
changeset
|
3943 ngx_quic_send_ctx_t *ctx; |
7812
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
3944 ngx_quic_connection_t *qc; |
8068
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
3945 ngx_quic_crypto_frame_t *f; |
7812
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
3946 ngx_quic_frames_stream_t *fs; |
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
3947 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3948 qc = ngx_quic_get_connection(c); |
7812
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
3949 fs = &qc->crypto[pkt->level]; |
8068
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
3950 f = &frame->u.crypto; |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
3951 |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
3952 /* no overflow since both values are 62-bit */ |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
3953 last = f->offset + f->length; |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
3954 |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
3955 if (last > fs->received && last - fs->received > NGX_QUIC_MAX_BUFFERED) { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3956 qc->error = NGX_QUIC_ERR_CRYPTO_BUFFER_EXCEEDED; |
8068
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
3957 return NGX_ERROR; |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
3958 } |
7812
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
3959 |
8104
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3960 rc = ngx_quic_handle_ordered_frame(c, fs, frame, ngx_quic_crypto_input, |
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3961 NULL); |
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3962 if (rc != NGX_DECLINED) { |
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3963 return rc; |
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3964 } |
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3965 |
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3966 /* speeding up handshake completion */ |
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3967 |
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3968 if (pkt->level == ssl_encryption_initial) { |
8132
6226f834b420
QUIC: do not resend empty queue when speeding up handshake.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8131
diff
changeset
|
3969 ctx = ngx_quic_get_send_ctx(qc, pkt->level); |
6226f834b420
QUIC: do not resend empty queue when speeding up handshake.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8131
diff
changeset
|
3970 |
6226f834b420
QUIC: do not resend empty queue when speeding up handshake.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8131
diff
changeset
|
3971 if (!ngx_queue_empty(&ctx->sent)) { |
6226f834b420
QUIC: do not resend empty queue when speeding up handshake.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8131
diff
changeset
|
3972 ngx_quic_resend_frames(c, ctx); |
8244
6201cef77b1d
QUIC: resend handshake packets along with initial.
Roman Arutyunyan <arut@nginx.com>
parents:
8243
diff
changeset
|
3973 |
6201cef77b1d
QUIC: resend handshake packets along with initial.
Roman Arutyunyan <arut@nginx.com>
parents:
8243
diff
changeset
|
3974 ctx = ngx_quic_get_send_ctx(qc, ssl_encryption_handshake); |
6201cef77b1d
QUIC: resend handshake packets along with initial.
Roman Arutyunyan <arut@nginx.com>
parents:
8243
diff
changeset
|
3975 while (!ngx_queue_empty(&ctx->sent)) { |
6201cef77b1d
QUIC: resend handshake packets along with initial.
Roman Arutyunyan <arut@nginx.com>
parents:
8243
diff
changeset
|
3976 ngx_quic_resend_frames(c, ctx); |
6201cef77b1d
QUIC: resend handshake packets along with initial.
Roman Arutyunyan <arut@nginx.com>
parents:
8243
diff
changeset
|
3977 } |
8132
6226f834b420
QUIC: do not resend empty queue when speeding up handshake.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8131
diff
changeset
|
3978 } |
8104
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3979 } |
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3980 |
9588a2782c62
QUIC: speeding up handshake completion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8103
diff
changeset
|
3981 return NGX_OK; |
7812
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
3982 } |
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
3983 |
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
3984 |
76839f55bc48
Sorted functions and functions declarations.
Vladimir Homutov <vl@nginx.com>
parents:
7811
diff
changeset
|
3985 static ngx_int_t |
7855
81a4f98a2556
Cleaned up reordering code.
Vladimir Homutov <vl@nginx.com>
parents:
7854
diff
changeset
|
3986 ngx_quic_crypto_input(ngx_connection_t *c, ngx_quic_frame_t *frame, void *data) |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3987 { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3988 int n, sslerr; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3989 ngx_buf_t *b; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3990 ngx_chain_t *cl; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3991 ngx_ssl_conn_t *ssl_conn; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
3992 ngx_quic_connection_t *qc; |
7810
167d32476737
Crypto buffer frames reordering.
Vladimir Homutov <vl@nginx.com>
parents:
7809
diff
changeset
|
3993 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3994 qc = ngx_quic_get_connection(c); |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
3995 |
7691 | 3996 ssl_conn = c->ssl->connection; |
3997 | |
3998 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, | |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
3999 "quic SSL_quic_read_level:%d SSL_quic_write_level:%d", |
7691 | 4000 (int) SSL_quic_read_level(ssl_conn), |
4001 (int) SSL_quic_write_level(ssl_conn)); | |
4002 | |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4003 for (cl = frame->data; cl; cl = cl->next) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4004 b = cl->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4005 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4006 if (!SSL_provide_quic_data(ssl_conn, SSL_quic_read_level(ssl_conn), |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4007 b->pos, b->last - b->pos)) |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4008 { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4009 ngx_ssl_error(NGX_LOG_INFO, c->log, 0, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4010 "SSL_provide_quic_data() failed"); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4011 return NGX_ERROR; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4012 } |
7691 | 4013 } |
4014 | |
4015 n = SSL_do_handshake(ssl_conn); | |
4016 | |
8190
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4017 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4018 "quic SSL_quic_read_level:%d SSL_quic_write_level:%d", |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4019 (int) SSL_quic_read_level(ssl_conn), |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4020 (int) SSL_quic_write_level(ssl_conn)); |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4021 |
7691 | 4022 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_do_handshake: %d", n); |
4023 | |
8190
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4024 if (n <= 0) { |
7691 | 4025 sslerr = SSL_get_error(ssl_conn, n); |
4026 | |
4027 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_get_error: %d", | |
4028 sslerr); | |
4029 | |
7766
23a2b5e7acc8
Improved SSL_do_handshake() error handling in QUIC.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7765
diff
changeset
|
4030 if (sslerr != SSL_ERROR_WANT_READ) { |
7691 | 4031 ngx_ssl_error(NGX_LOG_ERR, c->log, 0, "SSL_do_handshake() failed"); |
7766
23a2b5e7acc8
Improved SSL_do_handshake() error handling in QUIC.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7765
diff
changeset
|
4032 return NGX_ERROR; |
7691 | 4033 } |
7729
1295b293d09a
Connection states code cleanup.
Vladimir Homutov <vl@nginx.com>
parents:
7726
diff
changeset
|
4034 |
8190
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4035 return NGX_OK; |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4036 } |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4037 |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4038 if (SSL_in_init(ssl_conn)) { |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4039 return NGX_OK; |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4040 } |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4041 |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4042 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4043 "quic ssl cipher:%s", SSL_get_cipher(ssl_conn)); |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4044 |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4045 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4046 "quic handshake completed successfully"); |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4047 |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4048 c->ssl->handshaked = 1; |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4049 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4050 frame = ngx_quic_alloc_frame(c); |
8190
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4051 if (frame == NULL) { |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4052 return NGX_ERROR; |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4053 } |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4054 |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4055 /* 12.4 Frames and frame types, figure 8 */ |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4056 frame->level = ssl_encryption_application; |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4057 frame->type = NGX_QUIC_FT_HANDSHAKE_DONE; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4058 ngx_quic_queue_frame(qc, frame); |
8190
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4059 |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4060 if (ngx_quic_send_new_token(c) != NGX_OK) { |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4061 return NGX_ERROR; |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4062 } |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4063 |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4064 /* |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4065 * Generating next keys before a key update is received. |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4066 * See quic-tls 9.4 Header Protection Timing Side-Channels. |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4067 */ |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4068 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4069 if (ngx_quic_keys_update(c, qc->keys) != NGX_OK) { |
8190
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4070 return NGX_ERROR; |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4071 } |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4072 |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4073 /* |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4074 * 4.10.2 An endpoint MUST discard its handshake keys |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4075 * when the TLS handshake is confirmed |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4076 */ |
d10118e38943
QUIC: refactored SSL_do_handshake() handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8189
diff
changeset
|
4077 ngx_quic_discard_ctx(c, ssl_encryption_handshake); |
7691 | 4078 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4079 if (ngx_quic_issue_server_ids(c) != NGX_OK) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4080 return NGX_ERROR; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4081 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4082 |
7691 | 4083 return NGX_OK; |
4084 } | |
4085 | |
4086 | |
4087 static ngx_int_t | |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4088 ngx_quic_handle_stream_frame(ngx_connection_t *c, ngx_quic_header_t *pkt, |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4089 ngx_quic_frame_t *frame) |
7691 | 4090 { |
8068
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4091 size_t window; |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4092 uint64_t last; |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4093 ngx_buf_t *b; |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4094 ngx_pool_t *pool; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4095 ngx_connection_t *sc; |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4096 ngx_quic_stream_t *sn; |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4097 ngx_quic_connection_t *qc; |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4098 ngx_quic_stream_frame_t *f; |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4099 ngx_quic_frames_stream_t *fs; |
7691 | 4100 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4101 qc = ngx_quic_get_connection(c); |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4102 f = &frame->u.stream; |
7691 | 4103 |
7922
d437ee1ce81e
Reject invalid STREAM ID with STREAM_STATE_ERROR connection error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7919
diff
changeset
|
4104 if ((f->stream_id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
d437ee1ce81e
Reject invalid STREAM ID with STREAM_STATE_ERROR connection error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7919
diff
changeset
|
4105 && (f->stream_id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
d437ee1ce81e
Reject invalid STREAM ID with STREAM_STATE_ERROR connection error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7919
diff
changeset
|
4106 { |
d437ee1ce81e
Reject invalid STREAM ID with STREAM_STATE_ERROR connection error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7919
diff
changeset
|
4107 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
d437ee1ce81e
Reject invalid STREAM ID with STREAM_STATE_ERROR connection error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7919
diff
changeset
|
4108 return NGX_ERROR; |
d437ee1ce81e
Reject invalid STREAM ID with STREAM_STATE_ERROR connection error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7919
diff
changeset
|
4109 } |
d437ee1ce81e
Reject invalid STREAM ID with STREAM_STATE_ERROR connection error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7919
diff
changeset
|
4110 |
8068
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4111 /* no overflow since both values are 62-bit */ |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4112 last = f->offset + f->length; |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4113 |
7691 | 4114 sn = ngx_quic_find_stream(&qc->streams.tree, f->stream_id); |
4115 | |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4116 if (sn == NULL) { |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4117 sn = ngx_quic_create_client_stream(c, f->stream_id); |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4118 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4119 if (sn == NULL) { |
7922
d437ee1ce81e
Reject invalid STREAM ID with STREAM_STATE_ERROR connection error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7919
diff
changeset
|
4120 return NGX_ERROR; |
d437ee1ce81e
Reject invalid STREAM ID with STREAM_STATE_ERROR connection error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7919
diff
changeset
|
4121 } |
d437ee1ce81e
Reject invalid STREAM ID with STREAM_STATE_ERROR connection error.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7919
diff
changeset
|
4122 |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4123 if (sn == NGX_QUIC_STREAM_GONE) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4124 return NGX_OK; |
8014
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
4125 } |
7814
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4126 |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4127 sc = sn->c; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4128 fs = &sn->fs; |
8068
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4129 b = sn->b; |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4130 window = b->end - b->last; |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4131 |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4132 if (last > window) { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4133 qc->error = NGX_QUIC_ERR_FLOW_CONTROL_ERROR; |
8068
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4134 goto cleanup; |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4135 } |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4136 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4137 if (ngx_quic_handle_ordered_frame(c, fs, frame, ngx_quic_stream_input, |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4138 sn) |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4139 != NGX_OK) |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4140 { |
8068
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4141 goto cleanup; |
7814
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4142 } |
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4143 |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4144 sc->listening->handler(sc); |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4145 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4146 return NGX_OK; |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4147 } |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4148 |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4149 fs = &sn->fs; |
8068
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4150 b = sn->b; |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4151 window = (b->pos - b->start) + (b->end - b->last); |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4152 |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4153 if (last > fs->received && last - fs->received > window) { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4154 qc->error = NGX_QUIC_ERR_FLOW_CONTROL_ERROR; |
8068
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4155 return NGX_ERROR; |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4156 } |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4157 |
7855
81a4f98a2556
Cleaned up reordering code.
Vladimir Homutov <vl@nginx.com>
parents:
7854
diff
changeset
|
4158 return ngx_quic_handle_ordered_frame(c, fs, frame, ngx_quic_stream_input, |
81a4f98a2556
Cleaned up reordering code.
Vladimir Homutov <vl@nginx.com>
parents:
7854
diff
changeset
|
4159 sn); |
8068
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4160 |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4161 cleanup: |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4162 |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4163 pool = sc->pool; |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4164 |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4165 ngx_close_connection(sc); |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4166 ngx_destroy_pool(pool); |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4167 |
f882b1784f30
QUIC: enforce flow control on incoming STREAM and CRYPTO frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8066
diff
changeset
|
4168 return NGX_ERROR; |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4169 } |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4170 |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4171 |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4172 static ngx_int_t |
7855
81a4f98a2556
Cleaned up reordering code.
Vladimir Homutov <vl@nginx.com>
parents:
7854
diff
changeset
|
4173 ngx_quic_stream_input(ngx_connection_t *c, ngx_quic_frame_t *frame, void *data) |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4174 { |
8019
fc16e303003a
QUIC: fixed possible use-after-free on stream cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8018
diff
changeset
|
4175 uint64_t id; |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4176 ngx_buf_t *b; |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4177 ngx_event_t *rev; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4178 ngx_chain_t *cl; |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4179 ngx_quic_stream_t *sn; |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4180 ngx_quic_connection_t *qc; |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4181 ngx_quic_stream_frame_t *f; |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4182 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4183 qc = ngx_quic_get_connection(c); |
7855
81a4f98a2556
Cleaned up reordering code.
Vladimir Homutov <vl@nginx.com>
parents:
7854
diff
changeset
|
4184 sn = data; |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4185 |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4186 f = &frame->u.stream; |
8019
fc16e303003a
QUIC: fixed possible use-after-free on stream cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8018
diff
changeset
|
4187 id = f->stream_id; |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4188 |
7691 | 4189 b = sn->b; |
7814
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4190 |
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4191 if ((size_t) ((b->pos - b->start) + (b->end - b->last)) < f->length) { |
7838 | 4192 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
4193 "quic no space in stream buffer"); | |
7814
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4194 return NGX_ERROR; |
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4195 } |
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4196 |
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4197 if ((size_t) (b->end - b->last) < f->length) { |
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4198 b->last = ngx_movemem(b->start, b->pos, b->last - b->pos); |
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4199 b->pos = b->start; |
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4200 } |
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4201 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4202 for (cl = frame->data; cl; cl = cl->next) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4203 b->last = ngx_cpymem(b->last, cl->buf->pos, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4204 cl->buf->last - cl->buf->pos); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4205 } |
7691 | 4206 |
7760
32db41d603cd
Fixed handling QUIC stream eof.
Roman Arutyunyan <arut@nginx.com>
parents:
7759
diff
changeset
|
4207 rev = sn->c->read; |
32db41d603cd
Fixed handling QUIC stream eof.
Roman Arutyunyan <arut@nginx.com>
parents:
7759
diff
changeset
|
4208 rev->ready = 1; |
32db41d603cd
Fixed handling QUIC stream eof.
Roman Arutyunyan <arut@nginx.com>
parents:
7759
diff
changeset
|
4209 |
32db41d603cd
Fixed handling QUIC stream eof.
Roman Arutyunyan <arut@nginx.com>
parents:
7759
diff
changeset
|
4210 if (f->fin) { |
32db41d603cd
Fixed handling QUIC stream eof.
Roman Arutyunyan <arut@nginx.com>
parents:
7759
diff
changeset
|
4211 rev->pending_eof = 1; |
32db41d603cd
Fixed handling QUIC stream eof.
Roman Arutyunyan <arut@nginx.com>
parents:
7759
diff
changeset
|
4212 } |
7691 | 4213 |
7814
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4214 if (rev->active) { |
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4215 rev->handler(rev); |
7780
de8981bf2dd5
Advertizing MAX_STREAMS (0x12) credit in advance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7778
diff
changeset
|
4216 } |
de8981bf2dd5
Advertizing MAX_STREAMS (0x12) credit in advance.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7778
diff
changeset
|
4217 |
7814
ab443e80d9e4
Create new stream immediately on receiving new stream id.
Vladimir Homutov <vl@nginx.com>
parents:
7813
diff
changeset
|
4218 /* check if stream was destroyed by handler */ |
8019
fc16e303003a
QUIC: fixed possible use-after-free on stream cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8018
diff
changeset
|
4219 if (ngx_quic_find_stream(&qc->streams.tree, id) == NULL) { |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4220 return NGX_DONE; |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4221 } |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
4222 |
7691 | 4223 return NGX_OK; |
4224 } | |
4225 | |
4226 | |
7711
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
4227 static ngx_int_t |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4228 ngx_quic_handle_max_data_frame(ngx_connection_t *c, |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4229 ngx_quic_max_data_frame_t *f) |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4230 { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4231 ngx_event_t *wev; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4232 ngx_rbtree_t *tree; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4233 ngx_rbtree_node_t *node; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4234 ngx_quic_stream_t *qs; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4235 ngx_quic_connection_t *qc; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4236 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4237 qc = ngx_quic_get_connection(c); |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4238 tree = &qc->streams.tree; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4239 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4240 if (f->max_data <= qc->streams.send_max_data) { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4241 return NGX_OK; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4242 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4243 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4244 if (qc->streams.sent >= qc->streams.send_max_data) { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4245 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4246 for (node = ngx_rbtree_min(tree->root, tree->sentinel); |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4247 node; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4248 node = ngx_rbtree_next(tree, node)) |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4249 { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4250 qs = (ngx_quic_stream_t *) node; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4251 wev = qs->c->write; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4252 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4253 if (wev->active) { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4254 wev->ready = 1; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4255 ngx_post_event(wev, &ngx_posted_events); |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4256 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4257 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4258 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4259 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4260 qc->streams.send_max_data = f->max_data; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4261 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4262 return NGX_OK; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4263 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4264 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4265 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4266 static ngx_int_t |
7711
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
4267 ngx_quic_handle_streams_blocked_frame(ngx_connection_t *c, |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
4268 ngx_quic_header_t *pkt, ngx_quic_streams_blocked_frame_t *f) |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
4269 { |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
4270 return NGX_OK; |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
4271 } |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
4272 |
a14afe21e692
Double MAX_STREAMS on STREAMS_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
7707
diff
changeset
|
4273 |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4274 static ngx_int_t |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4275 ngx_quic_handle_stream_data_blocked_frame(ngx_connection_t *c, |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4276 ngx_quic_header_t *pkt, ngx_quic_stream_data_blocked_frame_t *f) |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4277 { |
7746
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
4278 size_t n; |
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
4279 ngx_buf_t *b; |
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
4280 ngx_quic_frame_t *frame; |
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
4281 ngx_quic_stream_t *sn; |
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
4282 ngx_quic_connection_t *qc; |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4283 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4284 qc = ngx_quic_get_connection(c); |
7924
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4285 |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4286 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4287 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4288 { |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4289 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4290 return NGX_ERROR; |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4291 } |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4292 |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4293 sn = ngx_quic_find_stream(&qc->streams.tree, f->id); |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4294 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4295 if (sn == NULL) { |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4296 sn = ngx_quic_create_client_stream(c, f->id); |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4297 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4298 if (sn == NULL) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4299 return NGX_ERROR; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4300 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4301 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4302 if (sn == NGX_QUIC_STREAM_GONE) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4303 return NGX_OK; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4304 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4305 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4306 b = sn->b; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4307 n = b->end - b->last; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4308 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4309 sn->c->listening->handler(sn->c); |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4310 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4311 } else { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4312 b = sn->b; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4313 n = sn->fs.received + (b->pos - b->start) + (b->end - b->last); |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4314 } |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4315 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4316 frame = ngx_quic_alloc_frame(c); |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4317 if (frame == NULL) { |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4318 return NGX_ERROR; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4319 } |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4320 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4321 frame->level = pkt->level; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4322 frame->type = NGX_QUIC_FT_MAX_STREAM_DATA; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4323 frame->u.max_stream_data.id = f->id; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4324 frame->u.max_stream_data.limit = n; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4325 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4326 ngx_quic_queue_frame(qc, frame); |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4327 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4328 return NGX_OK; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4329 } |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4330 |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
4331 |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4332 static ngx_int_t |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4333 ngx_quic_handle_max_stream_data_frame(ngx_connection_t *c, |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4334 ngx_quic_header_t *pkt, ngx_quic_max_stream_data_frame_t *f) |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4335 { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4336 uint64_t sent; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4337 ngx_event_t *wev; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4338 ngx_quic_stream_t *sn; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4339 ngx_quic_connection_t *qc; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4340 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4341 qc = ngx_quic_get_connection(c); |
7924
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4342 |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4343 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4344 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0) |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4345 { |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4346 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4347 return NGX_ERROR; |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4348 } |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4349 |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4350 sn = ngx_quic_find_stream(&qc->streams.tree, f->id); |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4351 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4352 if (sn == NULL) { |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4353 sn = ngx_quic_create_client_stream(c, f->id); |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4354 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4355 if (sn == NULL) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4356 return NGX_ERROR; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4357 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4358 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4359 if (sn == NGX_QUIC_STREAM_GONE) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4360 return NGX_OK; |
7924
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4361 } |
8fc9fcf18608
Stream ID handling in MAX_STREAM_DATA and STREAM_DATA_BLOCKED.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7923
diff
changeset
|
4362 |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4363 if (f->limit > sn->send_max_data) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4364 sn->send_max_data = f->limit; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4365 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4366 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4367 sn->c->listening->handler(sn->c); |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4368 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
4369 return NGX_OK; |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4370 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4371 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4372 if (f->limit <= sn->send_max_data) { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4373 return NGX_OK; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4374 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4375 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4376 sent = sn->c->sent; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4377 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4378 if (sent >= sn->send_max_data) { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4379 wev = sn->c->write; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4380 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4381 if (wev->active) { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4382 wev->ready = 1; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4383 ngx_post_event(wev, &ngx_posted_events); |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4384 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4385 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4386 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4387 sn->send_max_data = f->limit; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4388 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4389 return NGX_OK; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4390 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4391 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
4392 |
7923
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4393 static ngx_int_t |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4394 ngx_quic_handle_reset_stream_frame(ngx_connection_t *c, |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4395 ngx_quic_header_t *pkt, ngx_quic_reset_stream_frame_t *f) |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4396 { |
8023
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4397 ngx_event_t *rev; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4398 ngx_connection_t *sc; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4399 ngx_quic_stream_t *sn; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4400 ngx_quic_connection_t *qc; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4401 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4402 qc = ngx_quic_get_connection(c); |
7923
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4403 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4404 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4405 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4406 { |
8023
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4407 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
7923
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4408 return NGX_ERROR; |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4409 } |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4410 |
8023
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4411 sn = ngx_quic_find_stream(&qc->streams.tree, f->id); |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4412 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4413 if (sn == NULL) { |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4414 sn = ngx_quic_create_client_stream(c, f->id); |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4415 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4416 if (sn == NULL) { |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4417 return NGX_ERROR; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4418 } |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4419 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4420 if (sn == NGX_QUIC_STREAM_GONE) { |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4421 return NGX_OK; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4422 } |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4423 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4424 sc = sn->c; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4425 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4426 rev = sc->read; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4427 rev->error = 1; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4428 rev->ready = 1; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4429 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4430 sc->listening->handler(sc); |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4431 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4432 return NGX_OK; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4433 } |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4434 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4435 rev = sn->c->read; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4436 rev->error = 1; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4437 rev->ready = 1; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4438 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4439 if (rev->active) { |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4440 rev->handler(rev); |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4441 } |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4442 |
7923
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4443 return NGX_OK; |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4444 } |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4445 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4446 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4447 static ngx_int_t |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4448 ngx_quic_handle_stop_sending_frame(ngx_connection_t *c, |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4449 ngx_quic_header_t *pkt, ngx_quic_stop_sending_frame_t *f) |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4450 { |
8023
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4451 ngx_event_t *wev; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4452 ngx_connection_t *sc; |
7923
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4453 ngx_quic_stream_t *sn; |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4454 ngx_quic_connection_t *qc; |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4455 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4456 qc = ngx_quic_get_connection(c); |
7923
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4457 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4458 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4459 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0) |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4460 { |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4461 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4462 return NGX_ERROR; |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4463 } |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4464 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4465 sn = ngx_quic_find_stream(&qc->streams.tree, f->id); |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4466 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4467 if (sn == NULL) { |
8023
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4468 sn = ngx_quic_create_client_stream(c, f->id); |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4469 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4470 if (sn == NULL) { |
7923
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4471 return NGX_ERROR; |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4472 } |
8023
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4473 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4474 if (sn == NGX_QUIC_STREAM_GONE) { |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4475 return NGX_OK; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4476 } |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4477 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4478 sc = sn->c; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4479 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4480 wev = sc->write; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4481 wev->error = 1; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4482 wev->ready = 1; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4483 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4484 sc->listening->handler(sc); |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4485 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4486 return NGX_OK; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4487 } |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4488 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4489 wev = sn->c->write; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4490 wev->error = 1; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4491 wev->ready = 1; |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4492 |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4493 if (wev->active) { |
240931629995
QUIC: handle client RESET_STREAM and STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8022
diff
changeset
|
4494 wev->handler(wev); |
7923
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4495 } |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4496 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4497 return NGX_OK; |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4498 } |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4499 |
953cf44708b0
Stream ID handling in RESET_STREAM and STOP_SENDING frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7922
diff
changeset
|
4500 |
8013
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4501 static ngx_int_t |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4502 ngx_quic_handle_max_streams_frame(ngx_connection_t *c, |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4503 ngx_quic_header_t *pkt, ngx_quic_max_streams_frame_t *f) |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4504 { |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4505 ngx_quic_connection_t *qc; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4506 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4507 qc = ngx_quic_get_connection(c); |
8013
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4508 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4509 if (f->bidi) { |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4510 if (qc->streams.server_max_streams_bidi < f->limit) { |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4511 qc->streams.server_max_streams_bidi = f->limit; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4512 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4513 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4514 "quic max_streams_bidi:%uL", f->limit); |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4515 } |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4516 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4517 } else { |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4518 if (qc->streams.server_max_streams_uni < f->limit) { |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4519 qc->streams.server_max_streams_uni = f->limit; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4520 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4521 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4522 "quic max_streams_uni:%uL", f->limit); |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4523 } |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4524 } |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4525 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4526 return NGX_OK; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4527 } |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4528 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
4529 |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4530 static ngx_int_t |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4531 ngx_quic_handle_path_challenge_frame(ngx_connection_t *c, |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4532 ngx_quic_header_t *pkt, ngx_quic_path_challenge_frame_t *f) |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4533 { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4534 ngx_quic_frame_t *frame; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4535 ngx_quic_connection_t *qc; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4536 |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4537 qc = ngx_quic_get_connection(c); |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4538 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4539 frame = ngx_quic_alloc_frame(c); |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4540 if (frame == NULL) { |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4541 return NGX_ERROR; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4542 } |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4543 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4544 frame->level = pkt->level; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4545 frame->type = NGX_QUIC_FT_PATH_RESPONSE; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4546 frame->u.path_response = *f; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4547 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4548 ngx_quic_queue_frame(qc, frame); |
8069
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4549 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4550 return NGX_OK; |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4551 } |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4552 |
4ff2a0b747d1
QUIC: handle PATH_CHALLENGE frame.
Roman Arutyunyan <arut@nginx.com>
parents:
8068
diff
changeset
|
4553 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4554 static ngx_int_t |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4555 ngx_quic_handle_new_connection_id_frame(ngx_connection_t *c, |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4556 ngx_quic_header_t *pkt, ngx_quic_new_conn_id_frame_t *f) |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4557 { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4558 ngx_queue_t *q; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4559 ngx_quic_client_id_t *cid, *item; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4560 ngx_quic_connection_t *qc; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4561 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4562 qc = ngx_quic_get_connection(c); |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4563 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4564 if (f->seqnum < qc->max_retired_seqnum) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4565 /* |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4566 * An endpoint that receives a NEW_CONNECTION_ID frame with |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4567 * a sequence number smaller than the Retire Prior To field |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4568 * of a previously received NEW_CONNECTION_ID frame MUST send |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4569 * a corresponding RETIRE_CONNECTION_ID frame that retires |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4570 * the newly received connection ID, unless it has already |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4571 * done so for that sequence number. |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4572 */ |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4573 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4574 if (ngx_quic_retire_connection_id(c, pkt->level, f->seqnum) != NGX_OK) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4575 return NGX_ERROR; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4576 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4577 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4578 goto retire; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4579 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4580 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4581 cid = NULL; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4582 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4583 for (q = ngx_queue_head(&qc->client_ids); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4584 q != ngx_queue_sentinel(&qc->client_ids); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4585 q = ngx_queue_next(q)) |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4586 { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4587 item = ngx_queue_data(q, ngx_quic_client_id_t, queue); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4588 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4589 if (item->seqnum == f->seqnum) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4590 cid = item; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4591 break; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4592 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4593 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4594 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4595 if (cid) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4596 /* |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4597 * Transmission errors, timeouts and retransmissions might cause the |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4598 * same NEW_CONNECTION_ID frame to be received multiple times |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4599 */ |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4600 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4601 if (cid->len != f->len |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4602 || ngx_strncmp(cid->id, f->cid, f->len) != 0 |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
4603 || ngx_strncmp(cid->sr_token, f->srt, NGX_QUIC_SR_TOKEN_LEN) != 0) |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4604 { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4605 /* |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4606 * ..a sequence number is used for different connection IDs, |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4607 * the endpoint MAY treat that receipt as a connection error |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4608 * of type PROTOCOL_VIOLATION. |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4609 */ |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4610 qc->error = NGX_QUIC_ERR_PROTOCOL_VIOLATION; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4611 qc->error_reason = "seqnum refers to different connection id/token"; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4612 return NGX_ERROR; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4613 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4614 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4615 } else { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4616 |
8197
405b6e8eb523
QUIC: renamed field and function related to client ids.
Roman Arutyunyan <arut@nginx.com>
parents:
8196
diff
changeset
|
4617 cid = ngx_quic_alloc_client_id(c, qc); |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4618 if (cid == NULL) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4619 return NGX_ERROR; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4620 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4621 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4622 cid->seqnum = f->seqnum; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4623 cid->len = f->len; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4624 ngx_memcpy(cid->id, f->cid, f->len); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4625 |
8100
b31c02454539
QUIC: added stateless reset support.
Vladimir Homutov <vl@nginx.com>
parents:
8099
diff
changeset
|
4626 ngx_memcpy(cid->sr_token, f->srt, NGX_QUIC_SR_TOKEN_LEN); |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4627 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4628 ngx_queue_insert_tail(&qc->client_ids, &cid->queue); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4629 qc->nclient_ids++; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4630 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4631 /* always use latest available connection id */ |
8197
405b6e8eb523
QUIC: renamed field and function related to client ids.
Roman Arutyunyan <arut@nginx.com>
parents:
8196
diff
changeset
|
4632 if (f->seqnum > qc->client_seqnum) { |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4633 qc->scid.len = cid->len; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4634 qc->scid.data = cid->id; |
8197
405b6e8eb523
QUIC: renamed field and function related to client ids.
Roman Arutyunyan <arut@nginx.com>
parents:
8196
diff
changeset
|
4635 qc->client_seqnum = f->seqnum; |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4636 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4637 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4638 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4639 retire: |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4640 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4641 if (qc->max_retired_seqnum && f->retire <= qc->max_retired_seqnum) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4642 /* |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4643 * Once a sender indicates a Retire Prior To value, smaller values sent |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4644 * in subsequent NEW_CONNECTION_ID frames have no effect. A receiver |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4645 * MUST ignore any Retire Prior To fields that do not increase the |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4646 * largest received Retire Prior To value. |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4647 */ |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4648 goto done; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4649 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4650 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4651 qc->max_retired_seqnum = f->retire; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4652 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4653 q = ngx_queue_head(&qc->client_ids); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4654 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4655 while (q != ngx_queue_sentinel(&qc->client_ids)) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4656 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4657 cid = ngx_queue_data(q, ngx_quic_client_id_t, queue); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4658 q = ngx_queue_next(q); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4659 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4660 if (cid->seqnum >= f->retire) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4661 continue; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4662 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4663 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4664 /* this connection id must be retired */ |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4665 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4666 if (ngx_quic_retire_connection_id(c, pkt->level, cid->seqnum) |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4667 != NGX_OK) |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4668 { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4669 return NGX_ERROR; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4670 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4671 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4672 ngx_queue_remove(&cid->queue); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4673 ngx_queue_insert_head(&qc->free_client_ids, &cid->queue); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4674 qc->nclient_ids--; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4675 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4676 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4677 done: |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4678 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4679 if (qc->nclient_ids > qc->tp.active_connection_id_limit) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4680 /* |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4681 * After processing a NEW_CONNECTION_ID frame and |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4682 * adding and retiring active connection IDs, if the number of active |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4683 * connection IDs exceeds the value advertised in its |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4684 * active_connection_id_limit transport parameter, an endpoint MUST |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4685 * close the connection with an error of type CONNECTION_ID_LIMIT_ERROR. |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4686 */ |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4687 qc->error = NGX_QUIC_ERR_CONNECTION_ID_LIMIT_ERROR; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4688 qc->error_reason = "too many connection ids received"; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4689 return NGX_ERROR; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4690 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4691 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4692 return NGX_OK; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4693 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4694 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4695 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4696 static ngx_int_t |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4697 ngx_quic_retire_connection_id(ngx_connection_t *c, |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4698 enum ssl_encryption_level_t level, uint64_t seqnum) |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4699 { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4700 ngx_quic_frame_t *frame; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4701 ngx_quic_connection_t *qc; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4702 |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4703 qc = ngx_quic_get_connection(c); |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4704 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4705 frame = ngx_quic_alloc_frame(c); |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4706 if (frame == NULL) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4707 return NGX_ERROR; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4708 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4709 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4710 frame->level = level; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4711 frame->type = NGX_QUIC_FT_RETIRE_CONNECTION_ID; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4712 frame->u.retire_cid.sequence_number = seqnum; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4713 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4714 ngx_quic_queue_frame(qc, frame); |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4715 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4716 return NGX_OK; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4717 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4718 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4719 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4720 static ngx_int_t |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4721 ngx_quic_handle_retire_connection_id_frame(ngx_connection_t *c, |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4722 ngx_quic_header_t *pkt, ngx_quic_retire_cid_frame_t *f) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4723 { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4724 ngx_queue_t *q; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4725 ngx_quic_server_id_t *sid; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4726 ngx_quic_connection_t *qc; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4727 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4728 qc = ngx_quic_get_connection(c); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4729 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4730 for (q = ngx_queue_head(&qc->server_ids); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4731 q != ngx_queue_sentinel(&qc->server_ids); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4732 q = ngx_queue_next(q)) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4733 { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4734 sid = ngx_queue_data(q, ngx_quic_server_id_t, queue); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4735 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4736 if (sid->seqnum == f->sequence_number) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4737 ngx_queue_remove(q); |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4738 ngx_queue_insert_tail(&qc->free_server_ids, &sid->queue); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4739 ngx_rbtree_delete(&c->listening->rbtree, &sid->udp.node); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4740 qc->nserver_ids--; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4741 break; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4742 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4743 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4744 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4745 return ngx_quic_issue_server_ids(c); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4746 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4747 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4748 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4749 static ngx_int_t |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4750 ngx_quic_issue_server_ids(ngx_connection_t *c) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4751 { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4752 ngx_str_t dcid; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4753 ngx_uint_t n; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4754 ngx_quic_frame_t *frame; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4755 ngx_quic_server_id_t *sid; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4756 ngx_quic_connection_t *qc; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4757 u_char id[NGX_QUIC_SERVER_CID_LEN]; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4758 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4759 qc = ngx_quic_get_connection(c); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4760 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4761 n = ngx_min(NGX_QUIC_MAX_SERVER_IDS, qc->ctp.active_connection_id_limit); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4762 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4763 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4764 "quic issue server ids has:%ui max:%ui", qc->nserver_ids, n); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4765 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4766 while (qc->nserver_ids < n) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4767 if (ngx_quic_create_server_id(c, id) != NGX_OK) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4768 return NGX_ERROR; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4769 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4770 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4771 dcid.len = NGX_QUIC_SERVER_CID_LEN; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4772 dcid.data = id; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4773 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4774 sid = ngx_quic_insert_server_id(c, &dcid); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4775 if (sid == NULL) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4776 return NGX_ERROR; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4777 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4778 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
4779 frame = ngx_quic_alloc_frame(c); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4780 if (frame == NULL) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4781 return NGX_ERROR; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4782 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4783 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4784 frame->level = ssl_encryption_application; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4785 frame->type = NGX_QUIC_FT_NEW_CONNECTION_ID; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4786 frame->u.ncid.seqnum = sid->seqnum; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4787 frame->u.ncid.retire = 0; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4788 frame->u.ncid.len = NGX_QUIC_SERVER_CID_LEN; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4789 ngx_memcpy(frame->u.ncid.cid, id, NGX_QUIC_SERVER_CID_LEN); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4790 |
8287
cef042935003
QUIC: the "quic_host_key" directive.
Vladimir Homutov <vl@nginx.com>
parents:
8286
diff
changeset
|
4791 if (ngx_quic_new_sr_token(c, &dcid, qc->conf->sr_token_key, |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4792 frame->u.ncid.srt) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4793 != NGX_OK) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4794 { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4795 return NGX_ERROR; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4796 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4797 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4798 ngx_quic_queue_frame(qc, frame); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4799 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4800 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4801 return NGX_OK; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4802 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4803 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4804 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4805 static void |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4806 ngx_quic_clear_temp_server_ids(ngx_connection_t *c) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4807 { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4808 ngx_queue_t *q, *next; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4809 ngx_quic_server_id_t *sid; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4810 ngx_quic_connection_t *qc; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4811 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4812 qc = ngx_quic_get_connection(c); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4813 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4814 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4815 "quic clear temp server ids"); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4816 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4817 for (q = ngx_queue_head(&qc->server_ids); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4818 q != ngx_queue_sentinel(&qc->server_ids); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4819 q = next) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4820 { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4821 next = ngx_queue_next(q); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4822 sid = ngx_queue_data(q, ngx_quic_server_id_t, queue); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4823 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4824 if (sid->seqnum != NGX_QUIC_UNSET_PN) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4825 continue; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4826 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4827 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4828 ngx_queue_remove(q); |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4829 ngx_queue_insert_tail(&qc->free_server_ids, &sid->queue); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4830 ngx_rbtree_delete(&c->listening->rbtree, &sid->udp.node); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4831 qc->nserver_ids--; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4832 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4833 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4834 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4835 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4836 static ngx_quic_server_id_t * |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4837 ngx_quic_insert_server_id(ngx_connection_t *c, ngx_str_t *id) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4838 { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4839 ngx_str_t dcid; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4840 ngx_quic_server_id_t *sid; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4841 ngx_quic_connection_t *qc; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4842 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4843 qc = ngx_quic_get_connection(c); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4844 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4845 sid = ngx_quic_alloc_server_id(c, qc); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4846 if (sid == NULL) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4847 return NULL; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4848 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4849 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4850 sid->seqnum = qc->server_seqnum; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4851 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4852 if (qc->server_seqnum != NGX_QUIC_UNSET_PN) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4853 qc->server_seqnum++; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4854 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4855 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4856 sid->len = id->len; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4857 ngx_memcpy(sid->id, id->data, id->len); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4858 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4859 ngx_queue_insert_tail(&qc->server_ids, &sid->queue); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4860 qc->nserver_ids++; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4861 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4862 dcid.data = sid->id; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4863 dcid.len = sid->len; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4864 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4865 ngx_insert_udp_connection(c, &sid->udp, &dcid); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4866 |
8235
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
4867 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
4868 "quic insert server id seqnum:%uL id len:%uz %xV", |
dbad2d6d1898
QUIC: removed ngx_quic_hexdump() macro.
Vladimir Homutov <vl@nginx.com>
parents:
8212
diff
changeset
|
4869 sid->seqnum, id->len, id); |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4870 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4871 return sid; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4872 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4873 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4874 |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4875 static ngx_quic_client_id_t * |
8197
405b6e8eb523
QUIC: renamed field and function related to client ids.
Roman Arutyunyan <arut@nginx.com>
parents:
8196
diff
changeset
|
4876 ngx_quic_alloc_client_id(ngx_connection_t *c, ngx_quic_connection_t *qc) |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4877 { |
8099
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
4878 ngx_queue_t *q; |
b4ef79ef1c23
QUIC: refined the "c->quic->initialized" flag usage.
Vladimir Homutov <vl@nginx.com>
parents:
8098
diff
changeset
|
4879 ngx_quic_client_id_t *cid; |
8076
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4880 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4881 if (!ngx_queue_empty(&qc->free_client_ids)) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4882 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4883 q = ngx_queue_head(&qc->free_client_ids); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4884 cid = ngx_queue_data(q, ngx_quic_client_id_t, queue); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4885 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4886 ngx_queue_remove(&cid->queue); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4887 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4888 ngx_memzero(cid, sizeof(ngx_quic_client_id_t)); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4889 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4890 } else { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4891 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4892 cid = ngx_pcalloc(c->pool, sizeof(ngx_quic_client_id_t)); |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4893 if (cid == NULL) { |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4894 return NULL; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4895 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4896 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4897 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4898 return cid; |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4899 } |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4900 |
3afaaaa930ab
QUIC: added support for multiple connection IDs.
Vladimir Homutov <vl@nginx.com>
parents:
8074
diff
changeset
|
4901 |
8198
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4902 static ngx_quic_server_id_t * |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4903 ngx_quic_alloc_server_id(ngx_connection_t *c, ngx_quic_connection_t *qc) |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4904 { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4905 ngx_queue_t *q; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4906 ngx_quic_server_id_t *sid; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4907 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4908 if (!ngx_queue_empty(&qc->free_server_ids)) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4909 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4910 q = ngx_queue_head(&qc->free_server_ids); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4911 sid = ngx_queue_data(q, ngx_quic_server_id_t, queue); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4912 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4913 ngx_queue_remove(&sid->queue); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4914 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4915 ngx_memzero(sid, sizeof(ngx_quic_server_id_t)); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4916 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4917 } else { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4918 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4919 sid = ngx_pcalloc(c->pool, sizeof(ngx_quic_server_id_t)); |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4920 if (sid == NULL) { |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4921 return NULL; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4922 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4923 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4924 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4925 return sid; |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4926 } |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4927 |
45db1b5c1706
QUIC: connection multiplexing per port.
Roman Arutyunyan <arut@nginx.com>
parents:
8197
diff
changeset
|
4928 |
7691 | 4929 static void |
4930 ngx_quic_queue_frame(ngx_quic_connection_t *qc, ngx_quic_frame_t *frame) | |
4931 { | |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
4932 ngx_quic_send_ctx_t *ctx; |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
4933 |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
4934 ctx = ngx_quic_get_send_ctx(qc, frame->level); |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
4935 |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
4936 ngx_queue_insert_tail(&ctx->frames, &frame->queue); |
7775 | 4937 |
7994
f9fbeb4ee0de
QUIC: added limit of queued data.
Vladimir Homutov <vl@nginx.com>
parents:
7993
diff
changeset
|
4938 frame->len = ngx_quic_create_frame(NULL, frame); |
f9fbeb4ee0de
QUIC: added limit of queued data.
Vladimir Homutov <vl@nginx.com>
parents:
7993
diff
changeset
|
4939 /* always succeeds */ |
f9fbeb4ee0de
QUIC: added limit of queued data.
Vladimir Homutov <vl@nginx.com>
parents:
7993
diff
changeset
|
4940 |
f9fbeb4ee0de
QUIC: added limit of queued data.
Vladimir Homutov <vl@nginx.com>
parents:
7993
diff
changeset
|
4941 if (qc->closing) { |
f9fbeb4ee0de
QUIC: added limit of queued data.
Vladimir Homutov <vl@nginx.com>
parents:
7993
diff
changeset
|
4942 return; |
f9fbeb4ee0de
QUIC: added limit of queued data.
Vladimir Homutov <vl@nginx.com>
parents:
7993
diff
changeset
|
4943 } |
f9fbeb4ee0de
QUIC: added limit of queued data.
Vladimir Homutov <vl@nginx.com>
parents:
7993
diff
changeset
|
4944 |
8055
924882f42dea
QUIC: do not artificially delay sending queued frames.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8054
diff
changeset
|
4945 ngx_post_event(&qc->push, &ngx_posted_events); |
7691 | 4946 } |
4947 | |
4948 | |
4949 static ngx_int_t | |
4950 ngx_quic_output(ngx_connection_t *c) | |
4951 { | |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4952 off_t max; |
8320
98bacfc65c61
QUIC: set idle timer when sending an ack-eliciting packet.
Roman Arutyunyan <arut@nginx.com>
parents:
8296
diff
changeset
|
4953 size_t len, min, in_flight; |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4954 ssize_t n; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4955 u_char *p; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4956 ngx_uint_t i, pad; |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
4957 ngx_quic_send_ctx_t *ctx; |
8320
98bacfc65c61
QUIC: set idle timer when sending an ack-eliciting packet.
Roman Arutyunyan <arut@nginx.com>
parents:
8296
diff
changeset
|
4958 ngx_quic_congestion_t *cg; |
7691 | 4959 ngx_quic_connection_t *qc; |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4960 static u_char dst[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; |
7691 | 4961 |
7741 | 4962 c->log->action = "sending frames"; |
4963 | |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
4964 qc = ngx_quic_get_connection(c); |
8320
98bacfc65c61
QUIC: set idle timer when sending an ack-eliciting packet.
Roman Arutyunyan <arut@nginx.com>
parents:
8296
diff
changeset
|
4965 cg = &qc->congestion; |
98bacfc65c61
QUIC: set idle timer when sending an ack-eliciting packet.
Roman Arutyunyan <arut@nginx.com>
parents:
8296
diff
changeset
|
4966 |
98bacfc65c61
QUIC: set idle timer when sending an ack-eliciting packet.
Roman Arutyunyan <arut@nginx.com>
parents:
8296
diff
changeset
|
4967 in_flight = cg->in_flight; |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
4968 |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4969 for ( ;; ) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4970 p = dst; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4971 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4972 len = ngx_min(qc->ctp.max_udp_payload_size, |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4973 NGX_QUIC_MAX_UDP_PAYLOAD_SIZE); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4974 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4975 if (!qc->validated) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4976 max = qc->received * 3; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4977 max = (c->sent >= max) ? 0 : max - c->sent; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4978 len = ngx_min(len, (size_t) max); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4979 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4980 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4981 pad = ngx_quic_get_padding_level(c); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4982 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4983 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4984 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4985 ctx = &qc->send_ctx[i]; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4986 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4987 if (ngx_quic_generate_ack(c, ctx) != NGX_OK) { |
8155
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
4988 return NGX_ERROR; |
38c7dd720774
QUIC: added ACK frame range support.
Vladimir Homutov <vl@nginx.com>
parents:
8154
diff
changeset
|
4989 } |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4990 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4991 min = (i == pad && p - dst < NGX_QUIC_MIN_INITIAL_SIZE) |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4992 ? NGX_QUIC_MIN_INITIAL_SIZE - (p - dst) : 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4993 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4994 n = ngx_quic_output_packet(c, ctx, p, len, min); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4995 if (n == NGX_ERROR) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4996 return NGX_ERROR; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4997 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4998 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
4999 p += n; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5000 len -= n; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5001 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5002 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5003 len = p - dst; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5004 if (len == 0) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5005 break; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5006 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5007 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5008 n = ngx_quic_send(c, dst, len); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5009 if (n == NGX_ERROR) { |
7691 | 5010 return NGX_ERROR; |
5011 } | |
8320
98bacfc65c61
QUIC: set idle timer when sending an ack-eliciting packet.
Roman Arutyunyan <arut@nginx.com>
parents:
8296
diff
changeset
|
5012 } |
98bacfc65c61
QUIC: set idle timer when sending an ack-eliciting packet.
Roman Arutyunyan <arut@nginx.com>
parents:
8296
diff
changeset
|
5013 |
98bacfc65c61
QUIC: set idle timer when sending an ack-eliciting packet.
Roman Arutyunyan <arut@nginx.com>
parents:
8296
diff
changeset
|
5014 if (in_flight != cg->in_flight && !qc->send_timer_set && !qc->closing) { |
98bacfc65c61
QUIC: set idle timer when sending an ack-eliciting packet.
Roman Arutyunyan <arut@nginx.com>
parents:
8296
diff
changeset
|
5015 qc->send_timer_set = 1; |
98bacfc65c61
QUIC: set idle timer when sending an ack-eliciting packet.
Roman Arutyunyan <arut@nginx.com>
parents:
8296
diff
changeset
|
5016 ngx_add_timer(c->read, qc->tp.max_idle_timeout); |
7737
8e54a17dabee
Respect QUIC max_idle_timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
7736
diff
changeset
|
5017 } |
8e54a17dabee
Respect QUIC max_idle_timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
7736
diff
changeset
|
5018 |
8290
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5019 ngx_quic_set_lost_timer(c); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5020 |
7691 | 5021 return NGX_OK; |
5022 } | |
5023 | |
5024 | |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5025 static ngx_uint_t |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5026 ngx_quic_get_padding_level(ngx_connection_t *c) |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5027 { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5028 ngx_queue_t *q; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5029 ngx_quic_frame_t *f; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5030 ngx_quic_send_ctx_t *ctx; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5031 ngx_quic_connection_t *qc; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5032 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5033 /* |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5034 * 14.1. Initial Datagram Size |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5035 * |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5036 * Similarly, a server MUST expand the payload of all UDP datagrams |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5037 * carrying ack-eliciting Initial packets to at least the smallest |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5038 * allowed maximum datagram size of 1200 bytes |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5039 */ |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5040 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5041 qc = ngx_quic_get_connection(c); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5042 ctx = ngx_quic_get_send_ctx(qc, ssl_encryption_initial); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5043 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5044 for (q = ngx_queue_head(&ctx->frames); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5045 q != ngx_queue_sentinel(&ctx->frames); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5046 q = ngx_queue_next(q)) |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5047 { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5048 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5049 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5050 if (f->need_ack) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5051 ctx = ngx_quic_get_send_ctx(qc, ssl_encryption_handshake); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5052 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5053 if (ngx_queue_empty(&ctx->frames)) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5054 return 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5055 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5056 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5057 return 1; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5058 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5059 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5060 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5061 return NGX_QUIC_SEND_CTX_LAST; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5062 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5063 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5064 |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5065 static ngx_int_t |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5066 ngx_quic_generate_ack(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx) |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5067 { |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5068 ngx_msec_t delay; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5069 ngx_quic_connection_t *qc; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5070 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5071 if (!ctx->send_ack) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5072 return NGX_OK; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5073 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5074 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5075 if (ctx->level == ssl_encryption_application) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5076 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5077 delay = ngx_current_msec - ctx->ack_delay_start; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5078 qc = ngx_quic_get_connection(c); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5079 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5080 if (ctx->send_ack < NGX_QUIC_MAX_ACK_GAP |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5081 && delay < qc->tp.max_ack_delay) |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5082 { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5083 if (!qc->push.timer_set && !qc->closing) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5084 ngx_add_timer(&qc->push, |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5085 qc->tp.max_ack_delay - delay); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5086 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5087 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5088 return NGX_OK; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5089 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5090 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5091 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5092 if (ngx_quic_send_ack(c, ctx) != NGX_OK) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5093 return NGX_ERROR; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5094 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5095 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5096 ctx->send_ack = 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5097 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5098 return NGX_OK; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5099 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5100 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5101 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5102 static ssize_t |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5103 ngx_quic_output_packet(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx, |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5104 u_char *data, size_t max, size_t min) |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5105 { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5106 size_t len, hlen, pad_len; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5107 u_char *p; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5108 ssize_t flen; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5109 ngx_str_t out, res; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5110 ngx_int_t rc; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5111 ngx_uint_t nframes; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5112 ngx_msec_t now; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5113 ngx_queue_t *q; |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5114 ngx_quic_frame_t *f; |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5115 ngx_quic_header_t pkt; |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
5116 ngx_quic_congestion_t *cg; |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5117 ngx_quic_connection_t *qc; |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5118 static u_char src[NGX_QUIC_MAX_UDP_PAYLOAD_SIZE]; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5119 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5120 if (ngx_queue_empty(&ctx->frames)) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5121 return 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5122 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5123 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5124 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5125 "quic output %s packet max:%uz min:%uz", |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5126 ngx_quic_level_name(ctx->level), max, min); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5127 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
5128 qc = ngx_quic_get_connection(c); |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
5129 cg = &qc->congestion; |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5130 |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5131 hlen = (ctx->level == ssl_encryption_application) |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5132 ? NGX_QUIC_MAX_SHORT_HEADER |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5133 : NGX_QUIC_MAX_LONG_HEADER; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5134 |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5135 hlen += EVP_GCM_TLS_TAG_LEN; |
8149
44991d728899
QUIC: account packet header length in amplification limit.
Vladimir Homutov <vl@nginx.com>
parents:
8148
diff
changeset
|
5136 hlen -= NGX_QUIC_MAX_CID_LEN - qc->scid.len; |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5137 |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5138 ngx_memzero(&pkt, sizeof(ngx_quic_header_t)); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5139 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5140 now = ngx_current_msec; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5141 nframes = 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5142 p = src; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5143 len = 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5144 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5145 for (q = ngx_queue_head(&ctx->frames); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5146 q != ngx_queue_sentinel(&ctx->frames); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5147 q = ngx_queue_next(q)) |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5148 { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5149 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5150 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5151 if (!pkt.need_ack && f->need_ack && max > cg->window) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5152 max = cg->window; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5153 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5154 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5155 if (hlen + len >= max) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5156 break; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5157 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5158 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5159 if (hlen + len + f->len > max) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5160 rc = ngx_quic_split_frame(c, f, max - hlen - len); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5161 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5162 if (rc == NGX_ERROR) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5163 return NGX_ERROR; |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5164 } |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5165 |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5166 if (rc == NGX_DECLINED) { |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
5167 break; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
5168 } |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5169 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5170 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5171 if (f->need_ack) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5172 pkt.need_ack = 1; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5173 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5174 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5175 ngx_quic_log_frame(c->log, f, 1); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5176 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5177 flen = ngx_quic_create_frame(p, f); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5178 if (flen == -1) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5179 return NGX_ERROR; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5180 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5181 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5182 len += flen; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5183 p += flen; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5184 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5185 f->pnum = ctx->pnum; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5186 f->first = now; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5187 f->last = now; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5188 f->plen = 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5189 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5190 nframes++; |
8291
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5191 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5192 if (f->flush) { |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5193 break; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5194 } |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5195 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5196 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5197 if (nframes == 0) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5198 return 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5199 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5200 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5201 out.data = src; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5202 out.len = len; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5203 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5204 pkt.keys = qc->keys; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5205 pkt.flags = NGX_QUIC_PKT_FIXED_BIT; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5206 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5207 if (ctx->level == ssl_encryption_initial) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5208 pkt.flags |= NGX_QUIC_PKT_LONG | NGX_QUIC_PKT_INITIAL; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5209 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5210 } else if (ctx->level == ssl_encryption_handshake) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5211 pkt.flags |= NGX_QUIC_PKT_LONG | NGX_QUIC_PKT_HANDSHAKE; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5212 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5213 } else { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5214 if (qc->key_phase) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5215 pkt.flags |= NGX_QUIC_PKT_KPHASE; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5216 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5217 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5218 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5219 ngx_quic_set_packet_number(&pkt, ctx); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5220 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5221 pkt.version = qc->version; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5222 pkt.log = c->log; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5223 pkt.level = ctx->level; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5224 pkt.dcid = qc->scid; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5225 pkt.scid = qc->dcid; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5226 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5227 pad_len = 4; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5228 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5229 if (min) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5230 hlen = EVP_GCM_TLS_TAG_LEN |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5231 + ngx_quic_create_header(&pkt, NULL, out.len, NULL); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5232 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5233 if (min > hlen + pad_len) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5234 pad_len = min - hlen; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5235 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5236 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5237 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5238 if (out.len < pad_len) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5239 ngx_memset(p, NGX_QUIC_FT_PADDING, pad_len - out.len); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5240 out.len = pad_len; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5241 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5242 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5243 pkt.payload = out; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5244 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5245 res.data = data; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5246 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5247 ngx_log_debug6(NGX_LOG_DEBUG_EVENT, c->log, 0, |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5248 "quic packet tx %s bytes:%ui" |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5249 " need_ack:%d number:%L encoded nl:%d trunc:0x%xD", |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5250 ngx_quic_level_name(ctx->level), out.len, pkt.need_ack, |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5251 pkt.number, pkt.num_len, pkt.trunc); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5252 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5253 if (ngx_quic_encrypt(&pkt, &res) != NGX_OK) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5254 return NGX_ERROR; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5255 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5256 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5257 ctx->pnum++; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5258 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5259 if (pkt.need_ack) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5260 /* move frames into the sent queue to wait for ack */ |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5261 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5262 if (!qc->closing) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5263 q = ngx_queue_head(&ctx->frames); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5264 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5265 f->plen = res.len; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5266 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5267 do { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5268 q = ngx_queue_head(&ctx->frames); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5269 ngx_queue_remove(q); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5270 ngx_queue_insert_tail(&ctx->sent, q); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5271 } while (--nframes); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5272 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5273 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5274 cg->in_flight += res.len; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5275 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5276 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5277 "quic congestion send if:%uz", cg->in_flight); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5278 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5279 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5280 while (nframes--) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5281 q = ngx_queue_head(&ctx->frames); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5282 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5283 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5284 ngx_queue_remove(q); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5285 ngx_quic_free_frame(c, f); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5286 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5287 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5288 return res.len; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5289 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5290 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5291 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5292 static ngx_int_t |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5293 ngx_quic_split_frame(ngx_connection_t *c, ngx_quic_frame_t *f, size_t len) |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5294 { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5295 size_t shrink; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5296 ngx_quic_frame_t *nf; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5297 ngx_quic_ordered_frame_t *of, *onf; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5298 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5299 switch (f->type) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5300 case NGX_QUIC_FT_CRYPTO: |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5301 case NGX_QUIC_FT_STREAM0: |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5302 case NGX_QUIC_FT_STREAM1: |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5303 case NGX_QUIC_FT_STREAM2: |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5304 case NGX_QUIC_FT_STREAM3: |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5305 case NGX_QUIC_FT_STREAM4: |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5306 case NGX_QUIC_FT_STREAM5: |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5307 case NGX_QUIC_FT_STREAM6: |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5308 case NGX_QUIC_FT_STREAM7: |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5309 break; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5310 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5311 default: |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5312 return NGX_DECLINED; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5313 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5314 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5315 if ((size_t) f->len <= len) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5316 return NGX_OK; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5317 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5318 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5319 shrink = f->len - len; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5320 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5321 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5322 "quic split frame now:%uz need:%uz shrink:%uz", |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5323 f->len, len, shrink); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5324 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5325 of = &f->u.ord; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5326 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5327 if (of->length <= shrink) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5328 return NGX_DECLINED; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5329 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5330 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5331 of->length -= shrink; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5332 f->len = ngx_quic_create_frame(NULL, f); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5333 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5334 if ((size_t) f->len > len) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5335 ngx_log_error(NGX_LOG_ERR, c->log, 0, "could not split QUIC frame"); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5336 return NGX_ERROR; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5337 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5338 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5339 nf = ngx_quic_alloc_frame(c); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5340 if (nf == NULL) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5341 return NGX_ERROR; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5342 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5343 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5344 *nf = *f; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5345 onf = &nf->u.ord; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5346 onf->offset += of->length; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5347 onf->length = shrink; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5348 nf->len = ngx_quic_create_frame(NULL, nf); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5349 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5350 nf->data = ngx_quic_split_bufs(c, f->data, of->length); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5351 if (nf->data == NGX_CHAIN_ERROR) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5352 return NGX_ERROR; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5353 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5354 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
5355 ngx_queue_insert_after(&f->queue, &nf->queue); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5356 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5357 return NGX_OK; |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5358 } |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5359 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5360 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5361 static void |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5362 ngx_quic_free_frames(ngx_connection_t *c, ngx_queue_t *frames) |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5363 { |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5364 ngx_queue_t *q; |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5365 ngx_quic_frame_t *f; |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5366 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5367 do { |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
5368 q = ngx_queue_head(frames); |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
5369 |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
5370 if (q == ngx_queue_sentinel(frames)) { |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
5371 break; |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
5372 } |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
5373 |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
5374 ngx_queue_remove(q); |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
5375 |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5376 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5377 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5378 ngx_quic_free_frame(c, f); |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
5379 } while (1); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5380 } |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5381 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5382 |
8240
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5383 static ssize_t |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5384 ngx_quic_send(ngx_connection_t *c, u_char *buf, size_t len) |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5385 { |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5386 ngx_buf_t b; |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5387 ngx_chain_t cl, *res; |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5388 |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5389 ngx_memzero(&b, sizeof(ngx_buf_t)); |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5390 |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5391 b.pos = b.start = buf; |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5392 b.last = b.end = buf + len; |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5393 b.last_buf = 1; |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5394 b.temporary = 1; |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5395 |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5396 cl.buf = &b; |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5397 cl.next= NULL; |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5398 |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5399 res = c->send_chain(c, &cl, 0); |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5400 if (res == NGX_CHAIN_ERROR) { |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5401 return NGX_ERROR; |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5402 } |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5403 |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5404 return len; |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5405 } |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5406 |
43f3574b3e6f
QUIC: fixed handling of clients connected to wildcard address.
Vladimir Homutov <vl@nginx.com>
parents:
8239
diff
changeset
|
5407 |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5408 static void |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
5409 ngx_quic_set_packet_number(ngx_quic_header_t *pkt, ngx_quic_send_ctx_t *ctx) |
7781
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5410 { |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5411 uint64_t delta; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5412 |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
5413 delta = ctx->pnum - ctx->largest_ack; |
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
5414 pkt->number = ctx->pnum; |
7781
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5415 |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5416 if (delta <= 0x7F) { |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5417 pkt->num_len = 1; |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
5418 pkt->trunc = ctx->pnum & 0xff; |
7781
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5419 |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5420 } else if (delta <= 0x7FFF) { |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5421 pkt->num_len = 2; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5422 pkt->flags |= 0x1; |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
5423 pkt->trunc = ctx->pnum & 0xffff; |
7781
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5424 |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5425 } else if (delta <= 0x7FFFFF) { |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5426 pkt->num_len = 3; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5427 pkt->flags |= 0x2; |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
5428 pkt->trunc = ctx->pnum & 0xffffff; |
7781
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5429 |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5430 } else { |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5431 pkt->num_len = 4; |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5432 pkt->flags |= 0x3; |
7808
bda817d16cc2
Rename types and variables used for packet number space.
Vladimir Homutov <vl@nginx.com>
parents:
7794
diff
changeset
|
5433 pkt->trunc = ctx->pnum & 0xffffffff; |
7781
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5434 } |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5435 } |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5436 |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5437 |
fdda518d10ba
Proper handling of packet number in header.
Vladimir Homutov <vl@nginx.com>
parents:
7780
diff
changeset
|
5438 static void |
7990 | 5439 ngx_quic_pto_handler(ngx_event_t *ev) |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5440 { |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5441 ngx_uint_t i; |
8291
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5442 ngx_msec_t now; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5443 ngx_queue_t *q, *next; |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5444 ngx_connection_t *c; |
8291
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5445 ngx_quic_frame_t *f; |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5446 ngx_quic_send_ctx_t *ctx; |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5447 ngx_quic_connection_t *qc; |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5448 |
7990 | 5449 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic pto timer"); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5450 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5451 c = ev->data; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
5452 qc = ngx_quic_get_connection(c); |
8291
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5453 now = ngx_current_msec; |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5454 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5455 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5456 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5457 ctx = &qc->send_ctx[i]; |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5458 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5459 if (ngx_queue_empty(&ctx->sent)) { |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5460 continue; |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5461 } |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5462 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5463 q = ngx_queue_head(&ctx->sent); |
8291
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5464 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5465 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5466 if (f->pnum <= ctx->largest_ack |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
5467 && ctx->largest_ack != NGX_QUIC_UNSET_PN) |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5468 { |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5469 continue; |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5470 } |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5471 |
8291
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5472 if ((ngx_msec_int_t) (f->last + ngx_quic_pto(c, ctx) - now) > 0) { |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5473 continue; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5474 } |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5475 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5476 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5477 "quic pto %s pto_count:%ui", |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5478 ngx_quic_level_name(ctx->level), qc->pto_count); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5479 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5480 for (q = ngx_queue_head(&ctx->frames); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5481 q != ngx_queue_sentinel(&ctx->frames); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5482 /* void */) |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5483 { |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5484 next = ngx_queue_next(q); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5485 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5486 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5487 if (f->type == NGX_QUIC_FT_PING) { |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5488 ngx_queue_remove(q); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5489 ngx_quic_free_frame(c, f); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5490 } |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5491 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5492 q = next; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5493 } |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5494 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5495 for (q = ngx_queue_head(&ctx->sent); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5496 q != ngx_queue_sentinel(&ctx->sent); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5497 /* void */) |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5498 { |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5499 next = ngx_queue_next(q); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5500 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5501 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5502 if (f->type == NGX_QUIC_FT_PING) { |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5503 ngx_quic_congestion_lost(c, f); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5504 ngx_queue_remove(q); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5505 ngx_quic_free_frame(c, f); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5506 } |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5507 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5508 q = next; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5509 } |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5510 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5511 /* enforce 2 udp datagrams */ |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5512 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5513 f = ngx_quic_alloc_frame(c); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5514 if (f == NULL) { |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5515 break; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5516 } |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5517 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5518 f->level = ctx->level; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5519 f->type = NGX_QUIC_FT_PING; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5520 f->flush = 1; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5521 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5522 ngx_quic_queue_frame(qc, f); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5523 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5524 f = ngx_quic_alloc_frame(c); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5525 if (f == NULL) { |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5526 break; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5527 } |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5528 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5529 f->level = ctx->level; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5530 f->type = NGX_QUIC_FT_PING; |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5531 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5532 ngx_quic_queue_frame(qc, f); |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5533 } |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5534 |
9ed95726b99b
QUIC: send PING frames on PTO expiration.
Roman Arutyunyan <arut@nginx.com>
parents:
8290
diff
changeset
|
5535 qc->pto_count++; |
8166
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
5536 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
5537 ngx_quic_connstate_dbg(c); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5538 } |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5539 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5540 |
7775 | 5541 static void |
5542 ngx_quic_push_handler(ngx_event_t *ev) | |
5543 { | |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
5544 ngx_connection_t *c; |
7775 | 5545 |
7836 | 5546 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic push timer"); |
7775 | 5547 |
5548 c = ev->data; | |
5549 | |
5550 if (ngx_quic_output(c) != NGX_OK) { | |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
5551 ngx_quic_close_connection(c, NGX_ERROR); |
7775 | 5552 return; |
5553 } | |
8166
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
5554 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
5555 ngx_quic_connstate_dbg(c); |
7775 | 5556 } |
5557 | |
5558 | |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5559 static |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5560 void ngx_quic_lost_handler(ngx_event_t *ev) |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5561 { |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5562 ngx_connection_t *c; |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5563 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5564 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic lost timer"); |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5565 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5566 c = ev->data; |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5567 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5568 if (ngx_quic_detect_lost(c) != NGX_OK) { |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5569 ngx_quic_close_connection(c, NGX_ERROR); |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5570 } |
8166
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
5571 |
21b7dac9de3b
QUIC: added connection state debug to event handlers.
Vladimir Homutov <vl@nginx.com>
parents:
8165
diff
changeset
|
5572 ngx_quic_connstate_dbg(c); |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5573 } |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5574 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5575 |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5576 static ngx_int_t |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5577 ngx_quic_detect_lost(ngx_connection_t *c) |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5578 { |
7992
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5579 ngx_uint_t i; |
8290
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5580 ngx_msec_t now, wait, thr; |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5581 ngx_queue_t *q; |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5582 ngx_quic_frame_t *start; |
7992
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5583 ngx_quic_send_ctx_t *ctx; |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5584 ngx_quic_connection_t *qc; |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5585 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
5586 qc = ngx_quic_get_connection(c); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5587 now = ngx_current_msec; |
8290
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5588 thr = ngx_quic_lost_threshold(qc); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5589 |
7992
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5590 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { |
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5591 |
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5592 ctx = &qc->send_ctx[i]; |
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5593 |
8157
85a550047eb5
QUIC: added macro for unset packet number.
Vladimir Homutov <vl@nginx.com>
parents:
8156
diff
changeset
|
5594 if (ctx->largest_ack == NGX_QUIC_UNSET_PN) { |
8053
4e3a71621c9a
QUIC: do not arm loss detection timer for succeeding packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8052
diff
changeset
|
5595 continue; |
4e3a71621c9a
QUIC: do not arm loss detection timer for succeeding packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8052
diff
changeset
|
5596 } |
4e3a71621c9a
QUIC: do not arm loss detection timer for succeeding packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8052
diff
changeset
|
5597 |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5598 while (!ngx_queue_empty(&ctx->sent)) { |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5599 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5600 q = ngx_queue_head(&ctx->sent); |
7992
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5601 start = ngx_queue_data(q, ngx_quic_frame_t, queue); |
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5602 |
8053
4e3a71621c9a
QUIC: do not arm loss detection timer for succeeding packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8052
diff
changeset
|
5603 if (start->pnum > ctx->largest_ack) { |
4e3a71621c9a
QUIC: do not arm loss detection timer for succeeding packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8052
diff
changeset
|
5604 break; |
4e3a71621c9a
QUIC: do not arm loss detection timer for succeeding packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8052
diff
changeset
|
5605 } |
4e3a71621c9a
QUIC: do not arm loss detection timer for succeeding packets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8052
diff
changeset
|
5606 |
7992
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5607 wait = start->last + thr - now; |
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5608 |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5609 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8057
de7d6d943f68
QUIC: fixed format specifiers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8056
diff
changeset
|
5610 "quic detect_lost pnum:%uL thr:%M wait:%i level:%d", |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5611 start->pnum, thr, (ngx_int_t) wait, start->level); |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5612 |
8054
355e079c5eee
QUIC: do not arm loss detection timer on packet threshold.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8053
diff
changeset
|
5613 if ((ngx_msec_int_t) wait > 0 |
355e079c5eee
QUIC: do not arm loss detection timer on packet threshold.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8053
diff
changeset
|
5614 && ctx->largest_ack - start->pnum < NGX_QUIC_PKT_THR) |
355e079c5eee
QUIC: do not arm loss detection timer on packet threshold.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8053
diff
changeset
|
5615 { |
355e079c5eee
QUIC: do not arm loss detection timer on packet threshold.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8053
diff
changeset
|
5616 break; |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5617 } |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
5618 |
8094
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5619 ngx_quic_resend_frames(c, ctx); |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5620 } |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5621 } |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5622 |
8290
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5623 ngx_quic_set_lost_timer(c); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5624 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5625 return NGX_OK; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5626 } |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5627 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5628 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5629 static void |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5630 ngx_quic_set_lost_timer(ngx_connection_t *c) |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5631 { |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5632 ngx_uint_t i; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5633 ngx_msec_t now; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5634 ngx_queue_t *q; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5635 ngx_msec_int_t lost, pto, w; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5636 ngx_quic_frame_t *f; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5637 ngx_quic_send_ctx_t *ctx; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5638 ngx_quic_connection_t *qc; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5639 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5640 qc = ngx_quic_get_connection(c); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5641 now = ngx_current_msec; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5642 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5643 lost = -1; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5644 pto = -1; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5645 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5646 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5647 ctx = &qc->send_ctx[i]; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5648 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5649 if (ngx_queue_empty(&ctx->sent)) { |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5650 continue; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5651 } |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5652 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5653 if (ctx->largest_ack != NGX_QUIC_UNSET_PN) { |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5654 q = ngx_queue_head(&ctx->sent); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5655 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5656 w = (ngx_msec_int_t) (f->last + ngx_quic_lost_threshold(qc) - now); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5657 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5658 if (f->pnum <= ctx->largest_ack) { |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5659 if (w < 0 || ctx->largest_ack - f->pnum >= NGX_QUIC_PKT_THR) { |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5660 w = 0; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5661 } |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5662 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5663 if (lost == -1 || w < lost) { |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5664 lost = w; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5665 } |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5666 } |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5667 } |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5668 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5669 q = ngx_queue_last(&ctx->sent); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5670 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5671 w = (ngx_msec_int_t) (f->last + ngx_quic_pto(c, ctx) - now); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5672 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5673 if (w < 0) { |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5674 w = 0; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5675 } |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5676 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5677 if (pto == -1 || w < pto) { |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5678 pto = w; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5679 } |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5680 } |
7992
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5681 |
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5682 if (qc->pto.timer_set) { |
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5683 ngx_del_timer(&qc->pto); |
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5684 } |
909b989ec088
QUIC: reworked retransmission mechanism.
Vladimir Homutov <vl@nginx.com>
parents:
7991
diff
changeset
|
5685 |
8290
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5686 if (lost != -1) { |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5687 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5688 "quic lost timer lost:%M", lost); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5689 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5690 qc->pto.handler = ngx_quic_lost_handler; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5691 ngx_add_timer(&qc->pto, lost); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5692 return; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5693 } |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5694 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5695 if (pto != -1) { |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5696 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5697 "quic lost timer pto:%M", pto); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5698 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5699 qc->pto.handler = ngx_quic_pto_handler; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5700 ngx_add_timer(&qc->pto, pto); |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5701 return; |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5702 } |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5703 |
faa3201ff351
QUIC: improved setting the lost timer.
Roman Arutyunyan <arut@nginx.com>
parents:
8289
diff
changeset
|
5704 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic lost timer unset"); |
7691 | 5705 } |
5706 | |
5707 | |
8094
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5708 static void |
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5709 ngx_quic_resend_frames(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx) |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5710 { |
8176
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5711 size_t n; |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5712 ngx_buf_t *b; |
8094
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5713 ngx_queue_t *q; |
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5714 ngx_quic_frame_t *f, *start; |
8176
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5715 ngx_quic_stream_t *sn; |
8094
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5716 ngx_quic_connection_t *qc; |
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5717 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
5718 qc = ngx_quic_get_connection(c); |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5719 q = ngx_queue_head(&ctx->sent); |
8094
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5720 start = ngx_queue_data(q, ngx_quic_frame_t, queue); |
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5721 |
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5722 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5723 "quic resend packet pnum:%uL", start->pnum); |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5724 |
8175
64405f970f6f
QUIC: avoided retransmission of stale ack frames.
Vladimir Homutov <vl@nginx.com>
parents:
8174
diff
changeset
|
5725 ngx_quic_congestion_lost(c, start); |
64405f970f6f
QUIC: avoided retransmission of stale ack frames.
Vladimir Homutov <vl@nginx.com>
parents:
8174
diff
changeset
|
5726 |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5727 do { |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5728 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5729 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5730 if (f->pnum != start->pnum) { |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5731 break; |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5732 } |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5733 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5734 q = ngx_queue_next(q); |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5735 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5736 ngx_queue_remove(&f->queue); |
8175
64405f970f6f
QUIC: avoided retransmission of stale ack frames.
Vladimir Homutov <vl@nginx.com>
parents:
8174
diff
changeset
|
5737 |
64405f970f6f
QUIC: avoided retransmission of stale ack frames.
Vladimir Homutov <vl@nginx.com>
parents:
8174
diff
changeset
|
5738 switch (f->type) { |
64405f970f6f
QUIC: avoided retransmission of stale ack frames.
Vladimir Homutov <vl@nginx.com>
parents:
8174
diff
changeset
|
5739 case NGX_QUIC_FT_ACK: |
64405f970f6f
QUIC: avoided retransmission of stale ack frames.
Vladimir Homutov <vl@nginx.com>
parents:
8174
diff
changeset
|
5740 case NGX_QUIC_FT_ACK_ECN: |
8289
88c9c868a7c9
QUIC: disabled non-immediate ACKs for Initial and Handshake.
Roman Arutyunyan <arut@nginx.com>
parents:
8288
diff
changeset
|
5741 if (ctx->level == ssl_encryption_application) { |
88c9c868a7c9
QUIC: disabled non-immediate ACKs for Initial and Handshake.
Roman Arutyunyan <arut@nginx.com>
parents:
8288
diff
changeset
|
5742 /* force generation of most recent acknowledgment */ |
88c9c868a7c9
QUIC: disabled non-immediate ACKs for Initial and Handshake.
Roman Arutyunyan <arut@nginx.com>
parents:
8288
diff
changeset
|
5743 ctx->send_ack = NGX_QUIC_MAX_ACK_GAP; |
88c9c868a7c9
QUIC: disabled non-immediate ACKs for Initial and Handshake.
Roman Arutyunyan <arut@nginx.com>
parents:
8288
diff
changeset
|
5744 } |
88c9c868a7c9
QUIC: disabled non-immediate ACKs for Initial and Handshake.
Roman Arutyunyan <arut@nginx.com>
parents:
8288
diff
changeset
|
5745 |
8175
64405f970f6f
QUIC: avoided retransmission of stale ack frames.
Vladimir Homutov <vl@nginx.com>
parents:
8174
diff
changeset
|
5746 ngx_quic_free_frame(c, f); |
64405f970f6f
QUIC: avoided retransmission of stale ack frames.
Vladimir Homutov <vl@nginx.com>
parents:
8174
diff
changeset
|
5747 break; |
64405f970f6f
QUIC: avoided retransmission of stale ack frames.
Vladimir Homutov <vl@nginx.com>
parents:
8174
diff
changeset
|
5748 |
8176
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5749 case NGX_QUIC_FT_PING: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5750 case NGX_QUIC_FT_PATH_RESPONSE: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5751 case NGX_QUIC_FT_CONNECTION_CLOSE: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5752 ngx_quic_free_frame(c, f); |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5753 break; |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5754 |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5755 case NGX_QUIC_FT_MAX_DATA: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5756 f->u.max_data.max_data = qc->streams.recv_max_data; |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5757 ngx_quic_queue_frame(qc, f); |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5758 break; |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5759 |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5760 case NGX_QUIC_FT_MAX_STREAMS: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5761 case NGX_QUIC_FT_MAX_STREAMS2: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5762 f->u.max_streams.limit = f->u.max_streams.bidi |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5763 ? qc->streams.client_max_streams_bidi |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5764 : qc->streams.client_max_streams_uni; |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5765 ngx_quic_queue_frame(qc, f); |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5766 break; |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5767 |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5768 case NGX_QUIC_FT_MAX_STREAM_DATA: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5769 sn = ngx_quic_find_stream(&qc->streams.tree, |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5770 f->u.max_stream_data.id); |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5771 if (sn == NULL) { |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5772 ngx_quic_free_frame(c, f); |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5773 break; |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5774 } |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5775 |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5776 b = sn->b; |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5777 n = sn->fs.received + (b->pos - b->start) + (b->end - b->last); |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5778 |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5779 if (f->u.max_stream_data.limit < n) { |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5780 f->u.max_stream_data.limit = n; |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5781 } |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5782 |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5783 ngx_quic_queue_frame(qc, f); |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5784 break; |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5785 |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5786 case NGX_QUIC_FT_STREAM0: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5787 case NGX_QUIC_FT_STREAM1: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5788 case NGX_QUIC_FT_STREAM2: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5789 case NGX_QUIC_FT_STREAM3: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5790 case NGX_QUIC_FT_STREAM4: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5791 case NGX_QUIC_FT_STREAM5: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5792 case NGX_QUIC_FT_STREAM6: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5793 case NGX_QUIC_FT_STREAM7: |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5794 sn = ngx_quic_find_stream(&qc->streams.tree, f->u.stream.stream_id); |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5795 |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5796 if (sn && sn->c->write->error) { |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5797 /* RESET_STREAM was sent */ |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5798 ngx_quic_free_frame(c, f); |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5799 break; |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5800 } |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5801 |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5802 /* fall through */ |
69dc750cf66f
QUIC: handle more frames in ngx_quic_resend_frames().
Roman Arutyunyan <arut@nginx.com>
parents:
8175
diff
changeset
|
5803 |
8175
64405f970f6f
QUIC: avoided retransmission of stale ack frames.
Vladimir Homutov <vl@nginx.com>
parents:
8174
diff
changeset
|
5804 default: |
64405f970f6f
QUIC: avoided retransmission of stale ack frames.
Vladimir Homutov <vl@nginx.com>
parents:
8174
diff
changeset
|
5805 ngx_queue_insert_tail(&ctx->frames, &f->queue); |
64405f970f6f
QUIC: avoided retransmission of stale ack frames.
Vladimir Homutov <vl@nginx.com>
parents:
8174
diff
changeset
|
5806 } |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5807 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5808 } while (q != ngx_queue_sentinel(&ctx->sent)); |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5809 |
8094
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5810 if (qc->closing) { |
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5811 return; |
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5812 } |
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5813 |
b383120afca3
QUIC: resend frames by moving them to output queue.
Roman Arutyunyan <arut@nginx.com>
parents:
8091
diff
changeset
|
5814 ngx_post_event(&qc->push, &ngx_posted_events); |
8051
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5815 } |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5816 |
38f1be6c603f
QUIC: sending probe packets on PTO timer expiration.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8050
diff
changeset
|
5817 |
7691 | 5818 ngx_connection_t * |
8013
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5819 ngx_quic_open_stream(ngx_connection_t *c, ngx_uint_t bidi) |
7691 | 5820 { |
8013
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5821 size_t rcvbuf_size; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5822 uint64_t id; |
7746
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
5823 ngx_quic_stream_t *qs, *sn; |
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
5824 ngx_quic_connection_t *qc; |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
5825 |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8199
diff
changeset
|
5826 qs = c->quic; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
5827 qc = ngx_quic_get_connection(qs->parent); |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
5828 |
8013
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5829 if (bidi) { |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5830 if (qc->streams.server_streams_bidi |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5831 >= qc->streams.server_max_streams_bidi) |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5832 { |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5833 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
5834 "quic too many server bidi streams:%uL", |
8013
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5835 qc->streams.server_streams_bidi); |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5836 return NULL; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5837 } |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5838 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5839 id = (qc->streams.server_streams_bidi << 2) |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5840 | NGX_QUIC_STREAM_SERVER_INITIATED; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5841 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5842 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
5843 "quic creating server bidi stream" |
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
5844 " streams:%uL max:%uL id:0x%xL", |
8013
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5845 qc->streams.server_streams_bidi, |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5846 qc->streams.server_max_streams_bidi, id); |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5847 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5848 qc->streams.server_streams_bidi++; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5849 rcvbuf_size = qc->tp.initial_max_stream_data_bidi_local; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5850 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5851 } else { |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5852 if (qc->streams.server_streams_uni |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5853 >= qc->streams.server_max_streams_uni) |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5854 { |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5855 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
5856 "quic too many server uni streams:%uL", |
8013
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5857 qc->streams.server_streams_uni); |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5858 return NULL; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5859 } |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5860 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5861 id = (qc->streams.server_streams_uni << 2) |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5862 | NGX_QUIC_STREAM_SERVER_INITIATED |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5863 | NGX_QUIC_STREAM_UNIDIRECTIONAL; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5864 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5865 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
5866 "quic creating server uni stream" |
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
5867 " streams:%uL max:%uL id:0x%xL", |
8013
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5868 qc->streams.server_streams_uni, |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5869 qc->streams.server_max_streams_uni, id); |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5870 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5871 qc->streams.server_streams_uni++; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5872 rcvbuf_size = 0; |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5873 } |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5874 |
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8004
diff
changeset
|
5875 sn = ngx_quic_create_stream(qs->parent, id, rcvbuf_size); |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
5876 if (sn == NULL) { |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
5877 return NULL; |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
5878 } |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
5879 |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
5880 return sn->c; |
7691 | 5881 } |
5882 | |
5883 | |
5884 static void | |
5885 ngx_quic_rbtree_insert_stream(ngx_rbtree_node_t *temp, | |
5886 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel) | |
5887 { | |
7746
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
5888 ngx_rbtree_node_t **p; |
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
5889 ngx_quic_stream_t *qn, *qnt; |
7691 | 5890 |
5891 for ( ;; ) { | |
7750
2935a11c55b6
Fixed QUIC stream insert and find.
Roman Arutyunyan <arut@nginx.com>
parents:
7748
diff
changeset
|
5892 qn = (ngx_quic_stream_t *) node; |
2935a11c55b6
Fixed QUIC stream insert and find.
Roman Arutyunyan <arut@nginx.com>
parents:
7748
diff
changeset
|
5893 qnt = (ngx_quic_stream_t *) temp; |
7691 | 5894 |
7750
2935a11c55b6
Fixed QUIC stream insert and find.
Roman Arutyunyan <arut@nginx.com>
parents:
7748
diff
changeset
|
5895 p = (qn->id < qnt->id) ? &temp->left : &temp->right; |
7691 | 5896 |
5897 if (*p == sentinel) { | |
5898 break; | |
5899 } | |
5900 | |
5901 temp = *p; | |
5902 } | |
5903 | |
5904 *p = node; | |
5905 node->parent = temp; | |
5906 node->left = sentinel; | |
5907 node->right = sentinel; | |
5908 ngx_rbt_red(node); | |
5909 } | |
5910 | |
5911 | |
7746
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
5912 static ngx_quic_stream_t * |
7750
2935a11c55b6
Fixed QUIC stream insert and find.
Roman Arutyunyan <arut@nginx.com>
parents:
7748
diff
changeset
|
5913 ngx_quic_find_stream(ngx_rbtree_t *rbtree, uint64_t id) |
7691 | 5914 { |
5915 ngx_rbtree_node_t *node, *sentinel; | |
7750
2935a11c55b6
Fixed QUIC stream insert and find.
Roman Arutyunyan <arut@nginx.com>
parents:
7748
diff
changeset
|
5916 ngx_quic_stream_t *qn; |
7691 | 5917 |
5918 node = rbtree->root; | |
5919 sentinel = rbtree->sentinel; | |
5920 | |
5921 while (node != sentinel) { | |
7750
2935a11c55b6
Fixed QUIC stream insert and find.
Roman Arutyunyan <arut@nginx.com>
parents:
7748
diff
changeset
|
5922 qn = (ngx_quic_stream_t *) node; |
7691 | 5923 |
7750
2935a11c55b6
Fixed QUIC stream insert and find.
Roman Arutyunyan <arut@nginx.com>
parents:
7748
diff
changeset
|
5924 if (id == qn->id) { |
2935a11c55b6
Fixed QUIC stream insert and find.
Roman Arutyunyan <arut@nginx.com>
parents:
7748
diff
changeset
|
5925 return qn; |
7691 | 5926 } |
5927 | |
7750
2935a11c55b6
Fixed QUIC stream insert and find.
Roman Arutyunyan <arut@nginx.com>
parents:
7748
diff
changeset
|
5928 node = (id < qn->id) ? node->left : node->right; |
7691 | 5929 } |
5930 | |
5931 return NULL; | |
5932 } | |
5933 | |
5934 | |
7746
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
5935 static ngx_quic_stream_t * |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5936 ngx_quic_create_client_stream(ngx_connection_t *c, uint64_t id) |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5937 { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5938 size_t n; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5939 uint64_t min_id; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5940 ngx_quic_stream_t *sn; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5941 ngx_quic_connection_t *qc; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5942 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5943 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
5944 "quic stream id:0x%xL is new", id); |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5945 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
5946 qc = ngx_quic_get_connection(c); |
8022
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5947 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5948 if (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5949 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5950 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5951 if ((id >> 2) < qc->streams.server_streams_uni) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5952 return NGX_QUIC_STREAM_GONE; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5953 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5954 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5955 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5956 return NULL; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5957 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5958 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5959 if ((id >> 2) < qc->streams.client_streams_uni) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5960 return NGX_QUIC_STREAM_GONE; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5961 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5962 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5963 if ((id >> 2) >= qc->streams.client_max_streams_uni) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5964 qc->error = NGX_QUIC_ERR_STREAM_LIMIT_ERROR; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5965 return NULL; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5966 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5967 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5968 min_id = (qc->streams.client_streams_uni << 2) |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5969 | NGX_QUIC_STREAM_UNIDIRECTIONAL; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5970 qc->streams.client_streams_uni = (id >> 2) + 1; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5971 n = qc->tp.initial_max_stream_data_uni; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5972 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5973 } else { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5974 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5975 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5976 if ((id >> 2) < qc->streams.server_streams_bidi) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5977 return NGX_QUIC_STREAM_GONE; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5978 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5979 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5980 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5981 return NULL; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5982 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5983 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5984 if ((id >> 2) < qc->streams.client_streams_bidi) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5985 return NGX_QUIC_STREAM_GONE; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5986 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5987 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5988 if ((id >> 2) >= qc->streams.client_max_streams_bidi) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5989 qc->error = NGX_QUIC_ERR_STREAM_LIMIT_ERROR; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5990 return NULL; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5991 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5992 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5993 min_id = (qc->streams.client_streams_bidi << 2); |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5994 qc->streams.client_streams_bidi = (id >> 2) + 1; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5995 n = qc->tp.initial_max_stream_data_bidi_remote; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5996 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5997 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5998 if (n < NGX_QUIC_STREAM_BUFSIZE) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
5999 n = NGX_QUIC_STREAM_BUFSIZE; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6000 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6001 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6002 /* |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6003 * 2.1. Stream Types and Identifiers |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6004 * |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6005 * Within each type, streams are created with numerically increasing |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6006 * stream IDs. A stream ID that is used out of order results in all |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6007 * streams of that type with lower-numbered stream IDs also being |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6008 * opened. |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6009 */ |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6010 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6011 for ( /* void */ ; min_id < id; min_id += 0x04) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6012 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6013 sn = ngx_quic_create_stream(c, min_id, n); |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6014 if (sn == NULL) { |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6015 return NULL; |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6016 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6017 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6018 sn->c->listening->handler(sn->c); |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6019 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6020 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6021 return ngx_quic_create_stream(c, id, n); |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6022 } |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6023 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6024 |
d277e25e37fc
QUIC: create streams for STREAM_DATA_BLOCKED and MAX_STREAM_DATA.
Roman Arutyunyan <arut@nginx.com>
parents:
8021
diff
changeset
|
6025 static ngx_quic_stream_t * |
7748
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6026 ngx_quic_create_stream(ngx_connection_t *c, uint64_t id, size_t rcvbuf_size) |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6027 { |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6028 ngx_log_t *log; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6029 ngx_pool_t *pool; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6030 ngx_quic_stream_t *sn; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6031 ngx_pool_cleanup_t *cln; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6032 ngx_quic_connection_t *qc; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6033 |
8014
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6034 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
6035 "quic stream id:0x%xL create", id); |
8014
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6036 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6037 qc = ngx_quic_get_connection(c); |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6038 |
7748
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6039 pool = ngx_create_pool(NGX_DEFAULT_POOL_SIZE, c->log); |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6040 if (pool == NULL) { |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6041 return NULL; |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6042 } |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6043 |
7748
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6044 sn = ngx_pcalloc(pool, sizeof(ngx_quic_stream_t)); |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6045 if (sn == NULL) { |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6046 ngx_destroy_pool(pool); |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6047 return NULL; |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6048 } |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6049 |
7748
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6050 sn->node.key = id; |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6051 sn->parent = c; |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6052 sn->id = id; |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6053 |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6054 sn->b = ngx_create_temp_buf(pool, rcvbuf_size); |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6055 if (sn->b == NULL) { |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6056 ngx_destroy_pool(pool); |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6057 return NULL; |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6058 } |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6059 |
7811
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
6060 ngx_queue_init(&sn->fs.frames); |
72d20158c814
Added reordering support for STREAM frames.
Vladimir Homutov <vl@nginx.com>
parents:
7810
diff
changeset
|
6061 |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6062 log = ngx_palloc(pool, sizeof(ngx_log_t)); |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6063 if (log == NULL) { |
7748
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6064 ngx_destroy_pool(pool); |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6065 return NULL; |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6066 } |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6067 |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6068 *log = *c->log; |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6069 pool->log = log; |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6070 |
7748
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6071 sn->c = ngx_get_connection(-1, log); |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6072 if (sn->c == NULL) { |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6073 ngx_destroy_pool(pool); |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6074 return NULL; |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6075 } |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6076 |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8199
diff
changeset
|
6077 sn->c->quic = sn; |
8000
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7999
diff
changeset
|
6078 sn->c->type = SOCK_STREAM; |
7748
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6079 sn->c->pool = pool; |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6080 sn->c->ssl = c->ssl; |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6081 sn->c->sockaddr = c->sockaddr; |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6082 sn->c->listening = c->listening; |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6083 sn->c->addr_text = c->addr_text; |
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6084 sn->c->local_sockaddr = c->local_sockaddr; |
8138
d57cfdebe301
QUIC: set local_socklen in stream connections.
Roman Arutyunyan <arut@nginx.com>
parents:
8137
diff
changeset
|
6085 sn->c->local_socklen = c->local_socklen; |
7748
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6086 sn->c->number = ngx_atomic_fetch_add(ngx_connection_counter, 1); |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6087 |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6088 sn->c->recv = ngx_quic_stream_recv; |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6089 sn->c->send = ngx_quic_stream_send; |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6090 sn->c->send_chain = ngx_quic_stream_send_chain; |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6091 |
7997
b250b515e5b6
QUIC: fixed stream read event log.
Roman Arutyunyan <arut@nginx.com>
parents:
7996
diff
changeset
|
6092 sn->c->read->log = log; |
b250b515e5b6
QUIC: fixed stream read event log.
Roman Arutyunyan <arut@nginx.com>
parents:
7996
diff
changeset
|
6093 sn->c->write->log = log; |
7748
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6094 |
7839
44cac24aaa44
Assign connection number to every QUIC stream log.
Roman Arutyunyan <arut@nginx.com>
parents:
7838
diff
changeset
|
6095 log->connection = sn->c->number; |
44cac24aaa44
Assign connection number to every QUIC stream log.
Roman Arutyunyan <arut@nginx.com>
parents:
7838
diff
changeset
|
6096 |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6097 if ((id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6098 || (id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6099 { |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6100 sn->c->write->ready = 1; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6101 } |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6102 |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6103 if (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6104 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6105 sn->send_max_data = qc->ctp.initial_max_stream_data_uni; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6106 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6107 |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6108 } else { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6109 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6110 sn->send_max_data = qc->ctp.initial_max_stream_data_bidi_remote; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6111 } else { |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6112 sn->send_max_data = qc->ctp.initial_max_stream_data_bidi_local; |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6113 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6114 } |
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6115 |
7705
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6116 cln = ngx_pool_cleanup_add(pool, 0); |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6117 if (cln == NULL) { |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6118 ngx_close_connection(sn->c); |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6119 ngx_destroy_pool(pool); |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6120 return NULL; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6121 } |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6122 |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6123 cln->handler = ngx_quic_stream_cleanup_handler; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6124 cln->data = sn->c; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6125 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6126 ngx_rbtree_insert(&qc->streams.tree, &sn->node); |
7748
4cf00c14f11a
Safe QUIC stream creation.
Roman Arutyunyan <arut@nginx.com>
parents:
7747
diff
changeset
|
6127 |
7695
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6128 return sn; |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6129 } |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6130 |
cfc429911c0d
Implemented creation of server unidirectional streams.
Vladimir Homutov <vl@nginx.com>
parents:
7691
diff
changeset
|
6131 |
7691 | 6132 static ssize_t |
6133 ngx_quic_stream_recv(ngx_connection_t *c, u_char *buf, size_t size) | |
6134 { | |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6135 ssize_t len; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6136 ngx_buf_t *b; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6137 ngx_event_t *rev; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6138 ngx_connection_t *pc; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6139 ngx_quic_frame_t *frame; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6140 ngx_quic_stream_t *qs; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6141 ngx_quic_connection_t *qc; |
7691 | 6142 |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8199
diff
changeset
|
6143 qs = c->quic; |
7746
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
6144 b = qs->b; |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6145 pc = qs->parent; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6146 qc = ngx_quic_get_connection(pc); |
7745
5f223cdad40e
Implemented eof in QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7744
diff
changeset
|
6147 rev = c->read; |
7691 | 6148 |
8021
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
6149 if (rev->error) { |
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
6150 return NGX_ERROR; |
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
6151 } |
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
6152 |
7836 | 6153 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
6154 "quic stream recv id:0x%xL eof:%d avail:%z", |
7836 | 6155 qs->id, rev->pending_eof, b->last - b->pos); |
7745
5f223cdad40e
Implemented eof in QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7744
diff
changeset
|
6156 |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
6157 if (b->pos == b->last) { |
7745
5f223cdad40e
Implemented eof in QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7744
diff
changeset
|
6158 rev->ready = 0; |
5f223cdad40e
Implemented eof in QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7744
diff
changeset
|
6159 |
5f223cdad40e
Implemented eof in QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7744
diff
changeset
|
6160 if (rev->pending_eof) { |
5f223cdad40e
Implemented eof in QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7744
diff
changeset
|
6161 rev->eof = 1; |
5f223cdad40e
Implemented eof in QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7744
diff
changeset
|
6162 return 0; |
5f223cdad40e
Implemented eof in QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7744
diff
changeset
|
6163 } |
5f223cdad40e
Implemented eof in QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7744
diff
changeset
|
6164 |
7836 | 6165 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
6166 "quic stream id:0x%xL recv() not ready", qs->id); |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
6167 return NGX_AGAIN; |
7691 | 6168 } |
6169 | |
6170 len = ngx_min(b->last - b->pos, (ssize_t) size); | |
6171 | |
6172 ngx_memcpy(buf, b->pos, len); | |
6173 | |
6174 b->pos += len; | |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6175 qc->streams.received += len; |
7691 | 6176 |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
6177 if (b->pos == b->last) { |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
6178 b->pos = b->start; |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
6179 b->last = b->start; |
7760
32db41d603cd
Fixed handling QUIC stream eof.
Roman Arutyunyan <arut@nginx.com>
parents:
7759
diff
changeset
|
6180 rev->ready = rev->pending_eof; |
7732
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
6181 } |
f92e583fc256
Better flow control and buffering for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
7731
diff
changeset
|
6182 |
7836 | 6183 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
6184 "quic stream id:0x%xL recv len:%z of size:%uz", |
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
6185 qs->id, len, size); |
7691 | 6186 |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6187 if (!rev->pending_eof) { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6188 frame = ngx_quic_alloc_frame(pc); |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6189 if (frame == NULL) { |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6190 return NGX_ERROR; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6191 } |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6192 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6193 frame->level = ssl_encryption_application; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6194 frame->type = NGX_QUIC_FT_MAX_STREAM_DATA; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6195 frame->u.max_stream_data.id = qs->id; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6196 frame->u.max_stream_data.limit = qs->fs.received + (b->pos - b->start) |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6197 + (b->end - b->last); |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6198 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6199 ngx_quic_queue_frame(qc, frame); |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6200 } |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6201 |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6202 if ((qc->streams.recv_max_data / 2) < qc->streams.received) { |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6203 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6204 frame = ngx_quic_alloc_frame(pc); |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6205 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6206 if (frame == NULL) { |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6207 return NGX_ERROR; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6208 } |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6209 |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6210 qc->streams.recv_max_data *= 2; |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6211 |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6212 frame->level = ssl_encryption_application; |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6213 frame->type = NGX_QUIC_FT_MAX_DATA; |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6214 frame->u.max_data.max_data = qc->streams.recv_max_data; |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6215 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6216 ngx_quic_queue_frame(qc, frame); |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6217 |
7836 | 6218 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
6219 "quic stream id:0x%xL recv: increased max_data:%uL", |
7842
fab75acb1f72
Respect MAX_DATA and MAX_STREAM_DATA from QUIC client.
Roman Arutyunyan <arut@nginx.com>
parents:
7841
diff
changeset
|
6220 qs->id, qc->streams.recv_max_data); |
7815
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6221 } |
0f9e9786b90d
Added primitive flow control mechanisms.
Vladimir Homutov <vl@nginx.com>
parents:
7814
diff
changeset
|
6222 |
7691 | 6223 return len; |
6224 } | |
6225 | |
6226 | |
6227 static ssize_t | |
6228 ngx_quic_stream_send(ngx_connection_t *c, u_char *buf, size_t size) | |
6229 { | |
8027
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6230 ngx_buf_t b; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6231 ngx_chain_t cl; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6232 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6233 ngx_memzero(&b, sizeof(ngx_buf_t)); |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6234 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6235 b.memory = 1; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6236 b.pos = buf; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6237 b.last = buf + size; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6238 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6239 cl.buf = &b; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6240 cl.next = NULL; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6241 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6242 if (ngx_quic_stream_send_chain(c, &cl, 0) == NGX_CHAIN_ERROR) { |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6243 return NGX_ERROR; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6244 } |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6245 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6246 if (b.pos == buf) { |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6247 return NGX_AGAIN; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6248 } |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6249 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6250 return b.pos - buf; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6251 } |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6252 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6253 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6254 static ngx_chain_t * |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6255 ngx_quic_stream_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6256 { |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6257 size_t n, flow; |
8021
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
6258 ngx_event_t *wev; |
8027
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6259 ngx_chain_t *cl; |
7746
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
6260 ngx_connection_t *pc; |
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
6261 ngx_quic_frame_t *frame; |
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
6262 ngx_quic_stream_t *qs; |
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
6263 ngx_quic_connection_t *qc; |
7691 | 6264 |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8199
diff
changeset
|
6265 qs = c->quic; |
7691 | 6266 pc = qs->parent; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6267 qc = ngx_quic_get_connection(pc); |
8021
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
6268 wev = c->write; |
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
6269 |
b66a2a041d7e
QUIC: fixed ngx_http_test_reading() for QUIC streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8020
diff
changeset
|
6270 if (wev->error) { |
8027
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6271 return NGX_CHAIN_ERROR; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6272 } |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6273 |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6274 flow = ngx_quic_max_stream_flow(c); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6275 if (flow == 0) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6276 wev->ready = 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6277 return in; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6278 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6279 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6280 n = (limit && (size_t) limit < flow) ? (size_t) limit : flow; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6281 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6282 frame = ngx_quic_alloc_frame(pc); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6283 if (frame == NULL) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6284 return NGX_CHAIN_ERROR; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6285 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6286 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6287 frame->data = ngx_quic_copy_chain(pc, in, n); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6288 if (frame->data == NGX_CHAIN_ERROR) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6289 return NGX_CHAIN_ERROR; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6290 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6291 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6292 for (n = 0, cl = frame->data; cl; cl = cl->next) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6293 n += ngx_buf_size(cl->buf); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6294 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6295 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6296 while (in && ngx_buf_size(in->buf) == 0) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6297 in = in->next; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6298 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6299 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6300 frame->level = ssl_encryption_application; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6301 frame->type = NGX_QUIC_FT_STREAM6; /* OFF=1 LEN=1 FIN=0 */ |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6302 frame->u.stream.off = 1; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6303 frame->u.stream.len = 1; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6304 frame->u.stream.fin = 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6305 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6306 frame->u.stream.type = frame->type; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6307 frame->u.stream.stream_id = qs->id; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6308 frame->u.stream.offset = c->sent; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6309 frame->u.stream.length = n; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6310 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6311 c->sent += n; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6312 qc->streams.sent += n; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6313 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6314 ngx_quic_queue_frame(qc, frame); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6315 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6316 wev->ready = (n < flow) ? 1 : 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6317 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6318 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6319 "quic send_chain sent:%uz", n); |
8027
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6320 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6321 return in; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6322 } |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6323 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6324 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6325 static size_t |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6326 ngx_quic_max_stream_flow(ngx_connection_t *c) |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6327 { |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6328 size_t size; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6329 uint64_t sent, unacked; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6330 ngx_quic_stream_t *qs; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6331 ngx_quic_connection_t *qc; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6332 |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8199
diff
changeset
|
6333 qs = c->quic; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6334 qc = ngx_quic_get_connection(qs->parent); |
8027
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6335 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6336 size = NGX_QUIC_STREAM_BUFSIZE; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6337 sent = c->sent; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6338 unacked = sent - qs->acked; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6339 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6340 if (qc->streams.send_max_data == 0) { |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6341 qc->streams.send_max_data = qc->ctp.initial_max_data; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6342 } |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6343 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6344 if (unacked >= NGX_QUIC_STREAM_BUFSIZE) { |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6345 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6346 "quic send flow hit buffer size"); |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6347 return 0; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6348 } |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6349 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6350 if (unacked + size > NGX_QUIC_STREAM_BUFSIZE) { |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6351 size = NGX_QUIC_STREAM_BUFSIZE - unacked; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6352 } |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6353 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6354 if (qc->streams.sent >= qc->streams.send_max_data) { |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6355 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6356 "quic send flow hit MAX_DATA"); |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6357 return 0; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6358 } |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6359 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6360 if (qc->streams.sent + size > qc->streams.send_max_data) { |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6361 size = qc->streams.send_max_data - qc->streams.sent; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6362 } |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6363 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6364 if (sent >= qs->send_max_data) { |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6365 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6366 "quic send flow hit MAX_STREAM_DATA"); |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6367 return 0; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6368 } |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6369 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6370 if (sent + size > qs->send_max_data) { |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6371 size = qs->send_max_data - sent; |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6372 } |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6373 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6374 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
6375 "quic send flow:%uz", size); |
8027
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6376 |
bce9e9643444
QUIC: coalesce neighbouring stream send buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8026
diff
changeset
|
6377 return size; |
7691 | 6378 } |
6379 | |
6380 | |
7705
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6381 static void |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6382 ngx_quic_stream_cleanup_handler(void *data) |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6383 { |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6384 ngx_connection_t *c = data; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6385 |
7746
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
6386 ngx_connection_t *pc; |
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
6387 ngx_quic_frame_t *frame; |
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
6388 ngx_quic_stream_t *qs; |
b364af7f9f3f
Removed ngx_quic_stream_node_t.
Roman Arutyunyan <arut@nginx.com>
parents:
7745
diff
changeset
|
6389 ngx_quic_connection_t *qc; |
7705
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6390 |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8199
diff
changeset
|
6391 qs = c->quic; |
7705
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6392 pc = qs->parent; |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6393 qc = ngx_quic_get_connection(pc); |
7705
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6394 |
7836 | 6395 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
6396 "quic stream id:0x%xL cleanup", qs->id); |
7747
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
6397 |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
6398 ngx_rbtree_delete(&qc->streams.tree, &qs->node); |
7825
d42b50d239f4
Fixed memory leak with reordered stream frames.
Vladimir Homutov <vl@nginx.com>
parents:
7823
diff
changeset
|
6399 ngx_quic_free_frames(pc, &qs->fs.frames); |
7747
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
6400 |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
6401 if (qc->closing) { |
7832
ad3a6f069498
Added proper handling of connection close phases.
Vladimir Homutov <vl@nginx.com>
parents:
7831
diff
changeset
|
6402 /* schedule handler call to continue ngx_quic_close_connection() */ |
7747
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
6403 ngx_post_event(pc->read, &ngx_posted_events); |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
6404 return; |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
6405 } |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
7746
diff
changeset
|
6406 |
8066
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6407 if ((qs->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6408 || (qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0) |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6409 { |
8077
62db595a86b5
QUIC: do not send STOP_SENDING after STREAM fin.
Roman Arutyunyan <arut@nginx.com>
parents:
8076
diff
changeset
|
6410 if (!c->read->pending_eof && !c->read->error) { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6411 frame = ngx_quic_alloc_frame(pc); |
8066
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6412 if (frame == NULL) { |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6413 return; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6414 } |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6415 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6416 frame->level = ssl_encryption_application; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6417 frame->type = NGX_QUIC_FT_STOP_SENDING; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6418 frame->u.stop_sending.id = qs->id; |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6419 frame->u.stop_sending.error_code = 0x100; /* HTTP/3 no error */ |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6420 |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6421 ngx_quic_queue_frame(qc, frame); |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6422 } |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6423 } |
97da6521657c
QUIC: send STOP_SENDING on stream closure.
Roman Arutyunyan <arut@nginx.com>
parents:
8064
diff
changeset
|
6424 |
8014
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6425 if ((qs->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0) { |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6426 frame = ngx_quic_alloc_frame(pc); |
8014
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6427 if (frame == NULL) { |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6428 return; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6429 } |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6430 |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6431 frame->level = ssl_encryption_application; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6432 frame->type = NGX_QUIC_FT_MAX_STREAMS; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6433 |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6434 if (qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6435 frame->u.max_streams.limit = ++qc->streams.client_max_streams_uni; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6436 frame->u.max_streams.bidi = 0; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6437 |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6438 } else { |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6439 frame->u.max_streams.limit = ++qc->streams.client_max_streams_bidi; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6440 frame->u.max_streams.bidi = 1; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6441 } |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6442 |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6443 ngx_quic_queue_frame(qc, frame); |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6444 |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6445 if (qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6446 /* do not send fin for client unidirectional streams */ |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6447 return; |
c5324bb3a704
QUIC: limited the number of client-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8013
diff
changeset
|
6448 } |
7705
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6449 } |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6450 |
8296
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
6451 if (c->write->error) { |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
6452 goto error; |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
6453 } |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
6454 |
7836 | 6455 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8164
eed49b83e18f
QUIC: revised value separators in debug and error messages.
Vladimir Homutov <vl@nginx.com>
parents:
8163
diff
changeset
|
6456 "quic stream id:0x%xL send fin", qs->id); |
7705
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6457 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6458 frame = ngx_quic_alloc_frame(pc); |
7705
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6459 if (frame == NULL) { |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6460 return; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6461 } |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6462 |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6463 frame->level = ssl_encryption_application; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6464 frame->type = NGX_QUIC_FT_STREAM7; /* OFF=1 LEN=1 FIN=1 */ |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6465 frame->u.stream.off = 1; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6466 frame->u.stream.len = 1; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6467 frame->u.stream.fin = 1; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6468 |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6469 frame->u.stream.type = frame->type; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6470 frame->u.stream.stream_id = qs->id; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6471 frame->u.stream.offset = c->sent; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6472 frame->u.stream.length = 0; |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6473 |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6474 ngx_quic_queue_frame(qc, frame); |
7759
1ec905f4d851
Push QUIC stream frames in send() and cleanup handler.
Roman Arutyunyan <arut@nginx.com>
parents:
7756
diff
changeset
|
6475 |
8296
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
6476 error: |
d710c457171c
QUIC: added ability to reset a stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8295
diff
changeset
|
6477 |
7759
1ec905f4d851
Push QUIC stream frames in send() and cleanup handler.
Roman Arutyunyan <arut@nginx.com>
parents:
7756
diff
changeset
|
6478 (void) ngx_quic_output(pc); |
7705
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6479 } |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6480 |
5ad7bffd3850
Send a FIN frame when QUIC stream is closed.
Roman Arutyunyan <arut@nginx.com>
parents:
7703
diff
changeset
|
6481 |
7752 | 6482 static ngx_quic_frame_t * |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6483 ngx_quic_alloc_frame(ngx_connection_t *c) |
7752 | 6484 { |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
6485 ngx_queue_t *q; |
7752 | 6486 ngx_quic_frame_t *frame; |
6487 ngx_quic_connection_t *qc; | |
6488 | |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6489 qc = ngx_quic_get_connection(c); |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
6490 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
6491 if (!ngx_queue_empty(&qc->free_frames)) { |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
6492 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
6493 q = ngx_queue_head(&qc->free_frames); |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
6494 frame = ngx_queue_data(q, ngx_quic_frame_t, queue); |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
6495 |
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
6496 ngx_queue_remove(&frame->queue); |
7752 | 6497 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6498 #ifdef NGX_QUIC_DEBUG_ALLOC |
7752 | 6499 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
7836 | 6500 "quic reuse frame n:%ui", qc->nframes); |
6501 #endif | |
7752 | 6502 |
6503 } else { | |
6504 frame = ngx_pcalloc(c->pool, sizeof(ngx_quic_frame_t)); | |
6505 if (frame == NULL) { | |
6506 return NULL; | |
6507 } | |
6508 | |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6509 #ifdef NGX_QUIC_DEBUG_ALLOC |
7752 | 6510 ++qc->nframes; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6511 |
7752 | 6512 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
7836 | 6513 "quic alloc frame n:%ui", qc->nframes); |
6514 #endif | |
7752 | 6515 } |
6516 | |
6517 ngx_memzero(frame, sizeof(ngx_quic_frame_t)); | |
6518 | |
6519 return frame; | |
6520 } | |
6521 | |
6522 | |
6523 static void | |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6524 ngx_quic_congestion_ack(ngx_connection_t *c, ngx_quic_frame_t *f) |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6525 { |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6526 ngx_msec_t timer; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6527 ngx_quic_congestion_t *cg; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6528 ngx_quic_connection_t *qc; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6529 |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6530 if (f->plen == 0) { |
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6531 return; |
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6532 } |
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6533 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6534 qc = ngx_quic_get_connection(c); |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6535 cg = &qc->congestion; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6536 |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6537 cg->in_flight -= f->plen; |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6538 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6539 timer = f->last - cg->recovery_start; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6540 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6541 if ((ngx_msec_int_t) timer <= 0) { |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6542 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8193
8550b91e8e35
QUIC: added proper logging of special values.
Vladimir Homutov <vl@nginx.com>
parents:
8192
diff
changeset
|
6543 "quic congestion ack recovery win:%uz ss:%z if:%uz", |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6544 cg->window, cg->ssthresh, cg->in_flight); |
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6545 |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6546 return; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6547 } |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6548 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6549 if (cg->window < cg->ssthresh) { |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6550 cg->window += f->plen; |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6551 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6552 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8193
8550b91e8e35
QUIC: added proper logging of special values.
Vladimir Homutov <vl@nginx.com>
parents:
8192
diff
changeset
|
6553 "quic congestion slow start win:%uz ss:%z if:%uz", |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6554 cg->window, cg->ssthresh, cg->in_flight); |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6555 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6556 } else { |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6557 cg->window += qc->tp.max_udp_payload_size * f->plen / cg->window; |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6558 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6559 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8193
8550b91e8e35
QUIC: added proper logging of special values.
Vladimir Homutov <vl@nginx.com>
parents:
8192
diff
changeset
|
6560 "quic congestion avoidance win:%uz ss:%z if:%uz", |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6561 cg->window, cg->ssthresh, cg->in_flight); |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6562 } |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6563 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6564 /* prevent recovery_start from wrapping */ |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6565 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6566 timer = cg->recovery_start - ngx_current_msec + qc->tp.max_idle_timeout * 2; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6567 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6568 if ((ngx_msec_int_t) timer < 0) { |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6569 cg->recovery_start = ngx_current_msec - qc->tp.max_idle_timeout * 2; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6570 } |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6571 } |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6572 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6573 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6574 static void |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6575 ngx_quic_congestion_lost(ngx_connection_t *c, ngx_quic_frame_t *f) |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6576 { |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6577 ngx_msec_t timer; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6578 ngx_quic_congestion_t *cg; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6579 ngx_quic_connection_t *qc; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6580 |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6581 if (f->plen == 0) { |
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6582 return; |
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6583 } |
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6584 |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6585 qc = ngx_quic_get_connection(c); |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6586 cg = &qc->congestion; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6587 |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6588 cg->in_flight -= f->plen; |
8171
b1676cd64dc9
QUIC: cleanup send context properly.
Vladimir Homutov <vl@nginx.com>
parents:
8170
diff
changeset
|
6589 f->plen = 0; |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6590 |
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6591 timer = f->last - cg->recovery_start; |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6592 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6593 if ((ngx_msec_int_t) timer <= 0) { |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6594 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8193
8550b91e8e35
QUIC: added proper logging of special values.
Vladimir Homutov <vl@nginx.com>
parents:
8192
diff
changeset
|
6595 "quic congestion lost recovery win:%uz ss:%z if:%uz", |
8026
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6596 cg->window, cg->ssthresh, cg->in_flight); |
4604e6043657
QUIC: packet based bytes_in_flight accounting.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8025
diff
changeset
|
6597 |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6598 return; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6599 } |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6600 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6601 cg->recovery_start = ngx_current_msec; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6602 cg->window /= 2; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6603 |
7910
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7908
diff
changeset
|
6604 if (cg->window < qc->tp.max_udp_payload_size * 2) { |
125cbfa77013
Renamed max_packet_size to max_udp_payload_size, from draft-28.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7908
diff
changeset
|
6605 cg->window = qc->tp.max_udp_payload_size * 2; |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6606 } |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6607 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6608 cg->ssthresh = cg->window; |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6609 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6610 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8193
8550b91e8e35
QUIC: added proper logging of special values.
Vladimir Homutov <vl@nginx.com>
parents:
8192
diff
changeset
|
6611 "quic congestion lost win:%uz ss:%z if:%uz", |
7841
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6612 cg->window, cg->ssthresh, cg->in_flight); |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6613 } |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6614 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6615 |
eee307399229
QUIC basic congestion control.
Roman Arutyunyan <arut@nginx.com>
parents:
7840
diff
changeset
|
6616 static void |
7752 | 6617 ngx_quic_free_frame(ngx_connection_t *c, ngx_quic_frame_t *frame) |
6618 { | |
6619 ngx_quic_connection_t *qc; | |
6620 | |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6621 qc = ngx_quic_get_connection(c); |
7752 | 6622 |
6623 if (frame->data) { | |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6624 ngx_quic_free_bufs(c, frame->data); |
7752 | 6625 } |
6626 | |
7774
e10b4c61420f
Implemented retransmission and retransmit queue.
Vladimir Homutov <vl@nginx.com>
parents:
7773
diff
changeset
|
6627 ngx_queue_insert_head(&qc->free_frames, &frame->queue); |
7752 | 6628 |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6629 #ifdef NGX_QUIC_DEBUG_ALLOC |
7752 | 6630 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
7836 | 6631 "quic free frame n:%ui", qc->nframes); |
6632 #endif | |
7752 | 6633 } |
8196
e0947c952d43
QUIC: multiple versions support in ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8195
diff
changeset
|
6634 |
e0947c952d43
QUIC: multiple versions support in ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8195
diff
changeset
|
6635 |
e0947c952d43
QUIC: multiple versions support in ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8195
diff
changeset
|
6636 uint32_t |
e0947c952d43
QUIC: multiple versions support in ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8195
diff
changeset
|
6637 ngx_quic_version(ngx_connection_t *c) |
e0947c952d43
QUIC: multiple versions support in ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8195
diff
changeset
|
6638 { |
8199
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6639 uint32_t version; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6640 ngx_quic_connection_t *qc; |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6641 |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6642 qc = ngx_quic_get_connection(c); |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6643 |
feec2cc762f6
QUIC: got rid of the c->quic field.
Roman Arutyunyan <arut@nginx.com>
parents:
8198
diff
changeset
|
6644 version = qc->version; |
8196
e0947c952d43
QUIC: multiple versions support in ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8195
diff
changeset
|
6645 |
e0947c952d43
QUIC: multiple versions support in ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8195
diff
changeset
|
6646 return (version & 0xff000000) == 0xff000000 ? version & 0xff : version; |
e0947c952d43
QUIC: multiple versions support in ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8195
diff
changeset
|
6647 } |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6648 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6649 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6650 static ngx_chain_t * |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6651 ngx_quic_alloc_buf(ngx_connection_t *c) |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6652 { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6653 ngx_buf_t *b; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6654 ngx_chain_t *cl; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6655 ngx_quic_connection_t *qc; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6656 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6657 qc = ngx_quic_get_connection(c); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6658 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6659 if (qc->free_bufs) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6660 cl = qc->free_bufs; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6661 qc->free_bufs = cl->next; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6662 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6663 b = cl->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6664 b->pos = b->start; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6665 b->last = b->start; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6666 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6667 #ifdef NGX_QUIC_DEBUG_ALLOC |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6668 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6669 "quic reuse buffer n:%ui", qc->nbufs); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6670 #endif |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6671 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6672 return cl; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6673 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6674 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6675 cl = ngx_alloc_chain_link(c->pool); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6676 if (cl == NULL) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6677 return NULL; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6678 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6679 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6680 b = ngx_create_temp_buf(c->pool, NGX_QUIC_BUFFER_SIZE); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6681 if (b == NULL) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6682 return NULL; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6683 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6684 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6685 b->tag = (ngx_buf_tag_t) &ngx_quic_alloc_buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6686 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6687 cl->buf = b; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6688 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6689 #ifdef NGX_QUIC_DEBUG_ALLOC |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6690 ++qc->nbufs; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6691 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6692 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6693 "quic alloc buffer n:%ui", qc->nbufs); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6694 #endif |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6695 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6696 return cl; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6697 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6698 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6699 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6700 static void |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6701 ngx_quic_free_bufs(ngx_connection_t *c, ngx_chain_t *in) |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6702 { |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6703 ngx_buf_t *b, *shadow; |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6704 ngx_chain_t *cl; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6705 ngx_quic_connection_t *qc; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6706 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6707 qc = ngx_quic_get_connection(c); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6708 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6709 while (in) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6710 #ifdef NGX_QUIC_DEBUG_ALLOC |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6711 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6712 "quic free buffer n:%ui", qc->nbufs); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6713 #endif |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6714 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6715 cl = in; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6716 in = in->next; |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6717 b = cl->buf; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6718 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6719 if (b->shadow) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6720 if (!b->last_shadow) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6721 b->recycled = 1; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6722 ngx_free_chain(c->pool, cl); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6723 continue; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6724 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6725 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6726 do { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6727 shadow = b->shadow; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6728 b->shadow = qc->free_shadow_bufs; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6729 qc->free_shadow_bufs = b; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6730 b = shadow; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6731 } while (b->recycled); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6732 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6733 if (b->shadow) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6734 b->last_shadow = 1; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6735 ngx_free_chain(c->pool, cl); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6736 continue; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6737 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6738 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6739 cl->buf = b; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6740 } |
8241
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6741 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6742 cl->next = qc->free_bufs; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6743 qc->free_bufs = cl; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6744 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6745 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6746 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6747 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6748 static ngx_chain_t * |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6749 ngx_quic_copy_buf(ngx_connection_t *c, u_char *data, size_t len) |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6750 { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6751 size_t n; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6752 ngx_buf_t *b; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6753 ngx_chain_t *cl, *out, **ll; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6754 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6755 out = NULL; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6756 ll = &out; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6757 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6758 while (len) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6759 cl = ngx_quic_alloc_buf(c); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6760 if (cl == NULL) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6761 return NGX_CHAIN_ERROR; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6762 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6763 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6764 b = cl->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6765 n = ngx_min((size_t) (b->end - b->last), len); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6766 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6767 b->last = ngx_cpymem(b->last, data, n); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6768 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6769 data += n; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6770 len -= n; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6771 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6772 *ll = cl; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6773 ll = &cl->next; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6774 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6775 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6776 *ll = NULL; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6777 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6778 return out; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6779 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6780 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6781 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6782 static ngx_chain_t * |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6783 ngx_quic_copy_chain(ngx_connection_t *c, ngx_chain_t *in, size_t limit) |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6784 { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6785 size_t n; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6786 ngx_buf_t *b; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6787 ngx_chain_t *cl, *out, **ll; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6788 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6789 out = NULL; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6790 ll = &out; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6791 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6792 while (in) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6793 if (!ngx_buf_in_memory(in->buf) || ngx_buf_size(in->buf) == 0) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6794 in = in->next; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6795 continue; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6796 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6797 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6798 cl = ngx_quic_alloc_buf(c); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6799 if (cl == NULL) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6800 return NGX_CHAIN_ERROR; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6801 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6802 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6803 *ll = cl; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6804 ll = &cl->next; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6805 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6806 b = cl->buf; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6807 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6808 while (in && b->last != b->end) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6809 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6810 n = ngx_min(in->buf->last - in->buf->pos, b->end - b->last); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6811 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6812 if (limit > 0 && n > limit) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6813 n = limit; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6814 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6815 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6816 b->last = ngx_cpymem(b->last, in->buf->pos, n); |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6817 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6818 in->buf->pos += n; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6819 if (in->buf->pos == in->buf->last) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6820 in = in->next; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6821 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6822 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6823 if (limit > 0) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6824 if (limit == n) { |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6825 goto done; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6826 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6827 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6828 limit -= n; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6829 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6830 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6831 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6832 } |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6833 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6834 done: |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6835 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6836 *ll = NULL; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6837 |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6838 return out; |
2dfc5ef29973
QUIC: introduced QUIC buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8240
diff
changeset
|
6839 } |
8242
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6840 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6841 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6842 static ngx_chain_t * |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6843 ngx_quic_split_bufs(ngx_connection_t *c, ngx_chain_t *in, size_t len) |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6844 { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6845 size_t n; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6846 ngx_buf_t *b; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6847 ngx_chain_t *out; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6848 ngx_quic_connection_t *qc; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6849 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6850 qc = ngx_quic_get_connection(c); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6851 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6852 while (in) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6853 n = ngx_buf_size(in->buf); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6854 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6855 if (n == len) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6856 out = in->next; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6857 in->next = NULL; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6858 return out; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6859 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6860 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6861 if (n > len) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6862 break; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6863 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6864 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6865 len -= n; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6866 in = in->next; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6867 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6868 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6869 if (in == NULL) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6870 return NULL; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6871 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6872 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6873 /* split in->buf by creating shadow bufs which reference it */ |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6874 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6875 if (in->buf->shadow == NULL) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6876 if (qc->free_shadow_bufs) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6877 b = qc->free_shadow_bufs; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6878 qc->free_shadow_bufs = b->shadow; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6879 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6880 } else { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6881 b = ngx_alloc_buf(c->pool); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6882 if (b == NULL) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6883 return NGX_CHAIN_ERROR; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6884 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6885 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6886 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6887 *b = *in->buf; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6888 b->shadow = in->buf; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6889 b->last_shadow = 1; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6890 in->buf = b; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6891 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6892 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6893 out = ngx_alloc_chain_link(c->pool); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6894 if (out == NULL) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6895 return NGX_CHAIN_ERROR; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6896 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6897 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6898 if (qc->free_shadow_bufs) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6899 b = qc->free_shadow_bufs; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6900 qc->free_shadow_bufs = b->shadow; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6901 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6902 } else { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6903 b = ngx_alloc_buf(c->pool); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6904 if (b == NULL) { |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6905 ngx_free_chain(c->pool, out); |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6906 return NGX_CHAIN_ERROR; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6907 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6908 } |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6909 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6910 out->buf = b; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6911 out->next = in->next; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6912 in->next = NULL; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6913 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6914 *b = *in->buf; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6915 b->last_shadow = 0; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6916 b->pos = b->pos + len; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6917 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6918 in->buf->shadow = b; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6919 in->buf->last = in->buf->pos + len; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6920 |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6921 return out; |
0af4ec6d1f92
QUIC: coalesce output packets into a single UDP datagram.
Roman Arutyunyan <arut@nginx.com>
parents:
8241
diff
changeset
|
6922 } |