Skip to content

Commit 2ed0721

Browse files
author
Dmitri Tikhonov
committed
Release 2.24.3
- [BUGFIX] Get rough RTT estimate on receipt of Handshake packet. This prevents BBR on the client from miscalculating pacing rate, slowing down sending of ACK packets. - [BUGFIX] Packets sent during handshake are app-limited. - [BUGFIX] Bandwidth sampler starts in app-limited mode. - [BUGFIX] Memory leak: free QPACK handler context in stream dtor. - Logging improvements.
1 parent ee4d393 commit 2ed0721

File tree

9 files changed

+90
-8
lines changed

9 files changed

+90
-8
lines changed

CHANGELOG

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2020-11-11
2+
- 2.24.3
3+
- [BUGFIX] Get rough RTT estimate on receipt of Handshake packet.
4+
This prevents BBR on the client from miscalculating pacing rate,
5+
slowing down sending of ACK packets.
6+
- [BUGFIX] Packets sent during handshake are app-limited.
7+
- [BUGFIX] Bandwidth sampler starts in app-limited mode.
8+
- [BUGFIX] Memory leak: free QPACK handler context in stream dtor.
9+
- Logging improvements.
10+
111
2020-11-05
212
- 2.24.2
313
- [BUGFIX] Allow peer to migrate when its SCID is zero-length.

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# The short X.Y version
2727
version = u'2.24'
2828
# The full version, including alpha/beta/rc tags
29-
release = u'2.24.2'
29+
release = u'2.24.3'
3030

3131

3232
# -- General configuration ---------------------------------------------------

include/lsquic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C" {
2525

2626
#define LSQUIC_MAJOR_VERSION 2
2727
#define LSQUIC_MINOR_VERSION 24
28-
#define LSQUIC_PATCH_VERSION 2
28+
#define LSQUIC_PATCH_VERSION 3
2929

3030
/**
3131
* Engine flags:

src/liblsquic/lsquic_bw_sampler.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ lsquic_bw_sampler_init (struct bw_sampler *sampler, struct lsquic_conn *conn,
3737
sampler->bws_malo = malo;
3838
sampler->bws_conn = conn;
3939
sampler->bws_retx_frames = retx_frames;
40+
sampler->bws_flags |= BWS_APP_LIMITED;
4041
LSQ_DEBUG("init");
4142
return 0;
4243
}

src/liblsquic/lsquic_full_conn.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,6 +3545,7 @@ full_conn_ci_tick (lsquic_conn_t *lconn, lsquic_time_t now)
35453545
if (!handshake_done_or_doing_sess_resume(conn))
35463546
{
35473547
process_hsk_stream_write_events(conn);
3548+
lsquic_send_ctl_maybe_app_limited(&conn->fc_send_ctl, &conn->fc_path);
35483549
goto end_write;
35493550
}
35503551

src/liblsquic/lsquic_full_conn_ietf.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7069,12 +7069,16 @@ process_regular_packet (struct ietf_full_conn *conn,
70697069
if (pns == PNS_INIT)
70707070
conn->ifc_conn.cn_esf.i->esfi_set_iscid(conn->ifc_conn.cn_enc_session,
70717071
packet_in);
7072+
else if (pns == PNS_HSK)
7073+
lsquic_send_ctl_maybe_calc_rough_rtt(&conn->ifc_send_ctl, pns - 1);
70727074
if ((pns == PNS_INIT && (conn->ifc_flags & IFC_IGNORE_INIT))
70737075
|| (pns == PNS_HSK && (conn->ifc_flags & IFC_IGNORE_HSK)))
70747076
{
70757077
/* Don't bother decrypting */
70767078
LSQ_DEBUG("ignore %s packet",
70777079
pns == PNS_INIT ? "Initial" : "Handshake");
7080+
EV_LOG_CONN_EVENT(LSQUIC_LOG_CONN_ID, "ignore %s packet",
7081+
lsquic_pns2str[pns]);
70787082
return 0;
70797083
}
70807084

@@ -8087,7 +8091,11 @@ ietf_full_conn_ci_tick (struct lsquic_conn *lconn, lsquic_time_t now)
80878091
if (0 == s)
80888092
process_crypto_stream_write_events(conn);
80898093
if (!(conn->ifc_mflags & MF_DOING_0RTT))
8094+
{
8095+
lsquic_send_ctl_maybe_app_limited(&conn->ifc_send_ctl,
8096+
CUR_NPATH(conn));
80908097
goto end_write;
8098+
}
80918099
}
80928100

80938101
maybe_conn_flush_special_streams(conn);

src/liblsquic/lsquic_send_ctl.c

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@
5757
#define LSQUIC_LOG_CONN_ID lsquic_conn_log_cid(ctl->sc_conn_pub->lconn)
5858
#include "lsquic_logger.h"
5959

60+
#if __GNUC__
61+
# define UNLIKELY(cond) __builtin_expect(cond, 0)
62+
#else
63+
# define UNLIKELY(cond) cond
64+
#endif
65+
6066
#define MAX_RESUBMITTED_ON_RTO 2
6167
#define MAX_RTO_BACKOFFS 10
6268
#define DEFAULT_RETX_DELAY 500000 /* Microseconds */
@@ -742,6 +748,12 @@ take_rtt_sample (lsquic_send_ctl_t *ctl,
742748
const lsquic_time_t measured_rtt = now - sent;
743749
if (packno > ctl->sc_max_rtt_packno && lack_delta < measured_rtt)
744750
{
751+
if (UNLIKELY(ctl->sc_flags & SC_ROUGH_RTT))
752+
{
753+
memset(&ctl->sc_conn_pub->rtt_stats, 0,
754+
sizeof(ctl->sc_conn_pub->rtt_stats));
755+
ctl->sc_flags &= ~SC_ROUGH_RTT;
756+
}
745757
ctl->sc_max_rtt_packno = packno;
746758
lsquic_rtt_stats_update(&ctl->sc_conn_pub->rtt_stats, measured_rtt, lack_delta);
747759
LSQ_DEBUG("packno %"PRIu64"; rtt: %"PRIu64"; delta: %"PRIu64"; "
@@ -1117,12 +1129,6 @@ lsquic_send_ctl_got_ack (lsquic_send_ctl_t *ctl,
11171129
__builtin_prefetch(packet_out);
11181130
#endif
11191131

1120-
#if __GNUC__
1121-
# define UNLIKELY(cond) __builtin_expect(cond, 0)
1122-
#else
1123-
# define UNLIKELY(cond) cond
1124-
#endif
1125-
11261132
#if __GNUC__
11271133
if (UNLIKELY(LSQ_LOG_ENABLED(LSQ_LOG_DEBUG)))
11281134
#endif
@@ -1520,9 +1526,22 @@ send_ctl_all_bytes_out (const struct lsquic_send_ctl *ctl)
15201526
int
15211527
lsquic_send_ctl_pacer_blocked (struct lsquic_send_ctl *ctl)
15221528
{
1529+
#ifdef NDEBUG
15231530
return (ctl->sc_flags & SC_PACE)
15241531
&& !lsquic_pacer_can_schedule(&ctl->sc_pacer,
15251532
ctl->sc_n_in_flight_all);
1533+
#else
1534+
if (ctl->sc_flags & SC_PACE)
1535+
{
1536+
const int blocked = !lsquic_pacer_can_schedule(&ctl->sc_pacer,
1537+
ctl->sc_n_in_flight_all);
1538+
LSQ_DEBUG("pacer blocked: %d, in_flight_all: %u", blocked,
1539+
ctl->sc_n_in_flight_all);
1540+
return blocked;
1541+
}
1542+
else
1543+
return 0;
1544+
#endif
15261545
}
15271546

15281547

@@ -3214,6 +3233,42 @@ lsquic_send_ctl_set_token (struct lsquic_send_ctl *ctl,
32143233
}
32153234

32163235

3236+
void
3237+
lsquic_send_ctl_maybe_calc_rough_rtt (struct lsquic_send_ctl *ctl,
3238+
enum packnum_space pns)
3239+
{
3240+
const struct lsquic_packet_out *packet_out;
3241+
lsquic_time_t min_sent, rtt;
3242+
struct lsquic_packets_tailq *const *q;
3243+
struct lsquic_packets_tailq *const queues[] = {
3244+
&ctl->sc_lost_packets,
3245+
&ctl->sc_unacked_packets[pns],
3246+
};
3247+
3248+
if ((ctl->sc_flags & SC_ROUGH_RTT)
3249+
|| lsquic_rtt_stats_get_srtt(&ctl->sc_conn_pub->rtt_stats))
3250+
return;
3251+
3252+
min_sent = UINT64_MAX;
3253+
for (q = queues; q < queues + sizeof(queues) / sizeof(queues[0]); ++q)
3254+
TAILQ_FOREACH(packet_out, *q, po_next)
3255+
if (min_sent > packet_out->po_sent)
3256+
min_sent = packet_out->po_sent;
3257+
3258+
/* If we do not have an RTT estimate yet, get a rough estimate of it,
3259+
* because now we will ignore packets that carry acknowledgements and
3260+
* RTT estimation may be delayed.
3261+
*/
3262+
if (min_sent < UINT64_MAX)
3263+
{
3264+
rtt = lsquic_time_now() - min_sent;
3265+
lsquic_rtt_stats_update(&ctl->sc_conn_pub->rtt_stats, rtt, 0);
3266+
ctl->sc_flags |= SC_ROUGH_RTT;
3267+
LSQ_DEBUG("set rough RTT to %"PRIu64" usec", rtt);
3268+
}
3269+
}
3270+
3271+
32173272
void
32183273
lsquic_send_ctl_empty_pns (struct lsquic_send_ctl *ctl, enum packnum_space pns)
32193274
{

src/liblsquic/lsquic_send_ctl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ enum send_ctl_flags {
5353
SC_ACK_RECV_INIT= 1 << 19,
5454
SC_ACK_RECV_HSK = SC_ACK_RECV_INIT << PNS_HSK,
5555
SC_ACK_RECV_APP = SC_ACK_RECV_INIT << PNS_APP,
56+
SC_ROUGH_RTT = 1 << 22,
5657
};
5758

5859
typedef struct lsquic_send_ctl {
@@ -366,6 +367,10 @@ lsquic_send_ctl_set_token (struct lsquic_send_ctl *,
366367
void
367368
lsquic_send_ctl_empty_pns (struct lsquic_send_ctl *, enum packnum_space);
368369

370+
void
371+
lsquic_send_ctl_maybe_calc_rough_rtt (struct lsquic_send_ctl *,
372+
enum packnum_space);
373+
369374
void
370375
lsquic_send_ctl_repath (struct lsquic_send_ctl *ctl,
371376
const struct network_path *old, const struct network_path *new,

src/liblsquic/lsquic_stream.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,8 @@ lsquic_stream_destroy (lsquic_stream_t *stream)
701701
destroy_uh(stream);
702702
free(stream->sm_buf);
703703
free(stream->sm_header_block);
704+
if (stream->sm_hblock_ctx)
705+
free(stream->sm_hblock_ctx);
704706
LSQ_DEBUG("destroyed stream");
705707
SM_HISTORY_DUMP_REMAINING(stream);
706708
free(stream);

0 commit comments

Comments
 (0)