Connection ID Steering (#165)

This commit is contained in:
Victor Stewart 2020-09-26 19:11:28 +01:00 committed by GitHub
parent fcd21c67ff
commit ece7c94dac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 5 deletions

View file

@ -1186,6 +1186,12 @@ struct lsquic_engine_api
*/
const struct lsquic_packout_mem_if *ea_pmi;
void *ea_pmi_ctx;
/**
* Optional interface to control the creation of connection IDs
*/
void (*es_generate_scid)(lsquic_conn_t *, lsquic_cid_t *, unsigned);
/**
* Optional interface to report new and old source connection IDs.
*/

View file

@ -553,8 +553,13 @@ gen_trans_params (struct enc_sess_iquic *enc_sess, unsigned char *buf,
}
cce->cce_seqno = seqno + 1;
cce->cce_flags = CCE_SEQNO;
lsquic_generate_cid(&cce->cce_cid,
enc_sess->esi_enpub->enp_settings.es_scid_len);
if (enc_sess->esi_enpub->enp_generate_scid)
enc_sess->esi_enpub->enp_generate_scid(enc_sess->esi_conn, &cce->cce_cid, enc_sess->esi_enpub->enp_settings.es_scid_len);
else
lsquic_generate_cid(&cce->cce_cid, enc_sess->esi_enpub->enp_settings.es_scid_len);
/* Don't add to hash: migration must not start until *after*
* handshake is complete.
*/

View file

@ -576,6 +576,9 @@ lsquic_engine_new (unsigned flags,
engine->pub.enp_lookup_cert = api->ea_lookup_cert;
engine->pub.enp_cert_lu_ctx = api->ea_cert_lu_ctx;
engine->pub.enp_get_ssl_ctx = api->ea_get_ssl_ctx;
engine->pub.enp_generate_scid = api->es_generate_scid;
if (api->ea_shi)
{
engine->pub.enp_shi = api->ea_shi;

View file

@ -44,6 +44,7 @@ struct lsquic_engine_public {
void *enp_stream_if_ctx;
const struct lsquic_hset_if *enp_hsi_if;
void *enp_hsi_ctx;
void (*enp_generate_scid)(lsquic_conn_t *, lsquic_cid_t *, unsigned);
int (*enp_verify_cert)(void *verify_ctx,
struct stack_st_X509 *chain);
void *enp_verify_ctx;

View file

@ -1086,7 +1086,13 @@ ietf_full_conn_add_scid (struct ietf_full_conn *conn,
}
if (enpub->enp_settings.es_scid_len)
lsquic_generate_cid(&cce->cce_cid, enpub->enp_settings.es_scid_len);
{
if (enpub->enp_generate_scid)
enpub->enp_generate_scid(lconn, &cce->cce_cid, enpub->enp_settings.es_scid_len);
else
lsquic_generate_cid(&cce->cce_cid, enpub->enp_settings.es_scid_len);
}
cce->cce_seqno = conn->ifc_scid_seqno++;
cce->cce_flags |= CCE_SEQNO | flags;
lconn->cn_cces_mask |= 1 << (cce - lconn->cn_cces);

View file

@ -495,8 +495,12 @@ lsquic_mini_conn_ietf_new (struct lsquic_engine_public *enpub,
/* Generate new SCID. Since is not the original SCID, it is given
* a sequence number (0) and therefore can be retired by the client.
*/
lsquic_generate_cid(&conn->imc_conn.cn_cces[1].cce_cid,
enpub->enp_settings.es_scid_len);
if (enpub->enp_settings.es_scid_len && enpub->enp_generate_scid)
enpub->enp_generate_scid(&conn->imc_conn, &conn->imc_conn.cn_cces[1].cce_cid, enpub->enp_settings.es_scid_len);
else
lsquic_generate_cid(&conn->imc_conn.cn_cces[1].cce_cid, enpub->enp_settings.es_scid_len);
LSQ_DEBUGC("generated SCID %"CID_FMT" at index %u, switching to it",
CID_BITS(&conn->imc_conn.cn_cces[1].cce_cid), 1);
conn->imc_conn.cn_cces[1].cce_flags = CCE_SEQNO | CCE_USED;