From 33291708463acdf7f63a744e3e1c6565b1e802cd Mon Sep 17 00:00:00 2001 From: Dmitri Tikhonov Date: Mon, 11 Feb 2019 12:56:57 -0500 Subject: [PATCH] Release 1.19.2 - [BUGFIX] Begin negotiation with version provided in 0-RTT info. - [BUGFIX] Version checking in zero_rtt deserialize function. --- CHANGELOG | 5 +++++ include/lsquic.h | 2 +- src/liblsquic/lsquic_full_conn.c | 24 +++++++++++++++++------- src/liblsquic/lsquic_handshake.c | 4 +++- src/liblsquic/lsquic_send_ctl.c | 3 ++- src/liblsquic/lsquic_ver_neg.h | 3 ++- 6 files changed, 30 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 005bc372f..1caa20381 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +2019-02-11 + - 1.19.2 + - [BUGFIX] Begin negotiation with version provided in 0-RTT info. + - [BUGFIX] Version checking in zero_rtt deserialize function. + 2019-02-04 - 1.19.1 - [BUGFIX] Fix Windows build. diff --git a/include/lsquic.h b/include/lsquic.h index 603b8da75..4dc0c8f9b 100644 --- a/include/lsquic.h +++ b/include/lsquic.h @@ -25,7 +25,7 @@ extern "C" { #define LSQUIC_MAJOR_VERSION 1 #define LSQUIC_MINOR_VERSION 19 -#define LSQUIC_PATCH_VERSION 1 +#define LSQUIC_PATCH_VERSION 2 /** * Engine flags: diff --git a/src/liblsquic/lsquic_full_conn.c b/src/liblsquic/lsquic_full_conn.c index 39a73896c..824b9b3b2 100644 --- a/src/liblsquic/lsquic_full_conn.c +++ b/src/liblsquic/lsquic_full_conn.c @@ -369,10 +369,11 @@ calc_mem_used (const struct full_conn *conn) static void -set_versions (struct full_conn *conn, unsigned versions) +set_versions (struct full_conn *conn, unsigned versions, + enum lsquic_version *ver) { conn->fc_ver_neg.vn_supp = versions; - conn->fc_ver_neg.vn_ver = highest_bit_set(versions); + conn->fc_ver_neg.vn_ver = (ver) ? *ver : highest_bit_set(versions); conn->fc_ver_neg.vn_buf = lsquic_ver2tag(conn->fc_ver_neg.vn_ver); conn->fc_conn.cn_version = conn->fc_ver_neg.vn_ver; conn->fc_conn.cn_pf = select_pf_by_ver(conn->fc_ver_neg.vn_ver); @@ -382,9 +383,10 @@ set_versions (struct full_conn *conn, unsigned versions) static void -init_ver_neg (struct full_conn *conn, unsigned versions) +init_ver_neg (struct full_conn *conn, unsigned versions, + enum lsquic_version *ver) { - set_versions(conn, versions); + set_versions(conn, versions, ver); conn->fc_ver_neg.vn_tag = &conn->fc_ver_neg.vn_buf; conn->fc_ver_neg.vn_state = VN_START; } @@ -641,11 +643,19 @@ full_conn_client_new (struct lsquic_engine_public *enpub, const unsigned char *zero_rtt, size_t zero_rtt_len) { struct full_conn *conn; - enum lsquic_version version; + enum lsquic_version version, zero_rtt_version; lsquic_cid_t cid; const struct enc_session_funcs *esf; version = highest_bit_set(enpub->enp_settings.es_versions); + if (zero_rtt) + { + zero_rtt_version = lsquic_tag2ver( + ((struct lsquic_zero_rtt_storage *)zero_rtt)->quic_version_tag); + if (zero_rtt_version < N_LSQVER && + ((1 << zero_rtt_version) & enpub->enp_settings.es_versions)) + version = zero_rtt_version; + } esf = select_esf_by_ver(version); cid = esf->esf_generate_cid(); conn = new_conn_common(cid, enpub, stream_if, stream_if_ctx, flags, @@ -673,7 +683,7 @@ full_conn_client_new (struct lsquic_engine_public *enpub, conn->fc_stream_ifs[STREAM_IF_HSK] .stream_if = &lsquic_client_hsk_stream_if; conn->fc_stream_ifs[STREAM_IF_HSK].stream_if_ctx = &conn->fc_hsk_ctx.client; - init_ver_neg(conn, conn->fc_settings->es_versions); + init_ver_neg(conn, conn->fc_settings->es_versions, &version); if (conn->fc_settings->es_handshake_to) lsquic_alarmset_set(&conn->fc_alset, AL_HANDSHAKE, lsquic_time_now() + conn->fc_settings->es_handshake_to); @@ -1926,7 +1936,7 @@ process_ver_neg_packet (struct full_conn *conn, lsquic_packet_in_t *packet_in) return; } - set_versions(conn, versions); + set_versions(conn, versions, NULL); conn->fc_ver_neg.vn_state = VN_IN_PROGRESS; lsquic_send_ctl_expire_all(&conn->fc_send_ctl); } diff --git a/src/liblsquic/lsquic_handshake.c b/src/liblsquic/lsquic_handshake.c index 8160600cb..03db38f61 100644 --- a/src/liblsquic/lsquic_handshake.c +++ b/src/liblsquic/lsquic_handshake.c @@ -313,6 +313,7 @@ lsquic_enc_session_deserialize_zero_rtt( lsquic_session_cache_info_t *info, c_cert_item_t *cert_item) { + enum lsquic_version ver; uint32_t i, len; uint64_t hash; uint32_t *cert_len; @@ -321,7 +322,8 @@ lsquic_enc_session_deserialize_zero_rtt( /* * check versions */ - if (lsquic_tag2ver(storage->quic_version_tag) & ~settings->es_versions) + ver = lsquic_tag2ver(storage->quic_version_tag); + if ((int)ver == -1 || !((1 << ver) & settings->es_versions)) return RTT_DESERIALIZE_BAD_QUIC_VER; if (storage->serializer_version != RTT_SERIALIZER_VERSION) return RTT_DESERIALIZE_BAD_SERIAL_VER; diff --git a/src/liblsquic/lsquic_send_ctl.c b/src/liblsquic/lsquic_send_ctl.c index 8bde407bf..d3c98838e 100644 --- a/src/liblsquic/lsquic_send_ctl.c +++ b/src/liblsquic/lsquic_send_ctl.c @@ -905,7 +905,8 @@ lsquic_send_ctl_cleanup (lsquic_send_ctl_t *ctl) send_ctl_destroy_packet(ctl, packet_out); } } - pacer_cleanup(&ctl->sc_pacer); + if (ctl->sc_flags & SC_PACE) + pacer_cleanup(&ctl->sc_pacer); #if LSQUIC_SEND_STATS LSQ_NOTICE("stats: n_total_sent: %u; n_resent: %u; n_delayed: %u", ctl->sc_stats.n_total_sent, ctl->sc_stats.n_resent, diff --git a/src/liblsquic/lsquic_ver_neg.h b/src/liblsquic/lsquic_ver_neg.h index 06f7615fd..e4546953e 100644 --- a/src/liblsquic/lsquic_ver_neg.h +++ b/src/liblsquic/lsquic_ver_neg.h @@ -7,7 +7,8 @@ */ struct ver_neg { unsigned vn_supp; /* Remaining options, including `vn_ver' */ - enum lsquic_version vn_ver; /* If client, current version sent to server; + enum lsquic_version vn_ver; /* If client, current version sent to server + * (zero_rtt version or highest supported); * if server, this is set to negotiated version. */ enum ver_neg_state {