Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Iteration 6 #31

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5872063
deps: update ngtcp2 to latest
jasnell May 20, 2019
e9d8fb4
quic: make alpn configurable + a fix
jasnell May 20, 2019
ff059b1
quic: uncomment out memory tracking
jasnell May 20, 2019
877b6b4
quic: multiple cleanups
jasnell May 20, 2019
065c786
quic: fixes and refactors
jasnell May 21, 2019
d7af6f2
quic: complete keylogging output
jasnell May 22, 2019
dae6d10
quic: fixes and improvements
jasnell May 22, 2019
faa2c12
quic: add back pressure guards
jasnell May 23, 2019
730695f
quic: update documentation
jasnell May 24, 2019
7e21993
quic: fixup ngtcp2 debuglog
jasnell May 26, 2019
cbec727
quic: refactoring error code handling
jasnell May 26, 2019
1e9d670
quic: ongoing iteration
jasnell May 29, 2019
3fc3a6d
quic: add session_stats
jasnell May 29, 2019
2eb7a95
quic: add debug stats output
jasnell May 30, 2019
e1de3a4
quic: expose stats buffer to JS
jasnell May 30, 2019
1bad06d
src: fix variadic templates for IncrementSocketStat
danbev May 30, 2019
8900827
quic: fix SetError compilation error
danbev May 30, 2019
1453942
quic: begin implementing clientHello and cert events
jasnell May 31, 2019
4f86a24
quic: beginning requestCert and rejectUnauthorized
jasnell Jun 3, 2019
51b90f3
quic: adding some implementation notes
jasnell Jun 3, 2019
b6e0e5a
quic: evolving implementation
jasnell Jun 5, 2019
39fea73
quic: complete implementation of OCSPRequest/OCSPResponse
jasnell Jun 5, 2019
c5e7b13
quic: linting fixups
jasnell Jun 5, 2019
8baf2a7
quic: further refinement on OCSPRequest
jasnell Jun 5, 2019
931569e
quic: add misc comment
jasnell Jun 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion deps/ngtcp2/lib/includes/ngtcp2/ngtcp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,13 @@ NGTCP2_EXTERN ngtcp2_tstamp ngtcp2_conn_get_expiry(ngtcp2_conn *conn);
*/
NGTCP2_EXTERN ngtcp2_duration ngtcp2_conn_get_idle_timeout(ngtcp2_conn *conn);

/**
* @function
*
* `ngtcp2_conn_get_pto` returns Probe Timeout (PTO).
*/
NGTCP2_EXTERN ngtcp2_duration ngtcp2_conn_get_pto(ngtcp2_conn *conn);

/**
* @function
*
Expand Down Expand Up @@ -2540,7 +2547,9 @@ NGTCP2_EXTERN const ngtcp2_addr *ngtcp2_conn_get_remote_addr(ngtcp2_conn *conn);
* @function
*
* `ngtcp2_conn_initiate_migration` starts connection migration to the
* given |path|. Only client can initiate migration.
* given |path|. Only client can initiate migration. This function
* does immediate migration; it does not probe peer reachability from
* a new local address.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
Expand Down
105 changes: 37 additions & 68 deletions deps/ngtcp2/lib/ngtcp2_acktr.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,20 @@ void ngtcp2_acktr_entry_del(ngtcp2_acktr_entry *ent, const ngtcp2_mem *mem) {
}

static int greater(const ngtcp2_ksl_key *lhs, const ngtcp2_ksl_key *rhs) {
return lhs->i > rhs->i;
return *lhs->i > *rhs->i;
}

int ngtcp2_acktr_init(ngtcp2_acktr *acktr, ngtcp2_log *log,
const ngtcp2_mem *mem) {
int rv;
ngtcp2_ksl_key inf_key = {-1};

rv = ngtcp2_ringbuf_init(&acktr->acks, 128, sizeof(ngtcp2_acktr_ack_entry),
mem);
if (rv != 0) {
return rv;
}

rv = ngtcp2_ksl_init(&acktr->ents, greater, &inf_key, mem);
rv = ngtcp2_ksl_init(&acktr->ents, greater, sizeof(int64_t), mem);
if (rv != 0) {
ngtcp2_ringbuf_free(&acktr->acks);
return rv;
Expand Down Expand Up @@ -98,9 +97,11 @@ int ngtcp2_acktr_add(ngtcp2_acktr *acktr, int64_t pkt_num, int active_ack,
ngtcp2_acktr_entry *ent, *prev_ent, *delent;
int rv;
int added = 0;
ngtcp2_ksl_key key, old_key;

if (ngtcp2_ksl_len(&acktr->ents)) {
it = ngtcp2_ksl_lower_bound(&acktr->ents, (const ngtcp2_ksl_key *)&pkt_num);
it = ngtcp2_ksl_lower_bound(&acktr->ents,
ngtcp2_ksl_key_ptr(&key, &pkt_num));
if (ngtcp2_ksl_it_end(&it)) {
ngtcp2_ksl_it_prev(&it);
ent = ngtcp2_ksl_it_get(&it);
Expand All @@ -119,8 +120,8 @@ int ngtcp2_acktr_add(ngtcp2_acktr *acktr, int64_t pkt_num, int active_ack,
if (ngtcp2_ksl_it_begin(&it)) {
if (ent->pkt_num + 1 == pkt_num) {
ngtcp2_ksl_update_key(&acktr->ents,
(const ngtcp2_ksl_key *)&ent->pkt_num,
(const ngtcp2_ksl_key *)&pkt_num);
ngtcp2_ksl_key_ptr(&key, &ent->pkt_num),
ngtcp2_ksl_key_ptr(&old_key, &pkt_num));
ent->pkt_num = pkt_num;
ent->tstamp = ts;
++ent->len;
Expand All @@ -135,17 +136,14 @@ int ngtcp2_acktr_add(ngtcp2_acktr *acktr, int64_t pkt_num, int active_ack,
if (ent->pkt_num + 1 == pkt_num) {
if (prev_ent->pkt_num == pkt_num + (int64_t)prev_ent->len) {
prev_ent->len += ent->len + 1;
rv = ngtcp2_ksl_remove(&acktr->ents, NULL,
(const ngtcp2_ksl_key *)&ent->pkt_num);
if (rv != 0) {
return rv;
}
ngtcp2_ksl_remove(&acktr->ents, NULL,
ngtcp2_ksl_key_ptr(&key, &ent->pkt_num));
ngtcp2_acktr_entry_del(ent, acktr->mem);
added = 1;
} else {
ngtcp2_ksl_update_key(&acktr->ents,
(const ngtcp2_ksl_key *)&ent->pkt_num,
(const ngtcp2_ksl_key *)&pkt_num);
ngtcp2_ksl_key_ptr(&key, &ent->pkt_num),
ngtcp2_ksl_key_ptr(&old_key, &pkt_num));
ent->pkt_num = pkt_num;
ent->tstamp = ts;
++ent->len;
Expand All @@ -165,7 +163,7 @@ int ngtcp2_acktr_add(ngtcp2_acktr *acktr, int64_t pkt_num, int active_ack,
return rv;
}
rv = ngtcp2_ksl_insert(&acktr->ents, NULL,
(const ngtcp2_ksl_key *)&ent->pkt_num, ent);
ngtcp2_ksl_key_ptr(&key, &ent->pkt_num), ent);
if (rv != 0) {
ngtcp2_acktr_entry_del(ent, acktr->mem);
return rv;
Expand All @@ -183,36 +181,28 @@ int ngtcp2_acktr_add(ngtcp2_acktr *acktr, int64_t pkt_num, int active_ack,
it = ngtcp2_ksl_end(&acktr->ents);
ngtcp2_ksl_it_prev(&it);
delent = ngtcp2_ksl_it_get(&it);
rv = ngtcp2_ksl_remove(&acktr->ents, NULL,
(const ngtcp2_ksl_key *)&delent->pkt_num);
if (rv != 0) {
return rv;
}
ngtcp2_ksl_remove(&acktr->ents, NULL,
ngtcp2_ksl_key_ptr(&key, &delent->pkt_num));
ngtcp2_acktr_entry_del(delent, acktr->mem);
}

return 0;
}

int ngtcp2_acktr_forget(ngtcp2_acktr *acktr, ngtcp2_acktr_entry *ent) {
void ngtcp2_acktr_forget(ngtcp2_acktr *acktr, ngtcp2_acktr_entry *ent) {
ngtcp2_ksl_it it;
int rv;
ngtcp2_ksl_key key;

it = ngtcp2_ksl_lower_bound(&acktr->ents,
(const ngtcp2_ksl_key *)&ent->pkt_num);
assert(ngtcp2_ksl_it_key(&it).i == (int64_t)ent->pkt_num);
ngtcp2_ksl_key_ptr(&key, &ent->pkt_num));
assert(*ngtcp2_ksl_it_key(&it).i == (int64_t)ent->pkt_num);

for (; !ngtcp2_ksl_it_end(&it);) {
ent = ngtcp2_ksl_it_get(&it);
rv = ngtcp2_ksl_remove(&acktr->ents, &it,
(const ngtcp2_ksl_key *)&ent->pkt_num);
if (rv != 0) {
return rv;
}
ngtcp2_ksl_remove(&acktr->ents, &it,
ngtcp2_ksl_key_ptr(&key, &ent->pkt_num));
ngtcp2_acktr_entry_del(ent, acktr->mem);
}

return 0;
}

ngtcp2_ksl_it ngtcp2_acktr_get(ngtcp2_acktr *acktr) {
Expand All @@ -233,48 +223,32 @@ ngtcp2_acktr_ack_entry *ngtcp2_acktr_add_ack(ngtcp2_acktr *acktr,
/*
* acktr_remove removes |ent| from |acktr|. The iterator which points
* to the entry next to |ent| is assigned to |it|.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* NGTCP2_ERR_NOMEM
* Out of memory.
*/
static int acktr_remove(ngtcp2_acktr *acktr, ngtcp2_ksl_it *it,
ngtcp2_acktr_entry *ent) {
int rv;

rv = ngtcp2_ksl_remove(&acktr->ents, it,
(const ngtcp2_ksl_key *)&ent->pkt_num);
if (rv != 0) {
return rv;
}
static void acktr_remove(ngtcp2_acktr *acktr, ngtcp2_ksl_it *it,
ngtcp2_acktr_entry *ent) {
ngtcp2_ksl_key key;

ngtcp2_ksl_remove(&acktr->ents, it, ngtcp2_ksl_key_ptr(&key, &ent->pkt_num));
ngtcp2_acktr_entry_del(ent, acktr->mem);

return 0;
}

static int acktr_on_ack(ngtcp2_acktr *acktr, ngtcp2_ringbuf *rb,
size_t ack_ent_offset) {
static void acktr_on_ack(ngtcp2_acktr *acktr, ngtcp2_ringbuf *rb,
size_t ack_ent_offset) {
ngtcp2_acktr_ack_entry *ack_ent;
ngtcp2_acktr_entry *ent;
ngtcp2_ksl_it it;
int rv;
ngtcp2_ksl_key key;

assert(ngtcp2_ringbuf_len(rb));

ack_ent = ngtcp2_ringbuf_get(rb, ack_ent_offset);

/* Assume that ngtcp2_pkt_validate_ack(fr) returns 0 */
it = ngtcp2_ksl_lower_bound(&acktr->ents,
(const ngtcp2_ksl_key *)&ack_ent->largest_ack);
ngtcp2_ksl_key_ptr(&key, &ack_ent->largest_ack));
for (; !ngtcp2_ksl_it_end(&it);) {
ent = ngtcp2_ksl_it_get(&it);
rv = acktr_remove(acktr, &it, ent);
if (rv != 0) {
return rv;
}
acktr_remove(acktr, &it, ent);
}

if (ngtcp2_ksl_len(&acktr->ents)) {
Expand All @@ -289,17 +263,14 @@ static int acktr_on_ack(ngtcp2_acktr *acktr, ngtcp2_ringbuf *rb,
}

ngtcp2_ringbuf_resize(rb, ack_ent_offset);

return 0;
}

int ngtcp2_acktr_recv_ack(ngtcp2_acktr *acktr, const ngtcp2_ack *fr) {
void ngtcp2_acktr_recv_ack(ngtcp2_acktr *acktr, const ngtcp2_ack *fr) {
ngtcp2_acktr_ack_entry *ent;
int64_t largest_ack = fr->largest_ack, min_ack;
size_t i, j;
ngtcp2_ringbuf *rb = &acktr->acks;
size_t nacks = ngtcp2_ringbuf_len(rb);
int rv;

/* Assume that ngtcp2_pkt_validate_ack(fr) returns 0 */
for (j = 0; j < nacks; ++j) {
Expand All @@ -309,17 +280,14 @@ int ngtcp2_acktr_recv_ack(ngtcp2_acktr *acktr, const ngtcp2_ack *fr) {
}
}
if (j == nacks) {
return 0;
return;
}

min_ack = largest_ack - (int64_t)fr->first_ack_blklen;

if (min_ack <= ent->pkt_num && ent->pkt_num <= largest_ack) {
rv = acktr_on_ack(acktr, rb, j);
if (rv != 0) {
return rv;
}
return 0;
acktr_on_ack(acktr, rb, j);
return;
}

for (i = 0; i < fr->num_blks && j < nacks; ++i) {
Expand All @@ -330,19 +298,20 @@ int ngtcp2_acktr_recv_ack(ngtcp2_acktr *acktr, const ngtcp2_ack *fr) {
if (ent->pkt_num > largest_ack) {
++j;
if (j == nacks) {
return 0;
return;
}
ent = ngtcp2_ringbuf_get(rb, j);
continue;
}
if (ent->pkt_num < min_ack) {
break;
}
return acktr_on_ack(acktr, rb, j);
acktr_on_ack(acktr, rb, j);
return;
}
}

return 0;
return;
}

void ngtcp2_acktr_commit_ack(ngtcp2_acktr *acktr) {
Expand Down
18 changes: 2 additions & 16 deletions deps/ngtcp2/lib/ngtcp2_acktr.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,8 @@ int ngtcp2_acktr_add(ngtcp2_acktr *acktr, int64_t pkt_num, int active_ack,
* ngtcp2_acktr_forget removes all entries which have the packet
* number that is equal to or less than ent->pkt_num. This function
* assumes that |acktr| includes |ent|.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* NGTCP2_ERR_NOMEM
* Out of memory.
*/
int ngtcp2_acktr_forget(ngtcp2_acktr *acktr, ngtcp2_acktr_entry *ent);
void ngtcp2_acktr_forget(ngtcp2_acktr *acktr, ngtcp2_acktr_entry *ent);

/*
* ngtcp2_acktr_get returns the pointer to pointer to the entry which
Expand All @@ -196,16 +190,8 @@ ngtcp2_acktr_add_ack(ngtcp2_acktr *acktr, int64_t pkt_num, int64_t largest_ack);
* |pkt_num| is a packet number which includes |fr|. If we receive
* ACK which acknowledges the ACKs added by ngtcp2_acktr_add_ack,
* ngtcp2_acktr_entry which the outgoing ACK acknowledges is removed.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* NGTCP2_ERR_CALLBACK_FAILURE
* User-defined callback function failed.
* NGTCP2_ERR_NOMEM
* Out of memory.
*/
int ngtcp2_acktr_recv_ack(ngtcp2_acktr *acktr, const ngtcp2_ack *fr);
void ngtcp2_acktr_recv_ack(ngtcp2_acktr *acktr, const ngtcp2_ack *fr);

/*
* ngtcp2_acktr_commit_ack tells |acktr| that ACK frame is generated.
Expand Down
2 changes: 2 additions & 0 deletions deps/ngtcp2/lib/ngtcp2_cid.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ void ngtcp2_dcid_init(ngtcp2_dcid *dcid, uint64_t seq, const ngtcp2_cid *cid,
memset(dcid->token, 0, NGTCP2_STATELESS_RESET_TOKENLEN);
}
ngtcp2_path_storage_zero(&dcid->ps);
dcid->ts_retired = UINT64_MAX;
}

void ngtcp2_dcid_copy(ngtcp2_dcid *dest, const ngtcp2_dcid *src) {
ngtcp2_dcid_init(dest, src->seq, &src->cid, src->token);
ngtcp2_path_copy(&dest->ps.path, &src->ps.path);
dest->ts_retired = src->ts_retired;
}

int ngtcp2_dcid_verify_uniqueness(ngtcp2_dcid *dcid, uint64_t seq,
Expand Down
3 changes: 3 additions & 0 deletions deps/ngtcp2/lib/ngtcp2_cid.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ typedef struct {
/* path is a path which cid is bound to. The addresses are zero
length if cid has not been bound to a particular path yet. */
ngtcp2_path_storage ps;
/* ts_retired is the timestamp when peer tells that this CID is
retired. */
ngtcp2_tstamp ts_retired;
/* token is a stateless reset token associated to this CID.
Actually, the stateless reset token is tied to the connection,
not to the particular connection ID. */
Expand Down
Loading