Skip to content

Commit fcbdf65

Browse files
author
Dmitri Tikhonov
committed
Release 2.26.0
- [OPTIMIZATION] Adjust packet reordering threshold when spurious losses are detected. - [API] Pass pointer to local sockaddr to ea_get_ssl_ctx() callback.
1 parent 7f96c7c commit fcbdf65

File tree

11 files changed

+98
-25
lines changed

11 files changed

+98
-25
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2020-12-09
2+
- 2.26.0
3+
- [OPTIMIZATION] Adjust packet reordering threshold when spurious losses
4+
are detected.
5+
- [API] Pass pointer to local sockaddr to ea_get_ssl_ctx() callback.
6+
17
2020-12-04
28
- 2.25.0
39
- [API, FEATURE] Add es_delay_onclose option to delay on_close until all

bin/prog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
static int prog_stopped;
4141

42-
static SSL_CTX * get_ssl_ctx (void *);
42+
static SSL_CTX * get_ssl_ctx (void *, const struct sockaddr *);
4343

4444
static const struct lsquic_packout_mem_if pmi = {
4545
.pmi_allocate = pba_allocate,
@@ -417,7 +417,7 @@ prog_init_client (struct prog *prog)
417417

418418

419419
static SSL_CTX *
420-
get_ssl_ctx (void *peer_ctx)
420+
get_ssl_ctx (void *peer_ctx, const struct sockaddr *unused)
421421
{
422422
const struct service_port *const sport = peer_ctx;
423423
return sport->sp_prog->prog_ssl_ctx;

docs/apiref.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ optional members.
257257

258258
Look up certificate. Mandatory in server mode.
259259

260-
.. member:: struct ssl_ctx_st * (*ea_get_ssl_ctx)(void *peer_ctx)
260+
.. member:: struct ssl_ctx_st * (*ea_get_ssl_ctx)(void *peer_ctx, const struct sockaddr *local)
261261

262262
Get SSL_CTX associated with a peer context. Mandatory in server
263-
mode. This is use for default values for SSL instantiation.
263+
mode. This is used for default values for SSL instantiation.
264264

265265
.. member:: const struct lsquic_hset_if *ea_hsi_if
266266
.. member:: void *ea_hsi_ctx

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
author = u'LiteSpeed Technologies'
2525

2626
# The short X.Y version
27-
version = u'2.25'
27+
version = u'2.26'
2828
# The full version, including alpha/beta/rc tags
29-
release = u'2.25.0'
29+
release = u'2.26.0'
3030

3131

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

docs/tutorial.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,8 @@ The server requires SSL callbacks to be present. The basic required callback is
863863
struct lsquic_engine_api {
864864
lsquic_lookup_cert_f ea_lookup_cert;
865865
void *ea_cert_lu_ctx;
866-
struct ssl_ctx_st * (*ea_get_ssl_ctx)(void *peer_ctx);
866+
struct ssl_ctx_st * (*ea_get_ssl_ctx)(void *peer_ctx,
867+
const struct sockaddr *local);
867868
/* (Other members of the struct are not shown) */
868869
};
869870

include/lsquic.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extern "C" {
2424
#endif
2525

2626
#define LSQUIC_MAJOR_VERSION 2
27-
#define LSQUIC_MINOR_VERSION 25
27+
#define LSQUIC_MINOR_VERSION 26
2828
#define LSQUIC_PATCH_VERSION 0
2929

3030
/**
@@ -1274,7 +1274,8 @@ struct lsquic_engine_api
12741274
lsquic_lookup_cert_f ea_lookup_cert;
12751275
void *ea_cert_lu_ctx;
12761276
/** Mandatory callback for server, optional for client. */
1277-
struct ssl_ctx_st * (*ea_get_ssl_ctx)(void *peer_ctx);
1277+
struct ssl_ctx_st * (*ea_get_ssl_ctx)(void *peer_ctx,
1278+
const struct sockaddr *local);
12781279
/**
12791280
* Shared hash interface is optional. If set to zero, performance of
12801281
* multiple LSQUIC instances will be degraded.

src/liblsquic/lsquic_enc_sess_ietf.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -888,11 +888,20 @@ iquic_esfi_create_client (const char *hostname,
888888
enc_sess->esi_alpn = am->alpn;
889889
}
890890

891-
if (enc_sess->esi_enpub->enp_get_ssl_ctx
892-
&& (ssl_ctx = enc_sess->esi_enpub->enp_get_ssl_ctx(peer_ctx)))
893-
set_app_ctx = 1;
891+
if (enc_sess->esi_enpub->enp_get_ssl_ctx)
892+
{
893+
struct network_path *const path =
894+
enc_sess->esi_conn->cn_if->ci_get_path(enc_sess->esi_conn, NULL);
895+
ssl_ctx = enc_sess->esi_enpub->enp_get_ssl_ctx(peer_ctx,
896+
NP_LOCAL_SA(path));
897+
if (ssl_ctx)
898+
set_app_ctx = 1;
899+
else
900+
goto create_new_ssl_ctx;
901+
}
894902
else
895903
{
904+
create_new_ssl_ctx:
896905
LSQ_DEBUG("Create new SSL_CTX");
897906
ssl_ctx = SSL_CTX_new(TLS_method());
898907
if (!ssl_ctx)
@@ -1363,6 +1372,7 @@ static int
13631372
iquic_esfi_init_server (enc_session_t *enc_session_p)
13641373
{
13651374
struct enc_sess_iquic *const enc_sess = enc_session_p;
1375+
struct network_path *path;
13661376
const struct alpn_map *am;
13671377
unsigned quic_ctx_idx;
13681378
int transpa_len;
@@ -1390,8 +1400,9 @@ iquic_esfi_init_server (enc_session_t *enc_session_p)
13901400
ok: enc_sess->esi_alpn = am->alpn;
13911401
}
13921402

1393-
ssl_ctx = enc_sess->esi_enpub->enp_get_ssl_ctx(
1394-
lsquic_conn_get_peer_ctx(enc_sess->esi_conn, NULL));
1403+
path = enc_sess->esi_conn->cn_if->ci_get_path(enc_sess->esi_conn, NULL);
1404+
ssl_ctx = enc_sess->esi_enpub->enp_get_ssl_ctx(path->np_peer_ctx,
1405+
NP_LOCAL_SA(path));
13951406
if (!ssl_ctx)
13961407
{
13971408
LSQ_ERROR("fetching SSL context associated with peer context failed");

src/liblsquic/lsquic_engine_public.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct ssl_ctx_st;
2020
struct crand;
2121
struct evp_aead_ctx_st;
2222
struct lsquic_server_config;
23+
struct sockaddr;
2324

2425
enum warning_type
2526
{
@@ -37,7 +38,8 @@ struct lsquic_engine_public {
3738
struct token_generator *enp_tokgen;
3839
lsquic_lookup_cert_f enp_lookup_cert;
3940
void *enp_cert_lu_ctx;
40-
struct ssl_ctx_st * (*enp_get_ssl_ctx)(void *peer_ctx);
41+
struct ssl_ctx_st * (*enp_get_ssl_ctx)(void *peer_ctx,
42+
const struct sockaddr *);
4143
const struct lsquic_shared_hash_if
4244
*enp_shi;
4345
void *enp_shi_ctx;

src/liblsquic/lsquic_packet_out.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ typedef struct lsquic_packet_out
166166
POL_HEADER_PROT = 1 << 9, /* Header protection applied */
167167
#endif
168168
POL_LIMITED = 1 << 10, /* Used to credit sc_next_limit if needed. */
169+
POL_FACKED = 1 << 11, /* Lost due to FACK check */
169170
} po_lflags:16;
170171
unsigned char *po_data;
171172

src/liblsquic/lsquic_send_ctl.c

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,13 @@ lsquic_send_ctl_init (lsquic_send_ctl_t *ctl, struct lsquic_alarmset *alset,
417417
ctl->sc_can_send = send_ctl_can_send_pre_hsk;
418418
else
419419
ctl->sc_can_send = send_ctl_can_send;
420+
ctl->sc_reord_thresh = N_NACKS_BEFORE_RETX;
421+
#if LSQUIC_DEVEL
422+
const char *s;
423+
s = getenv("LSQUIC_DYN_PTHRESH");
424+
if (s == NULL || atoi(s))
425+
ctl->sc_flags |= SC_DYN_PTHRESH;
426+
#endif
420427
}
421428

422429

@@ -884,7 +891,7 @@ send_ctl_destroy_chain (struct lsquic_send_ctl *ctl,
884891
}
885892

886893

887-
static void
894+
static struct lsquic_packet_out *
888895
send_ctl_record_loss (struct lsquic_send_ctl *ctl,
889896
struct lsquic_packet_out *packet_out)
890897
{
@@ -909,16 +916,21 @@ send_ctl_record_loss (struct lsquic_send_ctl *ctl,
909916
* remove from the list:
910917
*/
911918
TAILQ_INSERT_BEFORE(packet_out, loss_record, po_next);
919+
return loss_record;
912920
}
913921
else
922+
{
914923
LSQ_INFO("cannot allocate memory for loss record");
924+
return NULL;
925+
}
915926
}
916927

917928

918-
static int
929+
static struct lsquic_packet_out *
919930
send_ctl_handle_regular_lost_packet (struct lsquic_send_ctl *ctl,
920931
lsquic_packet_out_t *packet_out, struct lsquic_packet_out **next)
921932
{
933+
struct lsquic_packet_out *loss_record;
922934
unsigned packet_sz;
923935

924936
assert(ctl->sc_n_in_flight_all);
@@ -952,11 +964,11 @@ send_ctl_handle_regular_lost_packet (struct lsquic_send_ctl *ctl,
952964
{
953965
LSQ_DEBUG("lost retransmittable packet %"PRIu64,
954966
packet_out->po_packno);
955-
send_ctl_record_loss(ctl, packet_out);
967+
loss_record = send_ctl_record_loss(ctl, packet_out);
956968
send_ctl_unacked_remove(ctl, packet_out, packet_sz);
957969
TAILQ_INSERT_TAIL(&ctl->sc_lost_packets, packet_out, po_next);
958970
packet_out->po_flags |= PO_LOST;
959-
return 1;
971+
return loss_record;
960972
}
961973
else
962974
{
@@ -965,7 +977,7 @@ send_ctl_handle_regular_lost_packet (struct lsquic_send_ctl *ctl,
965977
send_ctl_unacked_remove(ctl, packet_out, packet_sz);
966978
send_ctl_destroy_chain(ctl, packet_out, next);
967979
send_ctl_destroy_packet(ctl, packet_out);
968-
return 0;
980+
return NULL;
969981
}
970982
}
971983

@@ -993,7 +1005,7 @@ send_ctl_handle_lost_packet (struct lsquic_send_ctl *ctl,
9931005
struct lsquic_packet_out *packet_out, struct lsquic_packet_out **next)
9941006
{
9951007
if (0 == (packet_out->po_flags & PO_MTU_PROBE))
996-
return send_ctl_handle_regular_lost_packet(ctl, packet_out, next);
1008+
return send_ctl_handle_regular_lost_packet(ctl, packet_out, next) != NULL;
9971009
else
9981010
return send_ctl_handle_lost_mtu_probe(ctl, packet_out);
9991011
}
@@ -1031,7 +1043,7 @@ static int
10311043
send_ctl_detect_losses (struct lsquic_send_ctl *ctl, enum packnum_space pns,
10321044
lsquic_time_t time)
10331045
{
1034-
lsquic_packet_out_t *packet_out, *next;
1046+
struct lsquic_packet_out *packet_out, *next, *loss_record;
10351047
lsquic_packno_t largest_retx_packno, largest_lost_packno;
10361048

10371049
largest_retx_packno = largest_retx_packet_number(ctl, pns);
@@ -1047,14 +1059,22 @@ send_ctl_detect_losses (struct lsquic_send_ctl *ctl, enum packnum_space pns,
10471059
if (packet_out->po_flags & (PO_LOSS_REC|PO_POISON))
10481060
continue;
10491061

1050-
if (packet_out->po_packno + N_NACKS_BEFORE_RETX <
1062+
if (packet_out->po_packno + ctl->sc_reord_thresh <
10511063
ctl->sc_largest_acked_packno)
10521064
{
1053-
LSQ_DEBUG("loss by FACK detected, packet %"PRIu64,
1065+
LSQ_DEBUG("loss by FACK detected (dist: %"PRIu64"), packet %"PRIu64,
1066+
ctl->sc_largest_acked_packno - packet_out->po_packno,
10541067
packet_out->po_packno);
10551068
if (0 == (packet_out->po_flags & PO_MTU_PROBE))
1069+
{
10561070
largest_lost_packno = packet_out->po_packno;
1057-
(void) send_ctl_handle_lost_packet(ctl, packet_out, &next);
1071+
loss_record = send_ctl_handle_regular_lost_packet(ctl,
1072+
packet_out, &next);
1073+
if (loss_record)
1074+
loss_record->po_lflags |= POL_FACKED;
1075+
}
1076+
else
1077+
send_ctl_handle_lost_mtu_probe(ctl, packet_out);
10581078
continue;
10591079
}
10601080

@@ -1120,6 +1140,26 @@ send_ctl_mtu_probe_acked (struct lsquic_send_ctl *ctl,
11201140
}
11211141

11221142

1143+
static void
1144+
send_ctl_maybe_increase_reord_thresh (struct lsquic_send_ctl *ctl,
1145+
const struct lsquic_packet_out *loss_record,
1146+
lsquic_packno_t prev_largest_acked)
1147+
{
1148+
#if LSQUIC_DEVEL
1149+
if (ctl->sc_flags & SC_DYN_PTHRESH)
1150+
#endif
1151+
if ((loss_record->po_lflags & POL_FACKED)
1152+
&& loss_record->po_packno + ctl->sc_reord_thresh
1153+
< prev_largest_acked)
1154+
{
1155+
ctl->sc_reord_thresh = prev_largest_acked - loss_record->po_packno;
1156+
LSQ_DEBUG("packet %"PRIu64" was a spurious loss by FACK, increase "
1157+
"reordering threshold to %u", loss_record->po_packno,
1158+
ctl->sc_reord_thresh);
1159+
}
1160+
}
1161+
1162+
11231163
int
11241164
lsquic_send_ctl_got_ack (lsquic_send_ctl_t *ctl,
11251165
const struct ack_info *acki,
@@ -1129,6 +1169,7 @@ lsquic_send_ctl_got_ack (lsquic_send_ctl_t *ctl,
11291169
&acki->ranges[ acki->n_ranges - 1 ];
11301170
lsquic_packet_out_t *packet_out, *next;
11311171
lsquic_packno_t smallest_unacked;
1172+
lsquic_packno_t prev_largest_acked;
11321173
lsquic_packno_t ack2ed[2];
11331174
unsigned packet_sz;
11341175
int app_limited, losses_detected;
@@ -1190,6 +1231,7 @@ lsquic_send_ctl_got_ack (lsquic_send_ctl_t *ctl,
11901231
ctl->sc_cur_rt_end = lsquic_senhist_largest(&ctl->sc_senhist);
11911232
}
11921233

1234+
prev_largest_acked = ctl->sc_largest_acked_packno;
11931235
do_rtt = 0, skip_checks = 0;
11941236
app_limited = -1;
11951237
do
@@ -1234,6 +1276,8 @@ lsquic_send_ctl_got_ack (lsquic_send_ctl_t *ctl,
12341276
po_next);
12351277
LSQ_DEBUG("acking via loss record %"PRIu64,
12361278
packet_out->po_packno);
1279+
send_ctl_maybe_increase_reord_thresh(ctl, packet_out,
1280+
prev_largest_acked);
12371281
#if LSQUIC_CONN_STATS
12381282
++ctl->sc_conn_pub->conn_stats->out.acked_via_loss;
12391283
#endif

0 commit comments

Comments
 (0)