Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3b29dff

Browse filesBrowse files
nodejs-github-botmarco-ippolito
authored andcommitted
deps: update ngtcp2 to 1.3.0
PR-URL: #51796 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent 88e08bb commit 3b29dff
Copy full SHA for 3b29dff

File tree

Expand file treeCollapse file tree

8 files changed

+205
-93
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

8 files changed

+205
-93
lines changed
Open diff view settings
Collapse file

‎deps/ngtcp2/ngtcp2/lib/includes/ngtcp2/version.h‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/lib/includes/ngtcp2/version.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* Version number of the ngtcp2 library release.
3838
*/
39-
#define NGTCP2_VERSION "1.2.0"
39+
#define NGTCP2_VERSION "1.3.0"
4040

4141
/**
4242
* @macro
@@ -46,6 +46,6 @@
4646
* number, 8 bits for minor and 8 bits for patch. Version 1.2.3
4747
* becomes 0x010203.
4848
*/
49-
#define NGTCP2_VERSION_NUM 0x010200
49+
#define NGTCP2_VERSION_NUM 0x010300
5050

5151
#endif /* VERSION_H */
Collapse file

‎deps/ngtcp2/ngtcp2/lib/ngtcp2_buf.h‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/lib/ngtcp2_buf.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ typedef struct ngtcp2_buf {
3636
uint8_t *begin;
3737
/* end points to the one beyond of the last byte of the buffer */
3838
uint8_t *end;
39-
/* pos pointers to the start of data. Typically, this points to the
39+
/* pos points to the start of data. Typically, this points to the
4040
point that next data should be read. Initially, it points to
4141
|begin|. */
4242
uint8_t *pos;
Collapse file

‎deps/ngtcp2/ngtcp2/lib/ngtcp2_cc.c‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/lib/ngtcp2_cc.c
+17-33Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
#include <assert.h>
2828
#include <string.h>
2929

30-
#if defined(_MSC_VER)
31-
# include <intrin.h>
32-
#endif
33-
3430
#include "ngtcp2_log.h"
3531
#include "ngtcp2_macro.h"
3632
#include "ngtcp2_mem.h"
@@ -235,39 +231,27 @@ void ngtcp2_cc_cubic_init(ngtcp2_cc_cubic *cubic, ngtcp2_log *log) {
235231
}
236232

237233
uint64_t ngtcp2_cbrt(uint64_t n) {
238-
int d;
239-
uint64_t a;
240-
241-
if (n == 0) {
242-
return 0;
243-
}
244-
245-
#if defined(_MSC_VER)
246-
{
247-
unsigned long index;
248-
# if defined(_WIN64)
249-
if (_BitScanReverse64(&index, n)) {
250-
d = 61 - index;
251-
} else {
252-
ngtcp2_unreachable();
253-
}
254-
# else /* !defined(_WIN64) */
255-
if (_BitScanReverse(&index, (unsigned int)(n >> 32))) {
256-
d = 31 - index;
257-
} else {
258-
d = 32 + 31 - _BitScanReverse(&index, (unsigned int)n);
234+
size_t s;
235+
uint64_t y = 0;
236+
uint64_t b;
237+
238+
for (s = 63; s > 0; s -= 3) {
239+
y <<= 1;
240+
b = 3 * y * (y + 1) + 1;
241+
if ((n >> s) >= b) {
242+
n -= b << s;
243+
y++;
259244
}
260-
# endif /* !defined(_WIN64) */
261245
}
262-
#else /* !defined(_MSC_VER) */
263-
d = __builtin_clzll(n);
264-
#endif /* !defined(_MSC_VER) */
265-
a = 1ULL << ((64 - d) / 3 + 1);
266246

267-
for (; a * a * a > n;) {
268-
a = (2 * a + n / a / a) / 3;
247+
y <<= 1;
248+
b = 3 * y * (y + 1) + 1;
249+
if (n >= b) {
250+
n -= b;
251+
y++;
269252
}
270-
return a;
253+
254+
return y;
271255
}
272256

273257
/* HyStart++ constants */
Collapse file

‎deps/ngtcp2/ngtcp2/lib/ngtcp2_conn.c‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/lib/ngtcp2_conn.c
+33-30Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3441,12 +3441,22 @@ static ngtcp2_ssize conn_write_pkt(ngtcp2_conn *conn, ngtcp2_pkt_info *pi,
34413441
}
34423442

34433443
switch ((*pfrc)->fr.type) {
3444+
case NGTCP2_FRAME_RESET_STREAM:
3445+
strm =
3446+
ngtcp2_conn_find_stream(conn, (*pfrc)->fr.reset_stream.stream_id);
3447+
if (strm == NULL ||
3448+
!ngtcp2_strm_require_retransmit_reset_stream(strm)) {
3449+
frc = *pfrc;
3450+
*pfrc = (*pfrc)->next;
3451+
ngtcp2_frame_chain_objalloc_del(frc, &conn->frc_objalloc, conn->mem);
3452+
continue;
3453+
}
3454+
break;
34443455
case NGTCP2_FRAME_STOP_SENDING:
34453456
strm =
34463457
ngtcp2_conn_find_stream(conn, (*pfrc)->fr.stop_sending.stream_id);
34473458
if (strm == NULL ||
3448-
((strm->flags & NGTCP2_STRM_FLAG_SHUT_RD) &&
3449-
ngtcp2_strm_rx_offset(strm) == strm->rx.last_offset)) {
3459+
!ngtcp2_strm_require_retransmit_stop_sending(strm)) {
34503460
frc = *pfrc;
34513461
*pfrc = (*pfrc)->next;
34523462
ngtcp2_frame_chain_objalloc_del(frc, &conn->frc_objalloc, conn->mem);
@@ -3476,10 +3486,8 @@ static ngtcp2_ssize conn_write_pkt(ngtcp2_conn *conn, ngtcp2_pkt_info *pi,
34763486
case NGTCP2_FRAME_MAX_STREAM_DATA:
34773487
strm = ngtcp2_conn_find_stream(conn,
34783488
(*pfrc)->fr.max_stream_data.stream_id);
3479-
if (strm == NULL ||
3480-
(strm->flags &
3481-
(NGTCP2_STRM_FLAG_SHUT_RD | NGTCP2_STRM_FLAG_STOP_SENDING)) ||
3482-
(*pfrc)->fr.max_stream_data.max_stream_data < strm->rx.max_offset) {
3489+
if (strm == NULL || !ngtcp2_strm_require_retransmit_max_stream_data(
3490+
strm, &(*pfrc)->fr.max_stream_data)) {
34833491
frc = *pfrc;
34843492
*pfrc = (*pfrc)->next;
34853493
ngtcp2_frame_chain_objalloc_del(frc, &conn->frc_objalloc, conn->mem);
@@ -3497,8 +3505,8 @@ static ngtcp2_ssize conn_write_pkt(ngtcp2_conn *conn, ngtcp2_pkt_info *pi,
34973505
case NGTCP2_FRAME_STREAM_DATA_BLOCKED:
34983506
strm = ngtcp2_conn_find_stream(
34993507
conn, (*pfrc)->fr.stream_data_blocked.stream_id);
3500-
if (strm == NULL || (strm->flags & NGTCP2_STRM_FLAG_SHUT_WR) ||
3501-
(*pfrc)->fr.stream_data_blocked.offset != strm->tx.max_offset) {
3508+
if (strm == NULL || !ngtcp2_strm_require_retransmit_stream_data_blocked(
3509+
strm, &(*pfrc)->fr.stream_data_blocked)) {
35023510
frc = *pfrc;
35033511
*pfrc = (*pfrc)->next;
35043512
ngtcp2_frame_chain_objalloc_del(frc, &conn->frc_objalloc, conn->mem);
@@ -7145,7 +7153,7 @@ static int conn_recv_stream(ngtcp2_conn *conn, const ngtcp2_stream *fr) {
71457153
return rv;
71467154
}
71477155
}
7148-
} else if (fr->datacnt) {
7156+
} else if (fr->datacnt && !(strm->flags & NGTCP2_STRM_FLAG_STOP_SENDING)) {
71497157
rv = ngtcp2_strm_recv_reordering(strm, fr->data[0].base, fr->data[0].len,
71507158
fr->offset);
71517159
if (rv != 0) {
@@ -7304,27 +7312,20 @@ static int conn_recv_reset_stream(ngtcp2_conn *conn,
73047312
}
73057313

73067314
/* Stream is reset before we create ngtcp2_strm object. */
7307-
conn->rx.offset += fr->final_size;
7308-
ngtcp2_conn_extend_max_offset(conn, fr->final_size);
7309-
7310-
rv = conn_call_stream_reset(conn, fr->stream_id, fr->final_size,
7311-
fr->app_error_code, NULL);
7315+
strm = ngtcp2_objalloc_strm_get(&conn->strm_objalloc);
7316+
if (strm == NULL) {
7317+
return NGTCP2_ERR_NOMEM;
7318+
}
7319+
rv = ngtcp2_conn_init_stream(conn, strm, fr->stream_id, NULL);
73127320
if (rv != 0) {
7321+
ngtcp2_objalloc_strm_release(&conn->strm_objalloc, strm);
73137322
return rv;
73147323
}
73157324

7316-
/* There will be no activity in this stream because we got
7317-
RESET_STREAM and don't write stream data any further. This
7318-
effectively allows another new stream for peer. */
7319-
if (bidi) {
7320-
handle_max_remote_streams_extension(&conn->remote.bidi.unsent_max_streams,
7321-
1);
7322-
} else {
7323-
handle_max_remote_streams_extension(&conn->remote.uni.unsent_max_streams,
7324-
1);
7325+
rv = conn_call_stream_open(conn, strm);
7326+
if (rv != 0) {
7327+
return rv;
73257328
}
7326-
7327-
return 0;
73287329
}
73297330

73307331
if ((strm->flags & NGTCP2_STRM_FLAG_SHUT_RD)) {
@@ -7461,15 +7462,16 @@ static int conn_recv_stop_sending(ngtcp2_conn *conn,
74617462
been acknowledged. */
74627463
if (!ngtcp2_strm_is_all_tx_data_fin_acked(strm) &&
74637464
!(strm->flags & NGTCP2_STRM_FLAG_RESET_STREAM)) {
7465+
strm->flags |= NGTCP2_STRM_FLAG_RESET_STREAM;
7466+
74647467
rv = conn_reset_stream(conn, strm, fr->app_error_code);
74657468
if (rv != 0) {
74667469
return rv;
74677470
}
74687471
}
74697472

7470-
strm->flags |= NGTCP2_STRM_FLAG_SHUT_WR |
7471-
NGTCP2_STRM_FLAG_STOP_SENDING_RECVED |
7472-
NGTCP2_STRM_FLAG_RESET_STREAM;
7473+
strm->flags |=
7474+
NGTCP2_STRM_FLAG_SHUT_WR | NGTCP2_STRM_FLAG_STOP_SENDING_RECVED;
74737475

74747476
ngtcp2_strm_streamfrq_clear(strm);
74757477

@@ -12533,14 +12535,15 @@ static int conn_shutdown_stream_read(ngtcp2_conn *conn, ngtcp2_strm *strm,
1253312535

1253412536
/* Extend connection flow control window for the amount of data
1253512537
which are not passed to application. */
12536-
if (!(strm->flags & (NGTCP2_STRM_FLAG_STOP_SENDING |
12537-
NGTCP2_STRM_FLAG_RESET_STREAM_RECVED))) {
12538+
if (!(strm->flags & NGTCP2_STRM_FLAG_RESET_STREAM_RECVED)) {
1253812539
ngtcp2_conn_extend_max_offset(conn, strm->rx.last_offset -
1253912540
ngtcp2_strm_rx_offset(strm));
1254012541
}
1254112542

1254212543
strm->flags |= NGTCP2_STRM_FLAG_STOP_SENDING;
1254312544

12545+
ngtcp2_strm_discard_reordered_data(strm);
12546+
1254412547
return conn_stop_sending(conn, strm, app_error_code);
1254512548
}
1254612549

Collapse file

‎deps/ngtcp2/ngtcp2/lib/ngtcp2_crypto.c‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/lib/ngtcp2_crypto.c
+41-17Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,25 @@ static uint8_t *write_varint_param(uint8_t *p, ngtcp2_transport_param_id id,
123123
return ngtcp2_put_uvarint(p, value);
124124
}
125125

126+
/*
127+
* zero_paramlen returns the length of a single transport parameter
128+
* which has zero length value in its parameter.
129+
*/
130+
static size_t zero_paramlen(ngtcp2_transport_param_id id) {
131+
return ngtcp2_put_uvarintlen(id) + 1;
132+
}
133+
134+
/*
135+
* write_zero_param writes parameter |id| that has zero length value.
136+
* It returns p + the number of bytes written.
137+
*/
138+
static uint8_t *write_zero_param(uint8_t *p, ngtcp2_transport_param_id id) {
139+
p = ngtcp2_put_uvarint(p, id);
140+
*p++ = 0;
141+
142+
return p;
143+
}
144+
126145
/*
127146
* cid_paramlen returns the length of a single transport parameter
128147
* which has |cid| as value.
@@ -235,9 +254,7 @@ ngtcp2_ssize ngtcp2_transport_params_encode_versioned(
235254
params->ack_delay_exponent);
236255
}
237256
if (params->disable_active_migration) {
238-
len +=
239-
ngtcp2_put_uvarintlen(NGTCP2_TRANSPORT_PARAM_DISABLE_ACTIVE_MIGRATION) +
240-
ngtcp2_put_uvarintlen(0);
257+
len += zero_paramlen(NGTCP2_TRANSPORT_PARAM_DISABLE_ACTIVE_MIGRATION);
241258
}
242259
if (params->max_ack_delay != NGTCP2_DEFAULT_MAX_ACK_DELAY) {
243260
len += varint_paramlen(NGTCP2_TRANSPORT_PARAM_MAX_ACK_DELAY,
@@ -258,8 +275,7 @@ ngtcp2_ssize ngtcp2_transport_params_encode_versioned(
258275
params->max_datagram_frame_size);
259276
}
260277
if (params->grease_quic_bit) {
261-
len += ngtcp2_put_uvarintlen(NGTCP2_TRANSPORT_PARAM_GREASE_QUIC_BIT) +
262-
ngtcp2_put_uvarintlen(0);
278+
len += zero_paramlen(NGTCP2_TRANSPORT_PARAM_GREASE_QUIC_BIT);
263279
}
264280
if (params->version_info_present) {
265281
version_infolen =
@@ -377,8 +393,7 @@ ngtcp2_ssize ngtcp2_transport_params_encode_versioned(
377393
}
378394

379395
if (params->disable_active_migration) {
380-
p = ngtcp2_put_uvarint(p, NGTCP2_TRANSPORT_PARAM_DISABLE_ACTIVE_MIGRATION);
381-
p = ngtcp2_put_uvarint(p, 0);
396+
p = write_zero_param(p, NGTCP2_TRANSPORT_PARAM_DISABLE_ACTIVE_MIGRATION);
382397
}
383398

384399
if (params->max_ack_delay != NGTCP2_DEFAULT_MAX_ACK_DELAY) {
@@ -404,8 +419,7 @@ ngtcp2_ssize ngtcp2_transport_params_encode_versioned(
404419
}
405420

406421
if (params->grease_quic_bit) {
407-
p = ngtcp2_put_uvarint(p, NGTCP2_TRANSPORT_PARAM_GREASE_QUIC_BIT);
408-
p = ngtcp2_put_uvarint(p, 0);
422+
p = write_zero_param(p, NGTCP2_TRANSPORT_PARAM_GREASE_QUIC_BIT);
409423
}
410424

411425
if (params->version_info_present) {
@@ -482,6 +496,22 @@ static int decode_varint_param(uint64_t *pdest, const uint8_t **pp,
482496
return 0;
483497
}
484498

499+
/*
500+
* decode_zero_param decodes zero length value from the buffer pointed
501+
* by |*pp| of length |end - *pp|. The length is encoded in varint
502+
* form. If it decodes zero length value successfully, it increments
503+
* |*pp| by 1, and returns 0. Otherwise it returns -1.
504+
*/
505+
static int decode_zero_param(const uint8_t **pp, const uint8_t *end) {
506+
if (*pp == end || **pp != 0) {
507+
return -1;
508+
}
509+
510+
++*pp;
511+
512+
return 0;
513+
}
514+
485515
/*
486516
* decode_cid_param decodes length prefixed ngtcp2_cid from the buffer
487517
* pointed by |*pp| of length |end - *pp|. The length is encoded in
@@ -701,10 +731,7 @@ int ngtcp2_transport_params_decode_versioned(int transport_params_version,
701731
params->preferred_addr_present = 1;
702732
break;
703733
case NGTCP2_TRANSPORT_PARAM_DISABLE_ACTIVE_MIGRATION:
704-
if (decode_varint(&valuelen, &p, end) != 0) {
705-
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
706-
}
707-
if (valuelen != 0) {
734+
if (decode_zero_param(&p, end) != 0) {
708735
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
709736
}
710737
params->disable_active_migration = 1;
@@ -751,10 +778,7 @@ int ngtcp2_transport_params_decode_versioned(int transport_params_version,
751778
}
752779
break;
753780
case NGTCP2_TRANSPORT_PARAM_GREASE_QUIC_BIT:
754-
if (decode_varint(&valuelen, &p, end) != 0) {
755-
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
756-
}
757-
if (valuelen != 0) {
781+
if (decode_zero_param(&p, end) != 0) {
758782
return NGTCP2_ERR_MALFORMED_TRANSPORT_PARAM;
759783
}
760784
params->grease_quic_bit = 1;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.