Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions deps/ngtcp2/ngtcp2.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
'ngtcp2/lib/ngtcp2_objalloc.c',
'ngtcp2/lib/ngtcp2_opl.c',
'ngtcp2/lib/ngtcp2_path.c',
'ngtcp2/lib/ngtcp2_pcg.c',
'ngtcp2/lib/ngtcp2_pkt.c',
'ngtcp2/lib/ngtcp2_pmtud.c',
'ngtcp2/lib/ngtcp2_ppe.c',
'ngtcp2/lib/ngtcp2_pq.c',
'ngtcp2/lib/ngtcp2_pv.c',
'ngtcp2/lib/ngtcp2_qlog.c',
'ngtcp2/lib/ngtcp2_range.c',
'ngtcp2/lib/ngtcp2_ratelim.c',
'ngtcp2/lib/ngtcp2_ringbuf.c',
'ngtcp2/lib/ngtcp2_rob.c',
'ngtcp2/lib/ngtcp2_rst.c',
Expand Down
131 changes: 117 additions & 14 deletions deps/ngtcp2/ngtcp2/lib/includes/ngtcp2/ngtcp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,8 @@ typedef enum ngtcp2_token_type {

#define NGTCP2_SETTINGS_V1 1
#define NGTCP2_SETTINGS_V2 2
#define NGTCP2_SETTINGS_VERSION NGTCP2_SETTINGS_V2
#define NGTCP2_SETTINGS_V3 3
#define NGTCP2_SETTINGS_VERSION NGTCP2_SETTINGS_V3

/**
* @struct
Expand Down Expand Up @@ -1917,6 +1918,23 @@ typedef struct ngtcp2_settings {
* field has been available since v1.4.0.
*/
size_t pmtud_probeslen;
/* The following fields have been added since NGTCP2_SETTINGS_V3. */
/**
* :member:`glitch_ratelim_burst` is the maximum number of tokens
* available to "glitch" rate limiter. "glitch" is a suspicious
* activity from a remote endpoint. If detected, certain amount of
* tokens are consumed. If no tokens are available to consume, the
* connection is closed. The rate of token generation is specified
* by :member:`glitch_ratelim_rate`. This field has been available
* since v1.15.0.
*/
uint64_t glitch_ratelim_burst;
/**
* :member:`glitch_ratelim_rate` is the number of tokens generated
* per second. See :member:`glitch_ratelim_burst` for "glitch" rate
* limiter. This field has been available since v1.15.0.
*/
uint64_t glitch_ratelim_rate;
} ngtcp2_settings;

/**
Expand Down Expand Up @@ -3000,9 +3018,8 @@ typedef int (*ngtcp2_begin_path_validation)(ngtcp2_conn *conn, uint32_t flags,
* an application the outcome of path validation. |flags| is zero or
* more of :macro:`NGTCP2_PATH_VALIDATION_FLAG_*
* <NGTCP2_PATH_VALIDATION_FLAG_NONE>`. |path| is the path that was
* validated. |old_path| is the path that is previously used before a
* local endpoint has migrated to |path| if |old_path| is not NULL.
* If |res| is
* validated. |fallback_path|, if not NULL, is the path that is used
* if the path validation failed. If |res| is
* :enum:`ngtcp2_path_validation_result.NGTCP2_PATH_VALIDATION_RESULT_SUCCESS`,
* the path validation succeeded. If |res| is
* :enum:`ngtcp2_path_validation_result.NGTCP2_PATH_VALIDATION_RESULT_FAILURE`,
Expand All @@ -3014,7 +3031,7 @@ typedef int (*ngtcp2_begin_path_validation)(ngtcp2_conn *conn, uint32_t flags,
*/
typedef int (*ngtcp2_path_validation)(ngtcp2_conn *conn, uint32_t flags,
const ngtcp2_path *path,
const ngtcp2_path *old_path,
const ngtcp2_path *fallback_path,
ngtcp2_path_validation_result res,
void *user_data);

Expand Down Expand Up @@ -5598,6 +5615,77 @@ NGTCP2_EXTERN size_t ngtcp2_conn_get_send_quantum(ngtcp2_conn *conn);
NGTCP2_EXTERN size_t ngtcp2_conn_get_stream_loss_count(ngtcp2_conn *conn,
int64_t stream_id);

/**
* @functypedef
*
* :type:`ngtcp2_write_pkt` is a callback function to write a single
* packet in the buffer pointed by |dest| of length |destlen|. The
* implementation should use `ngtcp2_conn_write_pkt`,
* `ngtcp2_conn_writev_stream`, `ngtcp2_conn_writev_datagram`, or
* their variants to write the packet. |path|, |pi|, |dest|,
* |destlen|, and |ts| should be directly passed to those functions.
* If the callback succeeds, it should return the number of bytes
* written to the buffer. In general, this callback function should
* return the value that the above mentioned functions returned except
* for the following error codes:
*
* - :macro:`NGTCP2_ERR_STREAM_DATA_BLOCKED`
* - :macro:`NGTCP2_ERR_STREAM_SHUT_WR`
* - :macro:`NGTCP2_ERR_STREAM_NOT_FOUND`
*
* Those error codes should be handled by an application. If any
* error occurred outside those functions, return
* :macro:`NGTCP2_ERR_CALLBACK_FAILURE`. If no packet is produced,
* return 0.
*
* Because GSO requires that the aggregated packets have the same
* length, :macro:`NGTCP2_WRITE_STREAM_FLAG_PADDING` (or
* :macro:`NGTCP2_WRITE_DATAGRAM_FLAG_PADDING` if
* `ngtcp2_conn_writev_datagram` is used) is recommended.
*
* This callback function has been available since v1.15.0.
*/
typedef ngtcp2_ssize (*ngtcp2_write_pkt)(ngtcp2_conn *conn, ngtcp2_path *path,
ngtcp2_pkt_info *pi, uint8_t *dest,
size_t destlen, ngtcp2_tstamp ts,
void *user_data);

/**
* @function
*
* `ngtcp2_conn_write_aggregate_pkt` is a helper function to write
* multiple packets in the provided buffer, which is suitable to be
* sent at once in GSO. This function returns the number of bytes
* written to the buffer pointed by |buf| of length |buflen|.
* |buflen| must be at least
* `ngtcp2_conn_get_path_max_tx_udp_payload_size(conn)
* <ngtcp2_conn_get_path_max_tx_udp_payload_size>` bytes long. It is
* recommended to pass the buffer at least
* `ngtcp2_conn_get_max_tx_udp_payload_size(conn)
* <ngtcp2_conn_get_max_tx_udp_payload_size>` bytes in order to send a
* PMTUD packet. This function only writes multiple packets if the
* first packet is `ngtcp2_conn_get_path_max_tx_udp_payload_size(conn)
* <ngtcp2_conn_get_path_max_tx_udp_payload_size>` bytes long. The
* application can adjust the length of the buffer to limit the number
* of packets to aggregate. If this function returns positive
* integer, all packets share the same :type:`ngtcp2_path` and
* :type:`ngtcp2_pkt_info` values, and they are assigned to the
* objects pointed by |path| and |pi| respectively. The length of all
* packets other than the last packet is assigned to |*pgsolen|. The
* length of last packet is equal to or less than |*pgsolen|.
* |write_pkt| must write a single packet. After all packets are
* written, this function calls `ngtcp2_conn_update_pkt_tx_time`.
*
* This function returns the number of bytes written to the buffer, or
* a negative error code returned by |write_pkt|.
*
* This function has been available since v1.15.0.
*/
NGTCP2_EXTERN ngtcp2_ssize ngtcp2_conn_write_aggregate_pkt_versioned(
ngtcp2_conn *conn, ngtcp2_path *path, int pkt_info_version,
ngtcp2_pkt_info *pi, uint8_t *buf, size_t buflen, size_t *pgsolen,
ngtcp2_write_pkt write_pkt, ngtcp2_tstamp ts);

/**
* @function
*
Expand Down Expand Up @@ -5680,15 +5768,19 @@ NGTCP2_EXTERN void ngtcp2_path_storage_zero(ngtcp2_path_storage *ps);
* values. First this function fills |settings| with 0, and set the
* default value to the following fields:
*
* * :type:`cc_algo <ngtcp2_settings.cc_algo>` =
* * :member:`cc_algo <ngtcp2_settings.cc_algo>` =
* :enum:`ngtcp2_cc_algo.NGTCP2_CC_ALGO_CUBIC`
* * :type:`initial_rtt <ngtcp2_settings.initial_rtt>` =
* * :member:`initial_rtt <ngtcp2_settings.initial_rtt>` =
* :macro:`NGTCP2_DEFAULT_INITIAL_RTT`
* * :type:`ack_thresh <ngtcp2_settings.ack_thresh>` = 2
* * :type:`max_tx_udp_payload_size
* * :member:`ack_thresh <ngtcp2_settings.ack_thresh>` = 2
* * :member:`max_tx_udp_payload_size
* <ngtcp2_settings.max_tx_udp_payload_size>` = 1452
* * :type:`handshake_timeout <ngtcp2_settings.handshake_timeout>` =
* * :member:`handshake_timeout <ngtcp2_settings.handshake_timeout>` =
* ``UINT64_MAX``
* * :member:`glitch_ratelim_burst
* <ngtcp2_settings.glitch_ratelim_burst>` = 1000
* * :member:`glitch_ratelim_rate
* <ngtcp2_settings.glitch_ratelim_rate>` = 33
*/
NGTCP2_EXTERN void ngtcp2_settings_default_versioned(int settings_version,
ngtcp2_settings *settings);
Expand All @@ -5700,15 +5792,15 @@ NGTCP2_EXTERN void ngtcp2_settings_default_versioned(int settings_version,
* default values. First this function fills |params| with 0, and set
* the default value to the following fields:
*
* * :type:`max_udp_payload_size
* * :member:`max_udp_payload_size
* <ngtcp2_transport_params.max_udp_payload_size>` =
* :macro:`NGTCP2_DEFAULT_MAX_RECV_UDP_PAYLOAD_SIZE`
* * :type:`ack_delay_exponent
* * :member:`ack_delay_exponent
* <ngtcp2_transport_params.ack_delay_exponent>` =
* :macro:`NGTCP2_DEFAULT_ACK_DELAY_EXPONENT`
* * :type:`max_ack_delay <ngtcp2_transport_params.max_ack_delay>` =
* * :member:`max_ack_delay <ngtcp2_transport_params.max_ack_delay>` =
* :macro:`NGTCP2_DEFAULT_MAX_ACK_DELAY`
* * :type:`active_connection_id_limit
* * :member:`active_connection_id_limit
* <ngtcp2_transport_params.active_connection_id_limit>` =
* :macro:`NGTCP2_DEFAULT_ACTIVE_CONNECTION_ID_LIMIT`
*/
Expand Down Expand Up @@ -5980,6 +6072,17 @@ NGTCP2_EXTERN uint32_t ngtcp2_select_version(const uint32_t *preferred_versions,
#define ngtcp2_conn_get_conn_info(CONN, CINFO) \
ngtcp2_conn_get_conn_info_versioned((CONN), NGTCP2_CONN_INFO_VERSION, (CINFO))

/*
* `ngtcp2_conn_write_aggregate_pkt` is a wrapper around
* `ngtcp2_conn_write_aggregate_pkt_versioned` to set the correct
* struct version.
*/
#define ngtcp2_conn_write_aggregate_pkt(CONN, PATH, PI, BUF, BUFLEN, PGSOLEN, \
WRITE_PKT, TS) \
ngtcp2_conn_write_aggregate_pkt_versioned( \
(CONN), (PATH), NGTCP2_PKT_INFO_VERSION, (PI), (BUF), (BUFLEN), (PGSOLEN), \
(WRITE_PKT), (TS))

/*
* `ngtcp2_settings_default` is a wrapper around
* `ngtcp2_settings_default_versioned` to set the correct struct
Expand Down
4 changes: 2 additions & 2 deletions deps/ngtcp2/ngtcp2/lib/includes/ngtcp2/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*
* Version number of the ngtcp2 library release.
*/
#define NGTCP2_VERSION "1.14.0"
#define NGTCP2_VERSION "1.15.1"

/**
* @macro
Expand All @@ -46,6 +46,6 @@
* number, 8 bits for minor and 8 bits for patch. Version 1.2.3
* becomes 0x010203.
*/
#define NGTCP2_VERSION_NUM 0x010e00
#define NGTCP2_VERSION_NUM 0x010f01

#endif /* !defined(NGTCP2_VERSION_H) */
6 changes: 3 additions & 3 deletions deps/ngtcp2/ngtcp2/lib/ngtcp2_acktr.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ void ngtcp2_acktr_recv_ack(ngtcp2_acktr *acktr, const ngtcp2_ack *fr) {
}

void ngtcp2_acktr_commit_ack(ngtcp2_acktr *acktr) {
acktr->flags &= (uint16_t) ~(NGTCP2_ACKTR_FLAG_ACTIVE_ACK |
NGTCP2_ACKTR_FLAG_IMMEDIATE_ACK |
NGTCP2_ACKTR_FLAG_CANCEL_TIMER);
acktr->flags &=
(uint16_t)~(NGTCP2_ACKTR_FLAG_ACTIVE_ACK | NGTCP2_ACKTR_FLAG_IMMEDIATE_ACK |
NGTCP2_ACKTR_FLAG_CANCEL_TIMER);
acktr->first_unacked_ts = UINT64_MAX;
acktr->rx_npkt = 0;
}
Expand Down
19 changes: 6 additions & 13 deletions deps/ngtcp2/ngtcp2/lib/ngtcp2_bbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "ngtcp2_rcvry.h"
#include "ngtcp2_rst.h"
#include "ngtcp2_conn_stat.h"
#include "ngtcp2_pcg.h"

#define NGTCP2_BBR_MAX_BW_FILTERLEN 2

Expand Down Expand Up @@ -906,15 +907,9 @@ static int bbr_is_time_to_probe_bw(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
}

static void bbr_pick_probe_wait(ngtcp2_cc_bbr *bbr) {
uint8_t rand;

bbr->rand(&rand, 1, &bbr->rand_ctx);

bbr->rounds_since_bw_probe = (uint64_t)(rand / 128);

bbr->rand(&rand, 1, &bbr->rand_ctx);

bbr->bw_probe_wait = 2 * NGTCP2_SECONDS + NGTCP2_SECONDS * rand / 255;
bbr->rounds_since_bw_probe = ngtcp2_pcg32_rand_n(bbr->pcg, 2);
bbr->bw_probe_wait =
2 * NGTCP2_SECONDS + ngtcp2_pcg32_rand_n(bbr->pcg, NGTCP2_SECONDS + 1);
}

static int bbr_is_reno_coexistence_probe_time(ngtcp2_cc_bbr *bbr,
Expand Down Expand Up @@ -1388,8 +1383,7 @@ static void bbr_cc_reset(ngtcp2_cc *cc, ngtcp2_conn_stat *cstat,

void ngtcp2_cc_bbr_init(ngtcp2_cc_bbr *bbr, ngtcp2_log *log,
ngtcp2_conn_stat *cstat, ngtcp2_rst *rst,
ngtcp2_tstamp initial_ts, ngtcp2_rand rand,
const ngtcp2_rand_ctx *rand_ctx) {
ngtcp2_tstamp initial_ts, ngtcp2_pcg32 *pcg) {
*bbr = (ngtcp2_cc_bbr){
.cc =
{
Expand All @@ -1403,8 +1397,7 @@ void ngtcp2_cc_bbr_init(ngtcp2_cc_bbr *bbr, ngtcp2_log *log,
.reset = bbr_cc_reset,
},
.rst = rst,
.rand = rand,
.rand_ctx = *rand_ctx,
.pcg = pcg,
.initial_cwnd = cstat->cwnd,
};

Expand Down
7 changes: 3 additions & 4 deletions deps/ngtcp2/ngtcp2/lib/ngtcp2_bbr.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "ngtcp2_window_filter.h"

typedef struct ngtcp2_rst ngtcp2_rst;
typedef struct ngtcp2_pcg32 ngtcp2_pcg32;

typedef enum ngtcp2_bbr_state {
NGTCP2_BBR_STATE_STARTUP,
Expand Down Expand Up @@ -62,8 +63,7 @@ typedef struct ngtcp2_cc_bbr {

uint64_t initial_cwnd;
ngtcp2_rst *rst;
ngtcp2_rand rand;
ngtcp2_rand_ctx rand_ctx;
ngtcp2_pcg32 *pcg;

/* max_bw_filter for tracking the maximum recent delivery rate
samples for estimating max_bw. */
Expand Down Expand Up @@ -136,7 +136,6 @@ typedef struct ngtcp2_cc_bbr {

void ngtcp2_cc_bbr_init(ngtcp2_cc_bbr *bbr, ngtcp2_log *log,
ngtcp2_conn_stat *cstat, ngtcp2_rst *rst,
ngtcp2_tstamp initial_ts, ngtcp2_rand rand,
const ngtcp2_rand_ctx *rand_ctx);
ngtcp2_tstamp initial_ts, ngtcp2_pcg32 *pcg);

#endif /* !defined(NGTCP2_BBR_H) */
6 changes: 6 additions & 0 deletions deps/ngtcp2/ngtcp2/lib/ngtcp2_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ size_t ngtcp2_buf_cap(const ngtcp2_buf *buf) {
return (size_t)(buf->end - buf->begin);
}

void ngtcp2_buf_trunc(ngtcp2_buf *buf, size_t len) {
if (ngtcp2_buf_len(buf) > len) {
buf->last = buf->pos + len;
}
}

int ngtcp2_buf_chain_new(ngtcp2_buf_chain **pbufchain, size_t len,
const ngtcp2_mem *mem) {
*pbufchain = ngtcp2_mem_malloc(mem, sizeof(ngtcp2_buf_chain) + len);
Expand Down
11 changes: 8 additions & 3 deletions deps/ngtcp2/ngtcp2/lib/ngtcp2_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,21 @@ static inline size_t ngtcp2_buf_left(const ngtcp2_buf *buf) {
* ngtcp2_buf_len returns the number of bytes left to read. In other
* words, it returns buf->last - buf->pos.
*/
static inline size_t ngtcp2_buf_len(const ngtcp2_buf *buf) {
return (size_t)(buf->last - buf->pos);
}
#define ngtcp2_buf_len(BUF) (size_t)((BUF)->last - (BUF)->pos)

/*
* ngtcp2_buf_cap returns the capacity of the buffer. In other words,
* it returns buf->end - buf->begin.
*/
size_t ngtcp2_buf_cap(const ngtcp2_buf *buf);

/*
* ngtcp2_buf_trunc truncates the number of bytes to read to at most
* |len|. In other words, it sets buf->last = buf->pos + len if
* ngtcp2_buf_len(buf) > len.
*/
void ngtcp2_buf_trunc(ngtcp2_buf *buf, size_t len);

/*
* ngtcp2_buf_chain is a linked list of ngtcp2_buf.
*/
Expand Down
Loading
Loading