Home | History | Annotate | Download | only in quic

Lines Matching defs:rcid

21  * to switch to a new RCID according to some arbitrary policy such as the number
24 * When we do this we should move to the next RCID in the sequence of received
31 * with sequence numbers 12, 10, 11, we should still consume the RCID with
38 const QUIC_CONN_ID *rcid);
46 * RCID
49 * The RCID structure is used to track RCIDs which have sequence numbers (i.e.,
52 * can logically be viewed as their own type of RCID but are tracked separately
55 * At any given time an RCID object is in one of these states:
73 * The RCID object is freed when it is popped.
77 * rcid->state == RCID_STATE_PENDING;
78 * rcid->pq_idx != SIZE_MAX (debug assert only);
79 * the RCID is not the current RCID, rcidm->cur_rcid != rcid;
80 * the RCID is in the priority queue;
81 * the RCID is not in the retiring_list.
85 * rcid->state == RCID_STATE_CUR;
86 * rcid->pq_idx == SIZE_MAX (debug assert only);
87 * the RCID is the current RCID, rcidm->cur_rcid == rcid;
88 * the RCID is not in the priority queue;
89 * the RCID is not in the retiring_list.
93 * rcid->state == RCID_STATE_RETIRING;
94 * rcid->pq_idx == SIZE_MAX (debug assert only);
95 * the RCID is not the current RCID, rcidm->cur_rcid != rcid;
96 * the RCID is not in the priority queue;
97 * the RCID is in the retiring_list.
99 * Invariant: At most one RCID object is in the CURRENT state at any one time.
101 * (If no RCID object is in the CURRENT state, this means either
102 * an unnumbered RCID is being used as the preferred RCID
103 * or we currently have no preferred RCID.)
106 * for an RCID as specified in RFC 9000. A CID only ceases to be active
129 QUIC_CONN_ID cid; /* The actual CID string for this RCID */
134 } RCID;
136 DEFINE_PRIORITY_QUEUE_OF(RCID);
137 DEFINE_LIST_OF(retiring, RCID);
140 * RCID Manager
146 * Invariant: An RCID of INITIAL type has a sequence number of 0.
147 * Invariant: An RCID of PREF_ADDR type has a sequence number of 1.
153 * Invariant: There is never more than one INITIAL RCID created
155 * Invariant: There is never more than one PREF_ADDR RCID created
157 * Invariant: No INITIAL or PREF_ADDR RCID may be added after
163 * The current RCID we prefer to use (value undefined if
166 * This is preferentially set to a numbered RCID (represented by an RCID
179 * Total number of packets sent since we last made a packet count-based RCID
184 /* Number of post-handshake RCID changes we have performed. */
193 /* (SORT BY seq_num ASC) -> (RCID *) */
194 PRIORITY_QUEUE_OF(RCID) * rcids;
197 * Current RCID object we are using. This may differ from the first item in
203 RCID *cur_rcid;
206 * When a RCID becomes pending-retirement, it is moved to the retiring_list,
222 /* Do we have any RCID we can use currently? */
228 /* odcid was set (not necessarily still valid as a RCID)? */
230 /* retry_odcid was set (not necessarily still valid as a RCID?) */
232 /* An initial RCID was added as an RCID structure? */
234 /* Has a RCID roll been manually requested? */
246 static void rcidm_transition_rcid(QUIC_RCIDM *rcidm, RCID *rcid,
249 /* Check invariants of an RCID */
250 static void rcidm_check_rcid(QUIC_RCIDM *rcidm, RCID *rcid)
252 assert(rcid->state == RCID_STATE_PENDING
253 || rcid->state == RCID_STATE_CUR
254 || rcid->state == RCID_STATE_RETIRING);
255 assert((rcid->state == RCID_STATE_PENDING)
256 == (rcid->pq_idx != SIZE_MAX));
257 assert((rcid->state == RCID_STATE_CUR)
258 == (rcidm->cur_rcid == rcid));
259 assert((ossl_list_retiring_next(rcid) != NULL
260 || ossl_list_retiring_prev(rcid) != NULL
261 || ossl_list_retiring_head(&rcidm->retiring_list) == rcid)
262 == (rcid->state == RCID_STATE_RETIRING));
263 assert(rcid->type != RCID_TYPE_INITIAL || rcid->seq_num == 0);
264 assert(rcid->type != RCID_TYPE_PREF_ADDR || rcid->seq_num == 1);
265 assert(rcid->seq_num <= OSSL_QUIC_VLINT_MAX);
266 assert(rcid->cid.id_len > 0 && rcid->cid.id_len <= QUIC_MAX_CONN_ID_LEN);
267 assert(rcid->seq_num >= rcidm->retire_prior_to
268 || rcid->state == RCID_STATE_RETIRING);
270 assert(rcid->state != RCID_STATE_RETIRING || rcidm->num_retiring > 0);
273 static int rcid_cmp(const RCID *a, const RCID *b)
305 RCID *rcid, *rnext;
311 while ((rcid = ossl_pqueue_RCID_pop(rcidm->rcids)) != NULL)
312 OPENSSL_free(rcid);
314 OSSL_LIST_FOREACH_DELSAFE(rcid, rnext, retiring, &rcidm->retiring_list)
315 OPENSSL_free(rcid);
322 const QUIC_CONN_ID *rcid)
324 if (rcid == NULL) {
330 if (ossl_quic_conn_id_eq(&rcidm->preferred_rcid, rcid))
333 rcidm->preferred_rcid = *rcid;
339 * RCID Lifecycle Management
342 static RCID *rcidm_create_rcid(QUIC_RCIDM *rcidm, uint64_t seq_num,
346 RCID *rcid;
354 if ((rcid = OPENSSL_zalloc(sizeof(*rcid))) == NULL)
357 rcid->seq_num = seq_num;
358 rcid->cid = *cid;
359 rcid->type = type;
361 if (rcid->seq_num >= rcidm->retire_prior_to) {
362 rcid->state = RCID_STATE_PENDING;
364 if (!ossl_pqueue_RCID_push(rcidm->rcids, rcid, &rcid->pq_idx)) {
365 OPENSSL_free(rcid);
369 /* RCID is immediately retired upon creation. */
370 rcid->state = RCID_STATE_RETIRING;
371 rcid->pq_idx = SIZE_MAX;
372 ossl_list_retiring_insert_tail(&rcidm->retiring_list, rcid);
376 rcidm_check_rcid(rcidm, rcid);
377 return rcid;
380 static void rcidm_transition_rcid(QUIC_RCIDM *rcidm, RCID *rcid,
383 unsigned int old_state = rcid->state;
386 rcidm_check_rcid(rcidm, rcid);
396 ossl_pqueue_RCID_remove(rcidm->rcids, rcid->pq_idx);
397 rcid->pq_idx = SIZE_MAX;
400 rcid->state = state;
403 rcidm->cur_rcid = rcid;
408 ossl_list_retiring_insert_tail(&rcidm->retiring_list, rcid);
412 rcidm_check_rcid(rcidm, rcid);
415 static void rcidm_free_rcid(QUIC_RCIDM *rcidm, RCID *rcid)
417 if (rcid == NULL)
420 rcidm_check_rcid(rcidm, rcid);
422 switch (rcid->state) {
424 ossl_pqueue_RCID_remove(rcidm->rcids, rcid->pq_idx);
430 ossl_list_retiring_remove(&rcidm->retiring_list, rcid);
438 OPENSSL_free(rcid);
444 RCID *rcid;
450 * Retire the current RCID (if any) if it is affected.
460 while ((rcid = ossl_pqueue_RCID_peek(rcidm->rcids)) != NULL
461 && rcid->seq_num < retire_prior_to)
462 rcidm_transition_rcid(rcidm, rcid, RCID_STATE_RETIRING);
474 RCID *rcid;
476 if ((rcid = ossl_pqueue_RCID_peek(rcidm->rcids)) == NULL)
479 rcidm_transition_rcid(rcidm, rcid, RCID_STATE_CUR);
492 RCID *rcid;
495 * If we have no current numbered RCID but have one or more pending, use it.
498 && (rcid = ossl_pqueue_RCID_peek(rcidm->rcids)) != NULL) {
499 rcidm_transition_rcid(rcidm, rcid, RCID_STATE_CUR);
503 /* Prefer use of any current numbered RCID we have, if possible. */
582 const QUIC_CONN_ID *rcid)
584 RCID *rcid_obj;
590 rcid, RCID_TYPE_INITIAL);
614 RCID *rcid;
616 rcid = rcidm_create_rcid(rcidm, ncid->seq_num, &ncid->conn_id, RCID_TYPE_NCID);
617 if (rcid == NULL)
632 RCID *rcid = ossl_list_retiring_head(&rcidm->retiring_list);
634 if (rcid == NULL)
638 *seq_num = rcid->seq_num;
641 rcidm_free_rcid(rcidm, rcid);