Skip to content

Commit

Permalink
Release 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gwanglst committed Dec 16, 2024
1 parent b0bd690 commit d3582f3
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 65 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2024-12-16
- 4.1.0
- Update to ls-qpack v2.6.0 to fix a infinite loop.
- Add lsquic_engine_get_conns_count() API
- Updated ea_generate_scid() API
- Fix retry packet SCID generation to follow engine API.
- Fix QUICv2 header protection key when retry packet is involved.

2024-09-23
- 4.0.12
- Fix stream WANT_WRITE flag that causes busy looping.
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
author = u'LiteSpeed Technologies'

# The short X.Y version
version = u'4.0'
version = u'4.1'
# The full version, including alpha/beta/rc tags
release = u'4.0.12'
release = u'4.1.0'


# -- General configuration ---------------------------------------------------
Expand Down
20 changes: 10 additions & 10 deletions include/lsquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ extern "C" {
#endif

#define LSQUIC_MAJOR_VERSION 4
#define LSQUIC_MINOR_VERSION 0
#define LSQUIC_PATCH_VERSION 12
#define LSQUIC_MINOR_VERSION 1
#define LSQUIC_PATCH_VERSION 0

/**
* Engine flags:
Expand Down Expand Up @@ -1377,11 +1377,17 @@ struct lsquic_engine_api
* Optional interface to control the creation of connection IDs
*/
void (*ea_generate_scid)(void *ctx,
lsquic_conn_t *, lsquic_cid_t *, unsigned);
lsquic_conn_t *, uint8_t *, unsigned);
/** Passed to ea_generate_scid() */
void *ea_gen_scid_ctx;
};

/**
* Returns current number of connections processed by the engine. Both mini and full connections included
*/
unsigned
lsquic_engine_get_conns_count (lsquic_engine_t *engine);

/**
* Create new engine.
*
Expand Down Expand Up @@ -1438,12 +1444,6 @@ lsquic_engine_packet_in (lsquic_engine_t *,
const struct sockaddr *sa_local, const struct sockaddr *sa_peer,
void *peer_ctx, int ecn);

/**
* Returns current number of connections processed by the engine. Both mini and full connections included
*/
unsigned
lsquic_engine_get_conns_count (lsquic_engine_t *engine);

/**
* Process tickable connections. This function must be called often enough so
* that packets and connections do not expire.
Expand Down Expand Up @@ -2085,7 +2085,7 @@ lsquic_cid_from_packet (const unsigned char *, size_t bufsz, lsquic_cid_t *cid);
*/
int
lsquic_dcid_from_packet (const unsigned char *, size_t bufsz,
unsigned server_cid_len, unsigned *cid_len);
unsigned server_cid_len, uint8_t *cid_len);

/**
* Returns true if there are connections to be processed, false otherwise.
Expand Down
2 changes: 1 addition & 1 deletion src/liblsquic/ls-qpack
Submodule ls-qpack updated 3 files
+1 −1 lsqpack.c
+14 −6 lsqpack.h
+4 −4 lsxpack_header.h
9 changes: 4 additions & 5 deletions src/liblsquic/lsquic_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,20 +239,19 @@ lsquic_generate_cid (lsquic_cid_t *cid, size_t len)


void
lsquic_generate_scid (void *ctx, struct lsquic_conn *lconn, lsquic_cid_t *scid,
lsquic_generate_scid (void *ctx, struct lsquic_conn *lconn, uint8_t *cid,
unsigned len)
{
if (len)
lsquic_generate_cid(scid, len);
else
scid->len = len;
RAND_bytes(cid, len);
}


void
lsquic_generate_cid_gquic (lsquic_cid_t *cid)
{
lsquic_generate_cid(cid, GQUIC_CID_LEN);
RAND_bytes(cid->idbuf, GQUIC_CID_LEN);
cid->len = GQUIC_CID_LEN;
}


Expand Down
2 changes: 1 addition & 1 deletion src/liblsquic/lsquic_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ void
lsquic_generate_cid_gquic (lsquic_cid_t *cid);

void
lsquic_generate_scid (void *, struct lsquic_conn *lconn, lsquic_cid_t *scid,
lsquic_generate_scid (void *, struct lsquic_conn *lconn, uint8_t *scid,
unsigned len);

void
Expand Down
15 changes: 12 additions & 3 deletions src/liblsquic/lsquic_enc_sess_ietf.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,10 @@ gen_trans_params (struct enc_sess_iquic *enc_sess, unsigned char *buf,
cce->cce_seqno = seqno + 1;
cce->cce_flags = CCE_SEQNO;

cce->cce_cid.len = enc_sess->esi_enpub->enp_settings.es_scid_len;
enc_sess->esi_enpub->enp_generate_scid(
enc_sess->esi_enpub->enp_gen_scid_ctx, enc_sess->esi_conn,
&cce->cce_cid, enc_sess->esi_enpub->enp_settings.es_scid_len);
cce->cce_cid.buf, cce->cce_cid.len);

/* Don't add to hash: migration must not start until *after*
* handshake is complete.
Expand Down Expand Up @@ -1181,6 +1182,8 @@ setup_handshake_keys (struct enc_sess_iquic *enc_sess, const lsquic_cid_t *cid)
char hexbuf[EVP_MAX_MD_SIZE * 2 + 1];
struct label_set *labels;

LSQ_INFOC("setup_handshake_keys for DCID %"CID_FMT, CID_BITS(cid));

if (!enc_sess->esi_hsk_crypto)
{
enc_sess->esi_hsk_crypto = calloc(N_HSK_PAIRS,
Expand Down Expand Up @@ -2746,8 +2749,14 @@ iquic_esfi_switch_version (enc_session_t *enc_session_p, lsquic_cid_t *dcid,
else
memset(&enc_sess->esi_hsk_crypto[ENC_LEV_INIT], 0,
sizeof(enc_sess->esi_hsk_crypto[ENC_LEV_INIT]));

if (0 == setup_handshake_keys(enc_sess, dcid ? dcid : &enc_sess->esi_odcid))
if (!dcid)
{
if (enc_sess->esi_flags & ESI_RETRY)
dcid = &enc_sess->esi_rscid;
else
dcid = &enc_sess->esi_odcid;
}
if (0 == setup_handshake_keys(enc_sess, dcid))
{
LSQ_INFO("update handshake keys to version %s",
lsquic_ver2str[enc_sess->esi_conn->cn_version]);
Expand Down
2 changes: 2 additions & 0 deletions src/liblsquic/lsquic_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -2213,12 +2213,14 @@ drop_all_mini_conns (lsquic_engine_t *engine)
cub_flush(&cub);
}


unsigned
lsquic_engine_get_conns_count (lsquic_engine_t *engine)
{
return engine->n_conns;
}


void
lsquic_engine_process_conns (lsquic_engine_t *engine)
{
Expand Down
2 changes: 1 addition & 1 deletion src/liblsquic/lsquic_engine_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct lsquic_engine_public {
const struct lsquic_hset_if *enp_hsi_if;
void *enp_hsi_ctx;
void (*enp_generate_scid)(void *,
struct lsquic_conn *, struct lsquic_cid *, unsigned);
struct lsquic_conn *, uint8_t *, unsigned);
void *enp_gen_scid_ctx;
int (*enp_verify_cert)(void *verify_ctx,
struct stack_st_X509 *chain);
Expand Down
9 changes: 6 additions & 3 deletions src/liblsquic/lsquic_full_conn_ietf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,8 +1196,11 @@ ietf_full_conn_add_scid (struct ietf_full_conn *conn,
}

if (enpub->enp_settings.es_scid_len)
enpub->enp_generate_scid(enpub->enp_gen_scid_ctx, lconn, &cce->cce_cid,
enpub->enp_settings.es_scid_len);
{
cce->cce_cid.len = enpub->enp_settings.es_scid_len;
enpub->enp_generate_scid(enpub->enp_gen_scid_ctx, lconn,
cce->cce_cid.buf, cce->cce_cid.len);
}

cce->cce_seqno = conn->ifc_scid_seqno++;
cce->cce_flags |= CCE_SEQNO | flags;
Expand Down Expand Up @@ -7254,6 +7257,7 @@ process_retry_packet (struct ietf_full_conn *conn,
LSQ_DEBUG("cannot verify retry packet: ignore it");
return 0;
}
LSQ_INFO("Received a retry packet. Will retry.");

if (0 != lsquic_send_ctl_retry(&conn->ifc_send_ctl,
packet_in->pi_data + packet_in->pi_token,
Expand All @@ -7272,7 +7276,6 @@ process_retry_packet (struct ietf_full_conn *conn,
lsquic_alarmset_unset(&conn->ifc_alset, AL_RETX_HSK);
lsquic_alarmset_unset(&conn->ifc_alset, AL_RETX_APP);

LSQ_INFO("Received a retry packet. Will retry.");
conn->ifc_flags |= IFC_RETRIED;
return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions src/liblsquic/lsquic_mini_conn_ietf.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,14 +581,15 @@ lsquic_mini_conn_ietf_new (struct lsquic_engine_public *enpub,
conn->imc_conn.cn_n_cces = sizeof(conn->imc_cces)
/ sizeof(conn->imc_cces[0]);
conn->imc_cces[0].cce_cid = packet_in->pi_dcid;
conn->imc_cces[0].cce_flags = CCE_USED;
conn->imc_cces[0].cce_flags = CCE_USED | CCE_REG;
conn->imc_conn.cn_cces_mask = 1;
lsquic_scid_from_packet_in(packet_in, &conn->imc_path.np_dcid);
/* Generate new SCID. Since is not the original SCID, it is given
* a sequence number (0) and therefore can be retired by the client.
*/
conn->imc_conn.cn_cces[1].cce_cid.len = enpub->enp_settings.es_scid_len;
enpub->enp_generate_scid(enpub->enp_gen_scid_ctx, &conn->imc_conn,
&conn->imc_conn.cn_cces[1].cce_cid, enpub->enp_settings.es_scid_len);
conn->imc_conn.cn_cces[1].cce_cid.buf, enpub->enp_settings.es_scid_len);

if (conn->imc_path.np_dcid.len)
conn->imc_conn.cn_logid = conn->imc_path.np_dcid;
Expand Down
31 changes: 31 additions & 0 deletions src/liblsquic/lsquic_packet_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,37 @@
#include "lsquic_packet_common.h"


const char * const frame_type_2_str[N_QUIC_FRAMES] = {
[QUIC_FRAME_INVALID] = "QUIC_FRAME_INVALID",
[QUIC_FRAME_STREAM] = "QUIC_FRAME_STREAM",
[QUIC_FRAME_ACK] = "QUIC_FRAME_ACK",
[QUIC_FRAME_PADDING] = "QUIC_FRAME_PADDING",
[QUIC_FRAME_RST_STREAM] = "QUIC_FRAME_RST_STREAM",
[QUIC_FRAME_CONNECTION_CLOSE] = "QUIC_FRAME_CONNECTION_CLOSE",
[QUIC_FRAME_GOAWAY] = "QUIC_FRAME_GOAWAY",
[QUIC_FRAME_WINDOW_UPDATE] = "QUIC_FRAME_WINDOW_UPDATE",
[QUIC_FRAME_BLOCKED] = "QUIC_FRAME_BLOCKED",
[QUIC_FRAME_STOP_WAITING] = "QUIC_FRAME_STOP_WAITING",
[QUIC_FRAME_PING] = "QUIC_FRAME_PING",
[QUIC_FRAME_MAX_DATA] = "QUIC_FRAME_MAX_DATA",
[QUIC_FRAME_MAX_STREAM_DATA] = "QUIC_FRAME_MAX_STREAM_DATA",
[QUIC_FRAME_MAX_STREAMS] = "QUIC_FRAME_MAX_STREAMS",
[QUIC_FRAME_STREAM_BLOCKED] = "QUIC_FRAME_STREAM_BLOCKED",
[QUIC_FRAME_STREAMS_BLOCKED] = "QUIC_FRAME_STREAMS_BLOCKED",
[QUIC_FRAME_NEW_CONNECTION_ID] = "QUIC_FRAME_NEW_CONNECTION_ID",
[QUIC_FRAME_STOP_SENDING] = "QUIC_FRAME_STOP_SENDING",
[QUIC_FRAME_PATH_CHALLENGE] = "QUIC_FRAME_PATH_CHALLENGE",
[QUIC_FRAME_PATH_RESPONSE] = "QUIC_FRAME_PATH_RESPONSE",
[QUIC_FRAME_CRYPTO] = "QUIC_FRAME_CRYPTO",
[QUIC_FRAME_NEW_TOKEN] = "QUIC_FRAME_NEW_TOKEN",
[QUIC_FRAME_RETIRE_CONNECTION_ID] = "QUIC_FRAME_RETIRE_CONNECTION_ID",
[QUIC_FRAME_HANDSHAKE_DONE] = "QUIC_FRAME_HANDSHAKE_DONE",
[QUIC_FRAME_ACK_FREQUENCY] = "QUIC_FRAME_ACK_FREQUENCY",
[QUIC_FRAME_TIMESTAMP] = "QUIC_FRAME_TIMESTAMP",
[QUIC_FRAME_DATAGRAM] = "QUIC_FRAME_DATAGRAM",
};


const char *
lsquic_frame_types_to_str (char *buf, size_t bufsz,
enum quic_ft_bit frame_types)
Expand Down
30 changes: 1 addition & 29 deletions src/liblsquic/lsquic_packet_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,35 +70,7 @@ enum quic_ft_bit {
QUIC_FTBIT_DATAGRAM = 1 << QUIC_FRAME_DATAGRAM,
};

static const char * const frame_type_2_str[N_QUIC_FRAMES] = {
[QUIC_FRAME_INVALID] = "QUIC_FRAME_INVALID",
[QUIC_FRAME_STREAM] = "QUIC_FRAME_STREAM",
[QUIC_FRAME_ACK] = "QUIC_FRAME_ACK",
[QUIC_FRAME_PADDING] = "QUIC_FRAME_PADDING",
[QUIC_FRAME_RST_STREAM] = "QUIC_FRAME_RST_STREAM",
[QUIC_FRAME_CONNECTION_CLOSE] = "QUIC_FRAME_CONNECTION_CLOSE",
[QUIC_FRAME_GOAWAY] = "QUIC_FRAME_GOAWAY",
[QUIC_FRAME_WINDOW_UPDATE] = "QUIC_FRAME_WINDOW_UPDATE",
[QUIC_FRAME_BLOCKED] = "QUIC_FRAME_BLOCKED",
[QUIC_FRAME_STOP_WAITING] = "QUIC_FRAME_STOP_WAITING",
[QUIC_FRAME_PING] = "QUIC_FRAME_PING",
[QUIC_FRAME_MAX_DATA] = "QUIC_FRAME_MAX_DATA",
[QUIC_FRAME_MAX_STREAM_DATA] = "QUIC_FRAME_MAX_STREAM_DATA",
[QUIC_FRAME_MAX_STREAMS] = "QUIC_FRAME_MAX_STREAMS",
[QUIC_FRAME_STREAM_BLOCKED] = "QUIC_FRAME_STREAM_BLOCKED",
[QUIC_FRAME_STREAMS_BLOCKED] = "QUIC_FRAME_STREAMS_BLOCKED",
[QUIC_FRAME_NEW_CONNECTION_ID] = "QUIC_FRAME_NEW_CONNECTION_ID",
[QUIC_FRAME_STOP_SENDING] = "QUIC_FRAME_STOP_SENDING",
[QUIC_FRAME_PATH_CHALLENGE] = "QUIC_FRAME_PATH_CHALLENGE",
[QUIC_FRAME_PATH_RESPONSE] = "QUIC_FRAME_PATH_RESPONSE",
[QUIC_FRAME_CRYPTO] = "QUIC_FRAME_CRYPTO",
[QUIC_FRAME_NEW_TOKEN] = "QUIC_FRAME_NEW_TOKEN",
[QUIC_FRAME_RETIRE_CONNECTION_ID] = "QUIC_FRAME_RETIRE_CONNECTION_ID",
[QUIC_FRAME_HANDSHAKE_DONE] = "QUIC_FRAME_HANDSHAKE_DONE",
[QUIC_FRAME_ACK_FREQUENCY] = "QUIC_FRAME_ACK_FREQUENCY",
[QUIC_FRAME_TIMESTAMP] = "QUIC_FRAME_TIMESTAMP",
[QUIC_FRAME_DATAGRAM] = "QUIC_FRAME_DATAGRAM",
};
extern const char * const frame_type_2_str[N_QUIC_FRAMES];

#define QUIC_FRAME_PRELEN (sizeof("QUIC_FRAME_"))
#define QUIC_FRAME_SLEN(x) (sizeof(#x) - QUIC_FRAME_PRELEN)
Expand Down
2 changes: 1 addition & 1 deletion src/liblsquic/lsquic_parse_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ lsquic_cid_from_packet (const unsigned char *buf, size_t bufsz,

int
lsquic_dcid_from_packet (const unsigned char *buf, size_t bufsz,
unsigned server_cid_len, unsigned *cid_len)
unsigned server_cid_len, uint8_t *cid_len)
{
const unsigned char *p;
unsigned dcil, scil;
Expand Down
2 changes: 1 addition & 1 deletion src/liblsquic/lsquic_parse_iquic_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ lsquic_iquic_gen_retry_pkt (unsigned char *buf, size_t bufsz,
memcpy(p, scid->idbuf, scid->len);
p += scid->len;
*p++ = our_scid_len;
RAND_bytes(p, our_scid_len);
enpub->enp_generate_scid(enpub->enp_gen_scid_ctx, NULL, p, our_scid_len);
p += our_scid_len;
sz = lsquic_tg_generate_retry(tokgen, p, end - p,
p - our_scid_len, our_scid_len, sockaddr, dcid);
Expand Down
43 changes: 37 additions & 6 deletions src/liblsquic/lsquic_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,45 @@ lsquic_tag2ver_fast (const unsigned char *tag)
{
unsigned char ch;
ch = *tag;
if (ch == 'Q' && *(tag + 1) == '0')
if (ch == '\0' && *(tag + 1) == 0 && *(tag + 2) == 0)
{
if (*(tag + 2) == '5' && *(tag + 3) == '0')
return LSQVER_050;
else if (*(tag + 2) == '4' && *(tag + 3) == '6')
return LSQVER_046;
if (*(tag + 3) == 0x01)
return LSQVER_I001;
else if (*(tag + 3) == 0x00)
return LSQVER_VERNEG;
}
else if (ch == 0xff && *(tag + 1) == 0 && *(tag + 2) == 0)
{
if (*(tag + 3) == 0x1D)
return LSQVER_ID29;
else if (*(tag + 3) == 0x1B)
return LSQVER_ID27;
}
else if (ch == 0x6b && *(tag + 1) == 0x33
&& *(tag + 2) == 0x43 && *(tag + 3) == 0xcf)
{
return LSQVER_I002;
}
else if (ch == '\0' && *(tag + 1) == 0 && *(tag + 2) == 0)
else if (ch == 'Q' && *(tag + 1) == '0')
{
if (*(tag + 2) == '5' && *(tag + 3) == '0')
return LSQVER_050;
else if (*(tag + 2) == '4' && *(tag + 3) == '6')
return LSQVER_046;
}
else if ((ch & 0xf) == 0xa && (*(tag + 1) & 0xf) == 0xa
&& (*(tag + 2) & 0xf) == 0xa && (*(tag + 3) & 0xf) == 0xa)
return LSQVER_RESVED;
return N_LSQVER;
}


enum lsquic_version
lsquic_tag2ver_ietf (const unsigned char *tag)
{
unsigned char ch;
ch = *tag;
if (ch == '\0' && *(tag + 1) == 0 && *(tag + 2) == 0)
{
if (*(tag + 3) == 0x01)
return LSQVER_I001;
Expand All @@ -79,6 +105,11 @@ lsquic_tag2ver_fast (const unsigned char *tag)
else if (*(tag + 3) == 0x1B)
return LSQVER_ID27;
}
else if (ch == 0x6b && *(tag + 1) == 0x33
&& *(tag + 2) == 0x43 && *(tag + 3) == 0xcf)
{
return LSQVER_I002;
}
else if ((ch & 0xf) == 0xa && (*(tag + 1) & 0xf) == 0xa
&& (*(tag + 2) & 0xf) == 0xa && (*(tag + 3) & 0xf) == 0xa)
return LSQVER_RESVED;
Expand Down
3 changes: 3 additions & 0 deletions src/liblsquic/lsquic_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ lsquic_ver2tag (unsigned version);
enum lsquic_version
lsquic_tag2ver (uint32_t ver_tag);

enum lsquic_version
lsquic_tag2ver_ietf (const unsigned char *tag);

enum lsquic_version
lsquic_tag2ver_fast (const unsigned char * tag);

Expand Down

0 comments on commit d3582f3

Please sign in to comment.