comparison src/event/quic/ngx_event_quic_connid.c @ 8920:9680f0badc95 quic

QUIC: fixed using of retired connection id (ticket #2289). RFC 9000 19.16 The sequence number specified in a RETIRE_CONNECTION_ID frame MUST NOT refer to the Destination Connection ID field of the packet in which the frame is contained. Before the patch, the RETIRE_CONNECTION_ID frame was sent before switching to the new client id. If retired client id was currently in use, this lead to violation of the spec.
author Vladimir Homutov <vl@nginx.com>
date Thu, 02 Dec 2021 14:09:52 +0300
parents b09f055daa4e
children 32daba3aabb2
comparison
equal deleted inserted replaced
8919:a6a328ebd362 8920:9680f0badc95
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_new_conn_id_frame_t *f) 78 ngx_quic_new_conn_id_frame_t *f)
79 { 79 {
80 uint64_t seq;
80 ngx_str_t id; 81 ngx_str_t id;
81 ngx_queue_t *q; 82 ngx_queue_t *q;
82 ngx_quic_client_id_t *cid, *item; 83 ngx_quic_client_id_t *cid, *item;
83 ngx_quic_connection_t *qc; 84 ngx_quic_connection_t *qc;
84 85
171 if (cid->seqnum >= f->retire) { 172 if (cid->seqnum >= f->retire) {
172 continue; 173 continue;
173 } 174 }
174 175
175 /* this connection id must be retired */ 176 /* this connection id must be retired */
176 177 seq = cid->seqnum;
177 if (ngx_quic_send_retire_connection_id(c, cid->seqnum) != NGX_OK) {
178 return NGX_ERROR;
179 }
180 178
181 if (cid->refcnt) { 179 if (cid->refcnt) {
182 /* we are going to retire client id which is in use */ 180 /* we are going to retire client id which is in use */
183 if (ngx_quic_replace_retired_client_id(c, cid) != NGX_OK) { 181 if (ngx_quic_replace_retired_client_id(c, cid) != NGX_OK) {
184 return NGX_ERROR; 182 return NGX_ERROR;
185 } 183 }
186 184
187 } else { 185 } else {
188 ngx_quic_unref_client_id(c, cid); 186 ngx_quic_unref_client_id(c, cid);
187 }
188
189 if (ngx_quic_send_retire_connection_id(c, seq) != NGX_OK) {
190 return NGX_ERROR;
189 } 191 }
190 } 192 }
191 193
192 done: 194 done:
193 195