Skip to content

Commit

Permalink
Release 2.5.0
Browse files Browse the repository at this point in the history
- [API] lsquic_engine_connect() can now be passed QUIC version to use.
- [OPTIMIZATION] Queue opportunistic ACKs if there is data to be sent.
- [BUGFIX] Don't evict streams from priority iterator if there is
  only one queue.
- [OPTIMIZATION, BUGFIX] Several other optimizations and bug fixes.
- Use ls-qpack v0.10.7.
  • Loading branch information
Dmitri Tikhonov committed Oct 31, 2019
1 parent 34e9ac5 commit a0e1aee
Show file tree
Hide file tree
Showing 34 changed files with 327 additions and 108 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2019-10-31
- 2.5.0
- [API] lsquic_engine_connect() can now be passed QUIC version to use.
- [OPTIMIZATION] Queue opportunistic ACKs if there is data to be sent.
- [BUGFIX] Don't evict streams from priority iterator if there is
only one queue.
- [OPTIMIZATION, BUGFIX] Several other optimizations and bug fixes.
- Use ls-qpack v0.10.7.

2019-10-24
- 2.4.10
- [BUGFIX] IETF QUIC server: fix uninitialized variable use.
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

OPTION(LSQUIC_FIU "Use Fault Injection in Userspace (FIU)" OFF)

SET(MY_CMAKE_FLAGS "-DLSQUIC_DEBUG_NEXT_ADV_TICK=1")
IF (NOT "$ENV{EXTRA_CFLAGS}" MATCHES "-DLSQUIC_DEBUG_NEXT_ADV_TICK")
SET(MY_CMAKE_FLAGS "-DLSQUIC_DEBUG_NEXT_ADV_TICK=1")
ENDIF()

IF (NOT MSVC)

Expand Down
11 changes: 8 additions & 3 deletions include/lsquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ extern "C" {
#endif

#define LSQUIC_MAJOR_VERSION 2
#define LSQUIC_MINOR_VERSION 4
#define LSQUIC_PATCH_VERSION 10
#define LSQUIC_MINOR_VERSION 5
#define LSQUIC_PATCH_VERSION 0

/**
* Engine flags:
Expand Down Expand Up @@ -1026,11 +1026,16 @@ lsquic_engine_new (unsigned lsquic_engine_flags,

/**
* Create a client connection to peer identified by `peer_ctx'.
*
* To let the engine specify QUIC version, use N_LSQVER. If zero-rtt info
* is supplied, version is picked from there instead.
*
* If `max_packet_size' is set to zero, it is inferred based on `peer_sa':
* 1350 for IPv6 and 1370 for IPv4.
*/
lsquic_conn_t *
lsquic_engine_connect (lsquic_engine_t *, const struct sockaddr *local_sa,
lsquic_engine_connect (lsquic_engine_t *, enum lsquic_version,
const struct sockaddr *local_sa,
const struct sockaddr *peer_sa,
void *peer_ctx, lsquic_conn_ctx_t *conn_ctx,
const char *hostname, unsigned short max_packet_size,
Expand Down
2 changes: 1 addition & 1 deletion src/liblsquic/ls-qpack
Submodule ls-qpack updated 4 files
+6 −2 bin/fuzz-decode.c
+136,247 −0 huff-tables.h
+5 −136,256 lsqpack.c
+1 −1 lsqpack.h
1 change: 0 additions & 1 deletion src/liblsquic/lsquic_alarmset.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ enum alarm_id_bit {
ALBIT_IDLE = 1 << AL_IDLE,
ALBIT_RET_CIDS = 1 << AL_RET_CIDS,
ALBIT_CID_THROT = 1 << AL_CID_THROT,
ALBIT_PATH_CHAL = 1 << AL_PATH_CHAL,
ALBIT_PATH_CHAL_0 = 1 << AL_PATH_CHAL_0,
ALBIT_PATH_CHAL_1 = 1 << AL_PATH_CHAL_1,
ALBIT_SESS_TICKET = 1 << AL_SESS_TICKET,
Expand Down
2 changes: 1 addition & 1 deletion src/liblsquic/lsquic_enc_sess_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ lsquic_zero_rtt_version (const unsigned char *buf, size_t bufsz)
return lsquic_tag2ver(tag);
}
else
return -1;
return N_LSQVER;
}
63 changes: 37 additions & 26 deletions src/liblsquic/lsquic_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1462,15 +1462,16 @@ add_conn_to_hash (struct lsquic_engine *engine, struct lsquic_conn *conn,


lsquic_conn_t *
lsquic_engine_connect (lsquic_engine_t *engine, const struct sockaddr *local_sa,
lsquic_engine_connect (lsquic_engine_t *engine, enum lsquic_version version,
const struct sockaddr *local_sa,
const struct sockaddr *peer_sa,
void *peer_ctx, lsquic_conn_ctx_t *conn_ctx,
const char *hostname, unsigned short max_packet_size,
const unsigned char *zero_rtt, size_t zero_rtt_len,
const unsigned char *token, size_t token_sz)
{
lsquic_conn_t *conn;
unsigned flags;
unsigned flags, versions;
int is_ipv4;

ENGINE_IN(engine);
Expand All @@ -1492,13 +1493,31 @@ lsquic_engine_connect (lsquic_engine_t *engine, const struct sockaddr *local_sa,
return NULL;
flags = engine->flags & (ENG_SERVER|ENG_HTTP);
is_ipv4 = peer_sa->sa_family == AF_INET;
if (engine->pub.enp_settings.es_versions & LSQUIC_IETF_VERSIONS)
conn = lsquic_ietf_full_conn_client_new(&engine->pub,
if (zero_rtt && zero_rtt_len)
{
version = lsquic_zero_rtt_version(zero_rtt, zero_rtt_len);
if (version >= N_LSQVER)
{
LSQ_INFO("zero-rtt version is bad, won't use");
zero_rtt = NULL;
zero_rtt_len = 0;
}
}
if (version >= N_LSQVER)
{
if (version > N_LSQVER)
LSQ_WARN("invalid version specified, engine will pick");
versions = engine->pub.enp_settings.es_versions;
}
else
versions = 1u << version;
if (versions & LSQUIC_IETF_VERSIONS)
conn = lsquic_ietf_full_conn_client_new(&engine->pub, versions,
flags, hostname, max_packet_size,
is_ipv4, zero_rtt, zero_rtt_len, token, token_sz);
else
conn = lsquic_gquic_full_conn_client_new(&engine->pub, flags,
hostname, max_packet_size, is_ipv4,
versions, hostname, max_packet_size, is_ipv4,
zero_rtt, zero_rtt_len);
if (!conn)
goto err;
Expand Down Expand Up @@ -1558,13 +1577,12 @@ refflags2str (enum lsquic_conn_flags flags, char s[6])
static void
engine_incref_conn (lsquic_conn_t *conn, enum lsquic_conn_flags flag)
{
const lsquic_cid_t *cid;
char str[2][7];
assert(flag & CONN_REF_FLAGS);
assert(!(conn->cn_flags & flag));
conn->cn_flags |= flag;
cid = lsquic_conn_log_cid(conn);
LSQ_DEBUGC("incref conn %"CID_FMT", '%s' -> '%s'", CID_BITS(cid),
LSQ_DEBUGC("incref conn %"CID_FMT", '%s' -> '%s'",
CID_BITS(lsquic_conn_log_cid(conn)),
(refflags2str(conn->cn_flags & ~flag, str[0]), str[0]),
(refflags2str(conn->cn_flags, str[1]), str[1]));
}
Expand All @@ -1574,7 +1592,6 @@ static lsquic_conn_t *
engine_decref_conn (lsquic_engine_t *engine, lsquic_conn_t *conn,
enum lsquic_conn_flags flags)
{
const lsquic_cid_t *cid;
char str[2][7];
lsquic_time_t now;
assert(flags & CONN_REF_FLAGS);
Expand All @@ -1584,8 +1601,8 @@ engine_decref_conn (lsquic_engine_t *engine, lsquic_conn_t *conn,
assert(0 == (conn->cn_flags & LSCONN_HASHED));
#endif
conn->cn_flags &= ~flags;
cid = lsquic_conn_log_cid(conn);
LSQ_DEBUGC("decref conn %"CID_FMT", '%s' -> '%s'", CID_BITS(cid),
LSQ_DEBUGC("decref conn %"CID_FMT", '%s' -> '%s'",
CID_BITS(lsquic_conn_log_cid(conn)),
(refflags2str(conn->cn_flags | flags, str[0]), str[0]),
(refflags2str(conn->cn_flags, str[1]), str[1]));
if (0 == (conn->cn_flags & CONN_REF_FLAGS))
Expand Down Expand Up @@ -2128,7 +2145,6 @@ send_packets_out (struct lsquic_engine *engine,
struct conns_tailq *ticked_conns,
struct conns_stailq *closed_conns)
{
const lsquic_cid_t *cid;
unsigned n, w, n_sent, n_batches_sent;
lsquic_packet_out_t *packet_out;
struct lsquic_packet_out **packet;
Expand All @@ -2148,14 +2164,13 @@ send_packets_out (struct lsquic_engine *engine,

while ((conn = coi_next(&conns_iter)))
{
cid = lsquic_conn_log_cid(conn);
packet_out = conn->cn_if->ci_next_packet_to_send(conn, 0);
if (!packet_out) {
/* Evanescent connection always has a packet to send: */
assert(!(conn->cn_flags & LSCONN_EVANESCENT));
LSQ_DEBUGC("batched all outgoing packets for %s conn %"CID_FMT,
(conn->cn_flags & LSCONN_MINI ? "mini" :
"full"), CID_BITS(cid));
(conn->cn_flags & LSCONN_MINI ? "mini" : "full"),
CID_BITS(lsquic_conn_log_cid(conn)));
coi_deactivate(&conns_iter, conn);
continue;
}
Expand All @@ -2174,7 +2189,7 @@ send_packets_out (struct lsquic_engine *engine,
/* This is pretty bad: close connection immediately */
conn->cn_if->ci_packet_not_sent(conn, packet_out);
LSQ_INFOC("conn %"CID_FMT" has unsendable packets",
CID_BITS(cid));
CID_BITS(lsquic_conn_log_cid(conn)));
if (!(conn->cn_flags & LSCONN_EVANESCENT))
{
if (!(conn->cn_flags & LSCONN_CLOSING))
Expand Down Expand Up @@ -2207,7 +2222,7 @@ send_packets_out (struct lsquic_engine *engine,
}
}
LSQ_DEBUGC("batched packet %"PRIu64" for connection %"CID_FMT,
packet_out->po_packno, CID_BITS(cid));
packet_out->po_packno, CID_BITS(lsquic_conn_log_cid(conn)));
if (packet_out->po_flags & PO_ENCRYPTED)
{
iov->iov_base = packet_out->po_enc_data;
Expand Down Expand Up @@ -2597,7 +2612,6 @@ lsquic_engine_earliest_adv_tick (lsquic_engine_t *engine, int *diff)
lsquic_time_t now, next_time;
#if LSQUIC_DEBUG_NEXT_ADV_TICK
const struct lsquic_conn *conn;
const lsquic_cid_t *cid;
const enum lsq_log_level L = LSQ_LOG_DEBUG; /* Easy toggle */
#endif

Expand All @@ -2608,11 +2622,11 @@ lsquic_engine_earliest_adv_tick (lsquic_engine_t *engine, int *diff)
{
#if LSQUIC_DEBUG_NEXT_ADV_TICK
conn = lsquic_mh_peek(&engine->conns_out);
cid = lsquic_conn_log_cid(conn);
LSQ_LOGC(L, "next advisory tick is now: went past deadline last time "
"and have %u outgoing connection%.*s (%"CID_FMT" first)",
lsquic_mh_count(&engine->conns_out),
lsquic_mh_count(&engine->conns_out) != 1, "s", CID_BITS(cid));
lsquic_mh_count(&engine->conns_out) != 1, "s",
CID_BITS(lsquic_conn_log_cid(conn)));
#endif
*diff = 0;
return 1;
Expand All @@ -2631,11 +2645,11 @@ lsquic_engine_earliest_adv_tick (lsquic_engine_t *engine, int *diff)
{
#if LSQUIC_DEBUG_NEXT_ADV_TICK
conn = lsquic_mh_peek(&engine->conns_tickable);
cid = lsquic_conn_log_cid(conn);
LSQ_LOGC(L, "next advisory tick is now: have %u tickable "
"connection%.*s (%"CID_FMT" first)",
lsquic_mh_count(&engine->conns_tickable),
lsquic_mh_count(&engine->conns_tickable) != 1, "s", CID_BITS(cid));
lsquic_mh_count(&engine->conns_tickable) != 1, "s",
CID_BITS(lsquic_conn_log_cid(conn)));
#endif
*diff = 0;
return 1;
Expand Down Expand Up @@ -2668,12 +2682,9 @@ lsquic_engine_earliest_adv_tick (lsquic_engine_t *engine, int *diff)
*diff = (int) ((int64_t) next_time - (int64_t) now);
#if LSQUIC_DEBUG_NEXT_ADV_TICK
if (next_attq)
{
cid = lsquic_conn_log_cid(next_attq->ae_conn);
LSQ_LOGC(L, "next advisory tick is %d usec away: conn %"CID_FMT
": %s", *diff, CID_BITS(cid),
": %s", *diff, CID_BITS(lsquic_conn_log_cid(next_attq->ae_conn)),
lsquic_attq_why2str(next_attq->ae_why));
}
else
LSQ_LOG(L, "next advisory tick is %d usec away: resume sending", *diff);
#endif
Expand Down
2 changes: 0 additions & 2 deletions src/liblsquic/lsquic_frame_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,6 @@ decode_and_pass_payload (struct lsquic_frame_reader *fr)
LSQ_INFO("%s: stream error %u", __func__, err);
if (hset)
fr->fr_hsi_if->hsi_discard_header_set(hset);
if (uh)
free(uh);
if (buf)
lsquic_mm_put_16k(fr->fr_mm, buf);
fr->fr_callbacks->frc_on_error(fr->fr_cb_ctx, fr_get_stream_id(fr), err);
Expand Down
18 changes: 11 additions & 7 deletions src/liblsquic/lsquic_full_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ struct full_conn
struct short_ack_info fc_saved_ack_info;
lsquic_time_t fc_saved_ack_received;
struct network_path fc_path;
unsigned fc_orig_versions; /* Client only */
};

static const struct ver_neg server_ver_neg;
Expand Down Expand Up @@ -672,7 +673,7 @@ new_conn_common (lsquic_cid_t cid, struct lsquic_engine_public *enpub,

struct lsquic_conn *
lsquic_gquic_full_conn_client_new (struct lsquic_engine_public *enpub,
unsigned flags,
unsigned versions, unsigned flags,
const char *hostname, unsigned short max_packet_size,
int is_ipv4,
const unsigned char *zero_rtt, size_t zero_rtt_len)
Expand All @@ -682,12 +683,13 @@ lsquic_gquic_full_conn_client_new (struct lsquic_engine_public *enpub,
lsquic_cid_t cid;
const struct enc_session_funcs_gquic *esf_g;

version = highest_bit_set(enpub->enp_settings.es_versions);
versions &= (~LSQUIC_IETF_VERSIONS & LSQUIC_SUPPORTED_VERSIONS);
assert(versions);
version = highest_bit_set(versions);
if (zero_rtt)
{
zero_rtt_version = lsquic_zero_rtt_version(zero_rtt, zero_rtt_len);
if (zero_rtt_version < N_LSQVER &&
((1 << zero_rtt_version) & enpub->enp_settings.es_versions))
if (zero_rtt_version < N_LSQVER && ((1 << zero_rtt_version) & versions))
version = zero_rtt_version;
}
esf_g = select_esf_gquic_by_ver(version);
Expand Down Expand Up @@ -725,7 +727,8 @@ lsquic_gquic_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, &version);
conn->fc_orig_versions = versions;
init_ver_neg(conn, 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);
Expand Down Expand Up @@ -2510,6 +2513,7 @@ idle_alarm_expired (enum alarm_id al_id, void *ctx, lsquic_time_t expiry,
{
struct full_conn *conn = ctx;
LSQ_DEBUG("connection timed out");
EV_LOG_CONN_EVENT(LSQUIC_LOG_CONN_ID, "connection timed out");
conn->fc_flags |= FC_TIMED_OUT;
}

Expand Down Expand Up @@ -4379,8 +4383,8 @@ lsquic_gquic_full_conn_srej (struct lsquic_conn *lconn)
lconn->cn_esf.g->esf_reset_cid(lconn->cn_enc_session, &cce->cce_cid);

/* Reset version negotiation */
version = highest_bit_set(conn->fc_settings->es_versions);
init_ver_neg(conn, conn->fc_settings->es_versions, &version);
version = highest_bit_set(conn->fc_orig_versions);
init_ver_neg(conn, conn->fc_orig_versions, &version);

/* Reset receive history */
lsquic_rechist_cleanup(&conn->fc_rechist);
Expand Down
2 changes: 2 additions & 0 deletions src/liblsquic/lsquic_full_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ struct lsquic_engine_public;

struct lsquic_conn *
lsquic_gquic_full_conn_client_new (struct lsquic_engine_public *,
unsigned versions,
unsigned flags /* Only FC_SERVER and FC_HTTP */,
const char *hostname, unsigned short max_packet_size,
int is_ipv4,
const unsigned char *zero_rtt, size_t zero_rtt_len);

struct lsquic_conn *
lsquic_ietf_full_conn_client_new (struct lsquic_engine_public *,
unsigned versions,
unsigned flags /* Only FC_SERVER and FC_HTTP */,
const char *hostname, unsigned short max_packet_size, int is_ipv4,
const unsigned char *zero_rtt, size_t,
Expand Down
Loading

0 comments on commit a0e1aee

Please sign in to comment.