comparison src/event/quic/ngx_event_quic_connid.c @ 8778:5186ee5a94b9 quic

QUIC: simplified sending 1-RTT only frames.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 05 May 2021 19:32:49 +0300
parents d5f93733c17d
children 4715f3e669f1
comparison
equal deleted inserted replaced
8777:d5f93733c17d 8778:5186ee5a94b9
14 14
15 #if (NGX_QUIC_BPF) 15 #if (NGX_QUIC_BPF)
16 static ngx_int_t ngx_quic_bpf_attach_id(ngx_connection_t *c, u_char *id); 16 static ngx_int_t ngx_quic_bpf_attach_id(ngx_connection_t *c, u_char *id);
17 #endif 17 #endif
18 static ngx_int_t ngx_quic_send_retire_connection_id(ngx_connection_t *c, 18 static ngx_int_t ngx_quic_send_retire_connection_id(ngx_connection_t *c,
19 enum ssl_encryption_level_t level, uint64_t seqnum); 19 uint64_t seqnum);
20 20
21 static ngx_quic_client_id_t *ngx_quic_alloc_client_id(ngx_connection_t *c, 21 static ngx_quic_client_id_t *ngx_quic_alloc_client_id(ngx_connection_t *c,
22 ngx_quic_connection_t *qc); 22 ngx_quic_connection_t *qc);
23 static ngx_int_t ngx_quic_replace_retired_client_id(ngx_connection_t *c, 23 static ngx_int_t ngx_quic_replace_retired_client_id(ngx_connection_t *c,
24 ngx_quic_client_id_t *retired_cid); 24 ngx_quic_client_id_t *retired_cid);
73 #endif 73 #endif
74 74
75 75
76 ngx_int_t 76 ngx_int_t
77 ngx_quic_handle_new_connection_id_frame(ngx_connection_t *c, 77 ngx_quic_handle_new_connection_id_frame(ngx_connection_t *c,
78 ngx_quic_header_t *pkt, ngx_quic_new_conn_id_frame_t *f) 78 ngx_quic_new_conn_id_frame_t *f)
79 { 79 {
80 ngx_str_t id; 80 ngx_str_t id;
81 ngx_queue_t *q; 81 ngx_queue_t *q;
82 ngx_quic_client_id_t *cid, *item; 82 ngx_quic_client_id_t *cid, *item;
83 ngx_quic_connection_t *qc; 83 ngx_quic_connection_t *qc;
92 * a corresponding RETIRE_CONNECTION_ID frame that retires 92 * a corresponding RETIRE_CONNECTION_ID frame that retires
93 * the newly received connection ID, unless it has already 93 * the newly received connection ID, unless it has already
94 * done so for that sequence number. 94 * done so for that sequence number.
95 */ 95 */
96 96
97 if (ngx_quic_send_retire_connection_id(c, pkt->level, f->seqnum) 97 if (ngx_quic_send_retire_connection_id(c, f->seqnum) != NGX_OK) {
98 != NGX_OK)
99 {
100 return NGX_ERROR; 98 return NGX_ERROR;
101 } 99 }
102 100
103 goto retire; 101 goto retire;
104 } 102 }
172 continue; 170 continue;
173 } 171 }
174 172
175 /* this connection id must be retired */ 173 /* this connection id must be retired */
176 174
177 if (ngx_quic_send_retire_connection_id(c, pkt->level, cid->seqnum) 175 if (ngx_quic_send_retire_connection_id(c, cid->seqnum) != NGX_OK) {
178 != NGX_OK)
179 {
180 return NGX_ERROR; 176 return NGX_ERROR;
181 } 177 }
182 178
183 if (cid->refcnt) { 179 if (cid->refcnt) {
184 /* we are going to retire client id which is in use */ 180 /* we are going to retire client id which is in use */
208 return NGX_OK; 204 return NGX_OK;
209 } 205 }
210 206
211 207
212 static ngx_int_t 208 static ngx_int_t
213 ngx_quic_send_retire_connection_id(ngx_connection_t *c, 209 ngx_quic_send_retire_connection_id(ngx_connection_t *c, uint64_t seqnum)
214 enum ssl_encryption_level_t level, uint64_t seqnum)
215 { 210 {
216 ngx_quic_frame_t *frame; 211 ngx_quic_frame_t *frame;
217 ngx_quic_connection_t *qc; 212 ngx_quic_connection_t *qc;
218 213
219 qc = ngx_quic_get_connection(c); 214 qc = ngx_quic_get_connection(c);
221 frame = ngx_quic_alloc_frame(c); 216 frame = ngx_quic_alloc_frame(c);
222 if (frame == NULL) { 217 if (frame == NULL) {
223 return NGX_ERROR; 218 return NGX_ERROR;
224 } 219 }
225 220
226 frame->level = level; 221 frame->level = ssl_encryption_application;
227 frame->type = NGX_QUIC_FT_RETIRE_CONNECTION_ID; 222 frame->type = NGX_QUIC_FT_RETIRE_CONNECTION_ID;
228 frame->u.retire_cid.sequence_number = seqnum; 223 frame->u.retire_cid.sequence_number = seqnum;
229 224
230 ngx_quic_queue_frame(qc, frame); 225 ngx_quic_queue_frame(qc, frame);
231 226
354 } 349 }
355 350
356 351
357 ngx_int_t 352 ngx_int_t
358 ngx_quic_handle_retire_connection_id_frame(ngx_connection_t *c, 353 ngx_quic_handle_retire_connection_id_frame(ngx_connection_t *c,
359 ngx_quic_header_t *pkt, ngx_quic_retire_cid_frame_t *f) 354 ngx_quic_retire_cid_frame_t *f)
360 { 355 {
361 ngx_quic_path_t *path; 356 ngx_quic_path_t *path;
362 ngx_quic_socket_t *qsock, **tmp; 357 ngx_quic_socket_t *qsock, **tmp;
363 ngx_quic_client_id_t *cid; 358 ngx_quic_client_id_t *cid;
364 ngx_quic_connection_t *qc; 359 ngx_quic_connection_t *qc;