Skip to content

Commit

Permalink
Release 2.10.5
Browse files Browse the repository at this point in the history
- [BUGFIX] BBR: call cci_sent() with correct arguments and at correct time.
- Refactor transport parameters module.
- Minor code cleanup.
  • Loading branch information
Dmitri Tikhonov committed Feb 13, 2020
1 parent e68b045 commit 1bdb91d
Show file tree
Hide file tree
Showing 12 changed files with 462 additions and 460 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2020-02-13
- 2.10.5
- [BUGFIX] BBR: call cci_sent() with correct arguments and at correct
time.
- Refactor transport parameters module.
- Minor code cleanup.

2020-02-11
- 2.10.4
- [BUGFIX] Send HANDSHAKE_DONE only after Finished is received.
Expand Down
3 changes: 1 addition & 2 deletions include/lsquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern "C" {

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

/**
* Engine flags:
Expand Down Expand Up @@ -757,7 +757,6 @@ struct lsquic_engine_settings {
* 0: Do not use loss bits
* 1: Allow loss bits
* 2: Allow and send loss bits
* -1: Allow and send loss bits, sending old-style boolean loss_bits TP
*
* Default value is @ref LSQUIC_DF_QL_BITS
*/
Expand Down
51 changes: 28 additions & 23 deletions src/liblsquic/lsquic_enc_sess_ietf.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,15 +436,14 @@ gen_trans_params (struct enc_sess_iquic *enc_sess, unsigned char *buf,
{
const struct lsquic_conn *const lconn = enc_sess->esi_conn;

params.tp_flags |= TRAPA_SERVER|TRAPA_RESET_TOKEN;

params.tp_set |= 1 << TPI_STATELESS_RESET_TOKEN;
lsquic_tg_generate_sreset(enc_sess->esi_enpub->enp_tokgen,
CN_SCID(lconn), params.tp_stateless_reset_token);

if (enc_sess->esi_flags & ESI_ODCID)
{
params.tp_original_cid = enc_sess->esi_odcid;
params.tp_flags |= TRAPA_ORIGINAL_CID;
params.tp_set |= 1 << TPI_ORIGINAL_CONNECTION_ID;
}
#if LSQUIC_PREFERRED_ADDR
char addr_buf[INET6_ADDRSTRLEN + 6 /* port */ + 1];
Expand All @@ -459,7 +458,7 @@ gen_trans_params (struct enc_sess_iquic *enc_sess, unsigned char *buf,
addr_buf[colon - s] = '\0';
inet_pton(AF_INET, addr_buf, params.tp_preferred_address.ipv4_addr);
params.tp_preferred_address.ipv4_port = atoi(colon + 1);
params.tp_flags |= TRAPA_PREFADDR_IPv4;
params.tp_set |= 1 << TPI_PREFERRED_ADDRESS;
}
s = getenv("LSQUIC_PREFERRED_ADDR6");
if (s && strlen(s) < sizeof(addr_buf) && (colon = strrchr(s, ':')))
Expand All @@ -469,10 +468,10 @@ gen_trans_params (struct enc_sess_iquic *enc_sess, unsigned char *buf,
inet_pton(AF_INET6, addr_buf,
params.tp_preferred_address.ipv6_addr);
params.tp_preferred_address.ipv6_port = atoi(colon + 1);
params.tp_flags |= TRAPA_PREFADDR_IPv6;
params.tp_set |= 1 << TPI_PREFERRED_ADDRESS;
}
conn = enc_sess->esi_conn;
if ((params.tp_flags & (TRAPA_PREFADDR_IPv4|TRAPA_PREFADDR_IPv6))
if ((params.tp_set & (1 << TPI_PREFERRED_ADDRESS))
&& (1 << conn->cn_n_cces) - 1 != conn->cn_cces_mask)
{
seqno = 0;
Expand Down Expand Up @@ -506,7 +505,7 @@ gen_trans_params (struct enc_sess_iquic *enc_sess, unsigned char *buf,
else
{
cant_use_prefaddr:
params.tp_flags &= ~(TRAPA_PREFADDR_IPv4|TRAPA_PREFADDR_IPv6);
params.tp_set &= ~(1 << TPI_PREFERRED_ADDRESS);
}
#endif
}
Expand All @@ -515,7 +514,7 @@ gen_trans_params (struct enc_sess_iquic *enc_sess, unsigned char *buf,
{
const char *s = getenv("LSQUIC_TEST_QUANTUM_READINESS");
if (s && atoi(s))
params.tp_flags |= TRAPA_QUANTUM_READY;
params.tp_set |= 1 << TPI_QUANTUM_READINESS;
}
#endif
params.tp_init_max_data = settings->es_init_max_data;
Expand All @@ -535,23 +534,33 @@ gen_trans_params (struct enc_sess_iquic *enc_sess, unsigned char *buf,
params.tp_max_ack_delay = TP_DEF_MAX_ACK_DELAY;
params.tp_max_packet_size = 1370 /* XXX: based on socket */;
params.tp_active_connection_id_limit = MAX_IETF_CONN_DCIDS;
params.tp_set |= (1 << TPI_INIT_MAX_DATA)
| (1 << TPI_INIT_MAX_STREAM_DATA_BIDI_LOCAL)
| (1 << TPI_INIT_MAX_STREAM_DATA_BIDI_REMOTE)
| (1 << TPI_INIT_MAX_STREAM_DATA_UNI)
| (1 << TPI_INIT_MAX_STREAMS_UNI)
| (1 << TPI_INIT_MAX_STREAMS_BIDI)
| (1 << TPI_ACK_DELAY_EXPONENT)
| (1 << TPI_MAX_IDLE_TIMEOUT)
| (1 << TPI_MAX_ACK_DELAY)
| (1 << TPI_MAX_PACKET_SIZE)
| (1 << TPI_ACTIVE_CONNECTION_ID_LIMIT)
;
if (enc_sess->esi_conn->cn_version == LSQVER_ID24)
{
params.tp_active_connection_id_limit = params.tp_active_connection_id_limit
- 1 /* One slot is used by peer's SCID */
- !!(params.tp_flags & (TRAPA_PREFADDR_IPv4|TRAPA_PREFADDR_IPv6));
- !!(params.tp_set & (1 << TPI_PREFERRED_ADDRESS));
}
if (!settings->es_allow_migration)
params.tp_disable_active_migration = 1;
if (settings->es_ql_bits == -1)
params.tp_flags |= TRAPA_QL_BITS_OLD;
else if (settings->es_ql_bits)
params.tp_set |= 1 << TPI_DISABLE_ACTIVE_MIGRATION;
if (settings->es_ql_bits)
{
params.tp_loss_bits = settings->es_ql_bits - 1;
params.tp_flags |= TRAPA_QL_BITS;
params.tp_set |= 1 << TPI_LOSS_BITS;
}

len = lsquic_tp_encode(&params, buf, bufsz);
len = lsquic_tp_encode(&params, enc_sess->esi_flags & ESI_SERVER, buf, bufsz);
if (len >= 0)
LSQ_DEBUG("generated transport parameters buffer of %d bytes", len);
else
Expand Down Expand Up @@ -1458,7 +1467,7 @@ get_peer_transport_params (struct enc_sess_iquic *enc_sess)

if ((enc_sess->esi_flags & (ESI_ODCID|ESI_SERVER)) == ESI_ODCID)
{
if (!(trans_params->tp_flags & TRAPA_ORIGINAL_CID))
if (!(trans_params->tp_set & (1 << TPI_ORIGINAL_CONNECTION_ID)))
{
LSQ_DEBUG("server did not produce original DCID (ODCID)");
return -1;
Expand All @@ -1480,15 +1489,11 @@ get_peer_transport_params (struct enc_sess_iquic *enc_sess)
}
}

if ((trans_params->tp_flags & TRAPA_QL_BITS)
if ((trans_params->tp_set & (1 << TPI_LOSS_BITS))
&& enc_sess->esi_enpub->enp_settings.es_ql_bits)
{
unsigned our_loss_bits;
if (enc_sess->esi_enpub->enp_settings.es_ql_bits == -1)
our_loss_bits = 1;
else
our_loss_bits = enc_sess->esi_enpub->enp_settings.es_ql_bits - 1;

const unsigned our_loss_bits
= enc_sess->esi_enpub->enp_settings.es_ql_bits - 1;
switch ((our_loss_bits << 1) | trans_params->tp_loss_bits)
{
case (0 << 1) | 0:
Expand Down
2 changes: 1 addition & 1 deletion src/liblsquic/lsquic_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ lsquic_engine_check_settings (const struct lsquic_engine_settings *settings,
return -1;
}

if (!(settings->es_ql_bits >= -1 && settings->es_ql_bits <= 2))
if (!(settings->es_ql_bits >= 0 && settings->es_ql_bits <= 2))
{
if (err_buf)
snprintf(err_buf, err_buf_sz, "Invalid QL bits value %d ",
Expand Down
19 changes: 9 additions & 10 deletions src/liblsquic/lsquic_full_conn_id24.c
Original file line number Diff line number Diff line change
Expand Up @@ -2592,10 +2592,10 @@ begin_migra_or_retire_cid (struct id24_full_conn *conn,
struct sockaddr_in6 v6;
} sockaddr;

if (params->tp_disable_active_migration
if ((params->tp_set & (1 << TPI_DISABLE_ACTIVE_MIGRATION))
|| !conn->ifc_settings->es_allow_migration)
{
if (params->tp_disable_active_migration)
if (params->tp_set & (1 << TPI_DISABLE_ACTIVE_MIGRATION))
LSQ_DEBUG("TP disables migration: retire PreferredAddress CID");
else
LSQ_DEBUG("Migration not allowed: retire PreferredAddress CID");
Expand All @@ -2604,8 +2604,8 @@ begin_migra_or_retire_cid (struct id24_full_conn *conn,
}

is_ipv6 = NP_IS_IPv6(CUR_NPATH(conn));
if ((is_ipv6 && !(params->tp_flags & TRAPA_PREFADDR_IPv6))
|| (!is_ipv6 && !(params->tp_flags & TRAPA_PREFADDR_IPv4)))
if ((is_ipv6 && !lsquic_tp_has_pref_ipv6(params))
|| (!is_ipv6 && !lsquic_tp_has_pref_ipv4(params)))
{
/* XXX This is a limitation in the client code outside of the library.
* To support cross-IP-version migration, we need to add some callbacks
Expand Down Expand Up @@ -2683,7 +2683,7 @@ maybe_start_migration (struct id24_full_conn *conn)

params = lconn->cn_esf.i->esfi_get_peer_transport_params(
lconn->cn_enc_session);
if (params->tp_flags & (TRAPA_PREFADDR_IPv4|TRAPA_PREFADDR_IPv6))
if (params->tp_set & (1 << TPI_PREFERRED_ADDRESS))
{
if (0 != begin_migra_or_retire_cid(conn, params))
ABORT_QUIETLY(0, TEC_INTERNAL_ERROR, "error initiating migration");
Expand Down Expand Up @@ -2721,9 +2721,8 @@ handshake_ok (struct lsquic_conn *lconn)
LSQ_DEBUG("peer transport parameters: %s",
(lsquic_tp_to_str(params, buf, sizeof(buf)), buf));

if ((params->tp_flags & TRAPA_QL_BITS)
&& (conn->ifc_settings->es_ql_bits == 2
|| conn->ifc_settings->es_ql_bits == -1))
if ((params->tp_set & (1 << TPI_LOSS_BITS))
&& conn->ifc_settings->es_ql_bits == 2)
{
LSQ_DEBUG("turn on QL loss bits");
lsquic_send_ctl_do_ql_bits(&conn->ifc_send_ctl);
Expand Down Expand Up @@ -2797,7 +2796,7 @@ handshake_ok (struct lsquic_conn *lconn)
memset(dce, 0, sizeof(*dce));
dce->de_cid = *CUR_DCID(conn);
dce->de_seqno = 0;
if (params->tp_flags & TRAPA_RESET_TOKEN)
if (params->tp_set & (1 << TPI_STATELESS_RESET_TOKEN))
{
memcpy(dce->de_srst, params->tp_stateless_reset_token,
sizeof(dce->de_srst));
Expand Down Expand Up @@ -4795,7 +4794,7 @@ must_reserve_one_dce_slot (struct id24_full_conn *conn)
params = lconn->cn_esf.i->esfi_get_peer_transport_params(
lconn->cn_enc_session);
if (params) /* Just in case */
return !!(params->tp_flags & (TRAPA_PREFADDR_IPv4|TRAPA_PREFADDR_IPv6));
return !!(params->tp_set & (1 << TPI_PREFERRED_ADDRESS));
else
return 0;
}
Expand Down
17 changes: 8 additions & 9 deletions src/liblsquic/lsquic_full_conn_ietf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2765,10 +2765,10 @@ begin_migra_or_retire_cid (struct ietf_full_conn *conn,
struct sockaddr_in6 v6;
} sockaddr;

if (params->tp_disable_active_migration
if ((params->tp_set & (1 << TPI_DISABLE_ACTIVE_MIGRATION))
|| !conn->ifc_settings->es_allow_migration)
{
if (params->tp_disable_active_migration)
if (params->tp_set & (1 << TPI_DISABLE_ACTIVE_MIGRATION))
LSQ_DEBUG("TP disables migration: retire PreferredAddress CID");
else
LSQ_DEBUG("Migration not allowed: retire PreferredAddress CID");
Expand All @@ -2777,8 +2777,8 @@ begin_migra_or_retire_cid (struct ietf_full_conn *conn,
}

is_ipv6 = NP_IS_IPv6(CUR_NPATH(conn));
if ((is_ipv6 && !(params->tp_flags & TRAPA_PREFADDR_IPv6))
|| (!is_ipv6 && !(params->tp_flags & TRAPA_PREFADDR_IPv4)))
if ((is_ipv6 && !lsquic_tp_has_pref_ipv6(params))
|| (!is_ipv6 && !lsquic_tp_has_pref_ipv4(params)))
{
/* XXX This is a limitation in the client code outside of the library.
* To support cross-IP-version migration, we need to add some callbacks
Expand Down Expand Up @@ -2856,7 +2856,7 @@ maybe_start_migration (struct ietf_full_conn *conn)

params = lconn->cn_esf.i->esfi_get_peer_transport_params(
lconn->cn_enc_session);
if (params->tp_flags & (TRAPA_PREFADDR_IPv4|TRAPA_PREFADDR_IPv6))
if (params->tp_set & (1 << TPI_PREFERRED_ADDRESS))
{
if (0 != begin_migra_or_retire_cid(conn, params))
ABORT_QUIETLY(0, TEC_INTERNAL_ERROR, "error initiating migration");
Expand Down Expand Up @@ -2894,9 +2894,8 @@ handshake_ok (struct lsquic_conn *lconn)
LSQ_DEBUG("peer transport parameters: %s",
(lsquic_tp_to_str(params, buf, sizeof(buf)), buf));

if ((params->tp_flags & TRAPA_QL_BITS)
&& (conn->ifc_settings->es_ql_bits == 2
|| conn->ifc_settings->es_ql_bits == -1))
if ((params->tp_set & (1 << TPI_LOSS_BITS))
&& conn->ifc_settings->es_ql_bits == 2)
{
LSQ_DEBUG("turn on QL loss bits");
lsquic_send_ctl_do_ql_bits(&conn->ifc_send_ctl);
Expand Down Expand Up @@ -3005,7 +3004,7 @@ handshake_ok (struct lsquic_conn *lconn)
memset(dce, 0, sizeof(*dce));
dce->de_cid = *CUR_DCID(conn);
dce->de_seqno = 0;
if (params->tp_flags & TRAPA_RESET_TOKEN)
if (params->tp_set & (1 << TPI_STATELESS_RESET_TOKEN))
{
memcpy(dce->de_srst, params->tp_stateless_reset_token,
sizeof(dce->de_srst));
Expand Down
3 changes: 2 additions & 1 deletion src/liblsquic/lsquic_parse_gquic_be.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,9 +887,10 @@ gquic_be_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
*type |= bits;

CHECKOUT(largest_acked_len);
tmp_packno = maxno;
#if __BYTE_ORDER == __LITTLE_ENDIAN
tmp_packno = bswap_64(maxno);
#else
tmp_packno = maxno;
#endif
memcpy(p, (unsigned char *) &tmp_packno + 8 - largest_acked_len,
largest_acked_len);
Expand Down
6 changes: 3 additions & 3 deletions src/liblsquic/lsquic_send_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,9 @@ lsquic_send_ctl_sent_packet (lsquic_send_ctl_t *ctl,
packet_out->po_packno, lsquic_frame_types_to_str(frames,
sizeof(frames), packet_out->po_frame_types));
lsquic_senhist_add(&ctl->sc_senhist, packet_out->po_packno);
if (ctl->sc_ci->cci_sent)
ctl->sc_ci->cci_sent(CGP(ctl), packet_out, ctl->sc_bytes_unacked_all,
ctl->sc_flags & SC_APP_LIMITED);
send_ctl_unacked_append(ctl, packet_out);
if (packet_out->po_frame_types & ctl->sc_retx_frames)
{
Expand All @@ -670,9 +673,6 @@ lsquic_send_ctl_sent_packet (lsquic_send_ctl_t *ctl,
#if LSQUIC_SEND_STATS
++ctl->sc_stats.n_total_sent;
#endif
if (ctl->sc_ci->cci_sent)
ctl->sc_ci->cci_sent(CGP(ctl), packet_out, ctl->sc_n_in_flight_all,
ctl->sc_flags & SC_APP_LIMITED);
lsquic_send_ctl_sanity_check(ctl);
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/liblsquic/lsquic_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -3407,10 +3407,10 @@ lsquic_stream_writef (lsquic_stream_t *stream, struct lsquic_reader *reader)
static ssize_t
stream_write_buf (struct lsquic_stream *stream, const void *buf, size_t sz)
{
struct iovec iov = { (void *) buf, sz, };
const struct iovec iov[1] = {{ (void *) buf, sz, }};
struct inner_reader_iovec iro = {
.iov = &iov,
.end = &iov + 1,
.iov = iov,
.end = iov + 1,
.cur_iovec_off = 0,
};
struct lsquic_reader reader = {
Expand Down
Loading

0 comments on commit 1bdb91d

Please sign in to comment.