Release 2.21.0

- [FEATURE] QUIC and HTTP/3 Internet Draft 31 support.
- [API] Let user generate Souce Connection IDs.
- [FEATURE] Allow building lsquic as shared library.
- [OPTIMIZATION] Receive history: use a single contiguous memory
  block for everything.
- Deprecate QUIC versions ID-27 and ID-30.
This commit is contained in:
Dmitri Tikhonov 2020-09-29 08:56:43 -04:00
parent 2e1429b465
commit b62ec17fd2
33 changed files with 653 additions and 426 deletions

View file

@ -54,7 +54,6 @@ SET(TESTS
purga
qlog
quic_be_floats
rechist
reg_pkt_headergen
rst_stream_gquic_be
rtt
@ -127,3 +126,6 @@ ADD_TEST(malo_nopool test_malo_nopool)
ADD_EXECUTABLE(test_minmax test_minmax.c ../src/liblsquic/lsquic_minmax.c)
ADD_TEST(minmax test_minmax)
ADD_EXECUTABLE(test_rechist test_rechist.c ../src/liblsquic/lsquic_rechist.c)
ADD_TEST(rechist test_rechist)

View file

@ -30,7 +30,7 @@ test1 (void) /* Inverse of quic_framer_test.cc -- NewAckFrameOneAckBlock */
lsquic_time_t now = lsquic_time_now();
lsquic_packno_t largest = 0;
lsquic_rechist_init(&rechist, 0, 0);
lsquic_rechist_init(&rechist, 0);
unsigned i;
for (i = 1; i <= 0x1234; ++i)
@ -69,7 +69,7 @@ test2 (void) /* Inverse of quic_framer_test.cc -- NewAckFrameOneAckBlock, minus
lsquic_rechist_t rechist;
lsquic_time_t now = lsquic_time_now();
lsquic_rechist_init(&rechist, 0, 0);
lsquic_rechist_init(&rechist, 0);
/* Encode the following ranges:
* high low
@ -128,7 +128,7 @@ test3 (void)
lsquic_rechist_t rechist;
lsquic_time_t now = lsquic_time_now();
lsquic_rechist_init(&rechist, 0, 0);
lsquic_rechist_init(&rechist, 0);
/* Encode the following ranges:
* high low
@ -174,7 +174,7 @@ test4 (void)
lsquic_rechist_t rechist;
int i;
lsquic_rechist_init(&rechist, 0, 0);
lsquic_rechist_init(&rechist, 0);
lsquic_time_t now = lsquic_time_now();
lsquic_rechist_received(&rechist, 1, now);
@ -242,18 +242,17 @@ test_4byte_packnos (void)
{
lsquic_packno_t packno;
lsquic_rechist_t rechist;
struct packet_interval *pint;
lsquic_time_t now = lsquic_time_now();
lsquic_rechist_init(&rechist, 0, 0);
lsquic_rechist_init(&rechist, 0);
packno = 0x23456789;
(void) lsquic_rechist_received(&rechist, packno - 33, now);
pint = TAILQ_FIRST(&rechist.rh_pints.pk_intervals);
(void) lsquic_rechist_received(&rechist, packno, now);
/* Adjust: */
pint->range.low = 1;
rechist.rh_elems[0].re_low = 1;
rechist.rh_elems[0].re_count = packno - 33;
const unsigned char expected_ack_frame[] = {
0x60
@ -288,23 +287,52 @@ test_4byte_packnos (void)
}
/* lsquic_rechist no longer supports ranges that require integers
* wider than four bytes -- modify the test to use a custom receive
* history.
*/
static const struct lsquic_packno_range test_6byte_ranges[] = {
{ .high = 0xABCD23456789, .low = 0xABCD23456789, },
{ .high = 0xABCD23456789 - 33, .low = 1, },
};
static const struct lsquic_packno_range *
test_6byte_rechist_first (void *rechist)
{
int *next = rechist;
*next = 1;
return &test_6byte_ranges[0];
};
static const struct lsquic_packno_range *
test_6byte_rechist_next (void *rechist)
{
int *next = rechist;
if (*next == 1)
{
++*next;
return &test_6byte_ranges[1];
}
else
return NULL;
}
static lsquic_time_t s_test_6byte_now;
static lsquic_time_t
test_6byte_rechist_largest_recv (void *rechist)
{
return s_test_6byte_now;
}
static void
test_6byte_packnos (void)
{
lsquic_packno_t packno;
lsquic_rechist_t rechist;
struct packet_interval *pint;
lsquic_time_t now = lsquic_time_now();
lsquic_rechist_init(&rechist, 0, 0);
packno = 0xABCD23456789;
(void) lsquic_rechist_received(&rechist, packno - 33, now);
pint = TAILQ_FIRST(&rechist.rh_pints.pk_intervals);
(void) lsquic_rechist_received(&rechist, packno, now);
/* Adjust: */
pint->range.low = 1;
int rechist = 0;
s_test_6byte_now = lsquic_time_now();
const unsigned char expected_ack_frame[] = {
0x60
@ -324,18 +352,16 @@ test_6byte_packnos (void)
int has_missing = -1;
lsquic_packno_t largest = 0;
int w = pf->pf_gen_ack_frame(outbuf, sizeof(outbuf),
(gaf_rechist_first_f) lsquic_rechist_first,
(gaf_rechist_next_f) lsquic_rechist_next,
(gaf_rechist_largest_recv_f) lsquic_rechist_largest_recv,
&rechist, now, &has_missing, &largest, NULL);
test_6byte_rechist_first,
test_6byte_rechist_next,
test_6byte_rechist_largest_recv,
&rechist, s_test_6byte_now, &has_missing, &largest, NULL);
assert(("ACK frame generation successful", w > 0));
assert(("ACK frame length is correct", w == sizeof(expected_ack_frame)));
assert(("ACK frame contents are as expected",
0 == memcmp(outbuf, expected_ack_frame, sizeof(expected_ack_frame))));
assert(("ACK frame has missing packets", has_missing > 0));
assert(largest == 0xABCD23456789ULL);
lsquic_rechist_cleanup(&rechist);
}

View file

@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/queue.h>
#ifndef WIN32
#include <sys/time.h>
#else
@ -342,7 +343,7 @@ test_max_ack (void)
unsigned char buf[1500];
struct ack_info acki;
lsquic_rechist_init(&rechist, &lconn, 0);
lsquic_rechist_init(&rechist, 0);
now = lsquic_time_now();
for (i = 1; i <= 300; ++i)
@ -395,7 +396,7 @@ test_ack_truncation (void)
struct ack_info acki;
size_t bufsz;
lsquic_rechist_init(&rechist, &lconn, 0);
lsquic_rechist_init(&rechist, 0);
now = lsquic_time_now();
for (i = 1; i <= 300; ++i)

View file

@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/queue.h>
#ifndef WIN32
#include <sys/time.h>
#else
@ -33,7 +34,7 @@ test_max_ack (void)
unsigned char buf[1500];
struct ack_info acki;
lsquic_rechist_init(&rechist, &lconn, 0);
lsquic_rechist_init(&rechist, 0);
now = lsquic_time_now();
for (i = 1; i <= 300; ++i)
@ -86,7 +87,7 @@ test_ack_truncation (void)
struct ack_info acki;
size_t bufsz;
lsquic_rechist_init(&rechist, &lconn, 0);
lsquic_rechist_init(&rechist, 0);
now = lsquic_time_now();
for (i = 1; i <= 300; ++i)

View file

@ -9,18 +9,9 @@
#include "vc_compat.h"
#endif
#include "lsquic_types.h"
#include "lsquic_int_types.h"
#include "lsquic_rechist.h"
#include "lsquic_parse.h"
#include "lsquic_util.h"
#include "lsquic_logger.h"
#include "lsquic.h"
#include "lsquic_hash.h"
#include "lsquic_conn.h"
static struct lsquic_conn lconn = LSCONN_INITIALIZER_CIDLEN(lconn, 0);
static void
@ -30,7 +21,7 @@ test4 (void)
const struct lsquic_packno_range *range;
lsquic_packno_t packno;
lsquic_rechist_init(&rechist, &lconn, 0);
lsquic_rechist_init(&rechist, 0);
for (packno = 11917; packno <= 11941; ++packno)
lsquic_rechist_received(&rechist, packno, 0);
@ -131,7 +122,7 @@ test5 (void)
lsquic_rechist_t rechist;
char buf[100];
lsquic_rechist_init(&rechist, &lconn, 0);
lsquic_rechist_init(&rechist, 0);
lsquic_rechist_received(&rechist, 1, 0);
/* Packet 2 omitted because it could not be decrypted */
@ -173,6 +164,97 @@ test5 (void)
}
static void
test_rand_sequence (unsigned seed)
{
struct lsquic_rechist rechist;
const struct lsquic_packno_range *range;
lsquic_packno_t prev_low;
enum received_st st;
unsigned i;
lsquic_rechist_init(&rechist, 1);
srand(seed);
for (i = 0; i < 10000; ++i)
{
st = lsquic_rechist_received(&rechist, (unsigned) rand(), 0);
assert(st == REC_ST_OK || st == REC_ST_DUP);
}
range = lsquic_rechist_first(&rechist);
assert(range);
assert(range->high >= range->low);
prev_low = range->low;
while (range = lsquic_rechist_next(&rechist), range != NULL)
{
assert(range->high >= range->low);
assert(range->high < prev_low);
prev_low = range->low;
}
lsquic_rechist_cleanup(&rechist);
}
struct shuffle_elem {
unsigned packno;
int rand;
};
static int
comp_els (const void *a_p, const void *b_p)
{
const struct shuffle_elem *a = a_p, *b = b_p;
if (a->rand < b->rand)
return -1;
if (a->rand > b->rand)
return 1;
return (a->packno > b->packno) - (b->packno > a->packno);
}
static void
test_shuffle_1000 (unsigned seed)
{
struct lsquic_rechist rechist;
const struct lsquic_packno_range *range;
enum received_st st;
unsigned i;
struct shuffle_elem *els;
els = malloc(sizeof(els[0]) * 10000);
lsquic_rechist_init(&rechist, 1);
srand(seed);
for (i = 0; i < 10000; ++i)
{
els[i].packno = i;
els[i].rand = rand();
}
qsort(els, 10000, sizeof(els[0]), comp_els);
for (i = 0; i < 10000; ++i)
{
st = lsquic_rechist_received(&rechist, els[i].packno, 0);
assert(st == REC_ST_OK || st == REC_ST_DUP);
}
range = lsquic_rechist_first(&rechist);
assert(range);
assert(range->high == 9999);
assert(range->low == 0);
range = lsquic_rechist_next(&rechist);
assert(!range);
lsquic_rechist_cleanup(&rechist);
free(els);
}
int
main (void)
{
@ -181,15 +263,9 @@ main (void)
unsigned i;
const struct lsquic_packno_range *range;
lsquic_global_init(LSQUIC_GLOBAL_SERVER);
lsquic_rechist_init(&rechist, 0);
lsquic_log_to_fstream(stderr, 0);
lsq_log_levels[LSQLM_PARSE] = LSQ_LOG_DEBUG;
lsq_log_levels[LSQLM_RECHIST] = LSQ_LOG_DEBUG;
lsquic_rechist_init(&rechist, &lconn, 0);
lsquic_time_t now = lsquic_time_now();
lsquic_time_t now = 1234;
st = lsquic_rechist_received(&rechist, 0, now);
assert(("inserting packet number zero results in error", st == REC_ST_ERR));
@ -254,11 +330,36 @@ main (void)
range = lsquic_rechist_next(&rechist);
assert(("third range does not exist", !range));
lsquic_rechist_stop_wait(&rechist, 5);
range = lsquic_rechist_first(&rechist);
range = lsquic_rechist_next(&rechist);
assert(("second range returned correctly", range));
assert(("second range low value checks out", range->low == 5));
assert(("second range high value checks out", range->high == 5));
range = lsquic_rechist_next(&rechist);
assert(("third range does not exist", !range));
lsquic_rechist_stop_wait(&rechist, 8);
range = lsquic_rechist_first(&rechist);
assert(("first range returned correctly", range));
assert(("first range low value checks out", range->low == 8));
assert(("first range high value checks out", range->high == 9));
range = lsquic_rechist_next(&rechist);
assert(("second range does not exist", !range));
lsquic_rechist_cleanup(&rechist);
test4();
test5();
for (i = 0; i < 10; ++i)
test_rand_sequence(i);
for (i = 0; i < 10; ++i)
test_shuffle_1000(i);
return 0;
}