GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — deps: update ngtcp2 to 1.26.0 · nodejs/node@222866c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • deps/ngtcp2/ngtcp2
    • crypto
      • ossl
        • ossl.c
      • picotls
        • picotls.c
      • shared.c
    • examples
      • client.cc
      • hq_client_proto_codec.cc
      • hq_client_proto_codec.h
      • server.cc
      • server.h
      • server_base.h
      • sim_test.cc
      • siphash_test.cc
      • siphash_test.h
      • tests
        • ngtcp2test
          • client.py
          • tls.py
        • test_04_clientcert.py
      • tls_client_context_picotls.cc
      • util_test.cc
    • lib
      • includes/ngtcp2
        • ngtcp2.h
        • version.h
      • ngtcp2_balloc.c
      • ngtcp2_callbacks.c
      • ngtcp2_cc.c
      • ngtcp2_cc.h
      • ngtcp2_cid.c
      • ngtcp2_cid.h
      • ngtcp2_conn.c
      • ngtcp2_conn.h
      • ngtcp2_crypto.h
      • ngtcp2_dcidtr.c
      • ngtcp2_dcidtr.h
      • ngtcp2_log.c
      • ngtcp2_map.c
      • ngtcp2_map.h
      • ngtcp2_pkt.c
      • ngtcp2_pkt.h
      • ngtcp2_ppe.c
      • ngtcp2_ppe.h
      • ngtcp2_pv.c
      • ngtcp2_pv.h
      • ngtcp2_qlog.c
      • ngtcp2_ratelim.c
      • ngtcp2_ratelim.h
      • ngtcp2_rob.c
      • ngtcp2_rob.h
      • ngtcp2_rtb.c
      • ngtcp2_rtb.h
      • ngtcp2_settings.c
      • ngtcp2_strm.c
      • ngtcp2_strm.h
      • ngtcp2_transport_params.c
      • ngtcp2_unreachable.h
      • ngtcp2_vec.c
  • src/quic
    • session.cc
  • test/parallel
    • test-quic-callback-error-stream-onerror.mjs

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎deps/ngtcp2/ngtcp2/crypto/ossl/ossl.c‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/crypto/ossl/ossl.c
+15-2Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ static void crypto_buf_write(crypto_buf *cbuf, const uint8_t *data,
411411

412412
struct ngtcp2_crypto_ossl_ctx {
413413
SSL *ssl;
414+
ngtcp2_encryption_level rx_level;
414415
ngtcp2_encryption_level tx_level;
415416
crypto_buf *crypto_head, *crypto_read, *crypto_write;
416417
size_t crypto_head_released;
@@ -425,6 +426,7 @@ int ngtcp2_crypto_ossl_ctx_new(ngtcp2_crypto_ossl_ctx **possl_ctx, SSL *ssl) {
425426
}
426427

427428
ossl_ctx->ssl = ssl;
429+
ossl_ctx->rx_level = NGTCP2_ENCRYPTION_LEVEL_INITIAL;
428430
ossl_ctx->tx_level = NGTCP2_ENCRYPTION_LEVEL_INITIAL;
429431
ossl_ctx->crypto_head = ossl_ctx->crypto_read = ossl_ctx->crypto_write = NULL;
430432
ossl_ctx->crypto_head_released = 0;
@@ -962,7 +964,10 @@ int ngtcp2_crypto_read_write_crypto_data(
962964
SSL *ssl = ossl_ctx->ssl;
963965
int rv;
964966
int err;
965-
(void)encryption_level;
967+
968+
if (encryption_level != ossl_ctx->rx_level) {
969+
return -1;
970+
}
966971

967972
if (crypto_ossl_ctx_write_crypto_data(ossl_ctx, data, datalen) != 0) {
968973
return -1;
@@ -1128,7 +1133,10 @@ static int ossl_yield_secret(SSL *ssl, uint32_t ossl_level, int direction,
11281133
return 0;
11291134
}
11301135

1131-
ossl_ctx->tx_level = level;
1136+
/* CRYPTO data is never sent in 0-RTT packet. */
1137+
if (level != NGTCP2_ENCRYPTION_LEVEL_0RTT) {
1138+
ossl_ctx->tx_level = level;
1139+
}
11321140

11331141
return 1;
11341142
}
@@ -1138,6 +1146,11 @@ static int ossl_yield_secret(SSL *ssl, uint32_t ossl_level, int direction,
11381146
return 0;
11391147
}
11401148

1149+
/* This check is probably not needed, but just in case */
1150+
if (level != NGTCP2_ENCRYPTION_LEVEL_0RTT) {
1151+
ossl_ctx->rx_level = level;
1152+
}
1153+
11411154
return 1;
11421155
}
11431156

Collapse file

‎deps/ngtcp2/ngtcp2/crypto/picotls/picotls.c‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/crypto/picotls/picotls.c
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,11 @@ int ngtcp2_crypto_read_write_crypto_data(
387387
size_t i;
388388
int rv;
389389

390-
ptls_buffer_init(&sendbuf, (void *)"", 0);
390+
if (epoch != ptls_get_read_epoch(cptls->ptls)) {
391+
return -1;
392+
}
391393

392-
assert(datalen == 0 || epoch == ptls_get_read_epoch(cptls->ptls));
394+
ptls_buffer_init(&sendbuf, (void *)"", 0);
393395

394396
rv = ptls_handle_message(cptls->ptls, &sendbuf, epoch_offsets, epoch, data,
395397
datalen, &cptls->handshake_properties);
Collapse file

‎deps/ngtcp2/ngtcp2/crypto/shared.c‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/crypto/shared.c
+32-3Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,35 @@ int ngtcp2_crypto_update_traffic_secret(uint8_t *dest, uint32_t version,
236236
return 0;
237237
}
238238

239+
/*
240+
* crypto_set_remote_transport_params retrieves remote QUIC transport
241+
* parameters from |tls| and sets it to |conn|. Some TLS backends set
242+
* them to |conn| from their own TLS extension callback instead, which
243+
* is never called if a remote endpoint omits the extension. This
244+
* function fails if they have not been set to |conn| after all.
245+
*
246+
* This function returns 0 if it succeeds, or -1.
247+
*/
248+
static int crypto_set_remote_transport_params(ngtcp2_conn *conn, void *tls) {
249+
const ngtcp2_transport_params *params;
250+
251+
if (ngtcp2_crypto_set_remote_transport_params(conn, tls) != 0) {
252+
return -1;
253+
}
254+
255+
params = ngtcp2_conn_get_remote_transport_params2(conn);
256+
257+
/* Client might have the remembered 0-RTT transport parameters, but
258+
they never include initial_scid which is mandatory in the ones
259+
received from a remote endpoint. */
260+
if (!params || !params->initial_scid_present) {
261+
ngtcp2_conn_set_tls_error(conn, NGTCP2_ERR_REQUIRED_TRANSPORT_PARAM);
262+
return -1;
263+
}
264+
265+
return 0;
266+
}
267+
239268
int ngtcp2_crypto_derive_and_install_rx_key(ngtcp2_conn *conn, uint8_t *key,
240269
uint8_t *iv, uint8_t *hp_key,
241270
ngtcp2_encryption_level level,
@@ -282,7 +311,7 @@ int ngtcp2_crypto_derive_and_install_rx_key(ngtcp2_conn *conn, uint8_t *key,
282311
case NGTCP2_ENCRYPTION_LEVEL_HANDSHAKE:
283312
if (ngtcp2_conn_is_server2(conn) &&
284313
!ngtcp2_conn_get_negotiated_version2(conn)) {
285-
rv = ngtcp2_crypto_set_remote_transport_params(conn, tls);
314+
rv = crypto_set_remote_transport_params(conn, tls);
286315
if (rv != 0) {
287316
return -1;
288317
}
@@ -340,7 +369,7 @@ int ngtcp2_crypto_derive_and_install_rx_key(ngtcp2_conn *conn, uint8_t *key,
340369
break;
341370
case NGTCP2_ENCRYPTION_LEVEL_1RTT:
342371
if (!ngtcp2_conn_is_server2(conn)) {
343-
rv = ngtcp2_crypto_set_remote_transport_params(conn, tls);
372+
rv = crypto_set_remote_transport_params(conn, tls);
344373
if (rv != 0) {
345374
goto fail;
346375
}
@@ -443,7 +472,7 @@ int ngtcp2_crypto_derive_and_install_tx_key(ngtcp2_conn *conn, uint8_t *key,
443472
case NGTCP2_ENCRYPTION_LEVEL_HANDSHAKE:
444473
if (ngtcp2_conn_is_server2(conn) &&
445474
!ngtcp2_conn_get_negotiated_version2(conn)) {
446-
rv = ngtcp2_crypto_set_remote_transport_params(conn, tls);
475+
rv = crypto_set_remote_transport_params(conn, tls);
447476
if (rv != 0) {
448477
return -1;
449478
}
Collapse file

‎deps/ngtcp2/ngtcp2/examples/client.cc‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/examples/client.cc
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,8 @@ std::expected<void, Error> Client::make_stream_early() {
17211721
void Client::on_extend_max_streams() {
17221722
int64_t stream_id;
17231723

1724-
if ((config.delay_stream && !handshake_confirmed_) ||
1724+
if (config.requests.empty() ||
1725+
(config.delay_stream && !handshake_confirmed_) ||
17251726
ev_is_active(&delay_stream_timer_)) {
17261727
return;
17271728
}
Collapse file

‎deps/ngtcp2/ngtcp2/examples/hq_client_proto_codec.cc‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/examples/hq_client_proto_codec.cc
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ ProtoCodec::on_stream_close(int64_t stream_id,
8282
return {};
8383
}
8484

85+
if (auto stream = client_->find_stream(stream_id); stream) {
86+
sendq_.erase(stream);
87+
}
88+
8589
if (!config.quiet) {
8690
std::println(stderr,
8791
"HTTP stream {:#x} closed with error codes (RX:{}, TX:{})",
Collapse file

‎deps/ngtcp2/ngtcp2/examples/hq_client_proto_codec.h‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/examples/hq_client_proto_codec.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ProtoCodec {
6363
std::expected<void, Error> extend_max_stream_data(int64_t stream_id,
6464
uint64_t max_data);
6565

66-
void early_data_rejected() {}
66+
void early_data_rejected() { sendq_.clear(); }
6767

6868
std::expected<void, Error>
6969
on_stream_close(int64_t stream_id, std::optional<uint64_t> rx_app_error_code,
Collapse file

‎deps/ngtcp2/ngtcp2/examples/server.cc‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/examples/server.cc
+46-4Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include <memory>
3232
#include <fstream>
3333
#include <iomanip>
34+
#include <limits>
35+
#include <utility>
3436

3537
#include <unistd.h>
3638
#include <getopt.h>
@@ -216,6 +218,11 @@ Stream::open_file(const std::filesystem::path &path) {
216218
close(fd);
217219
} else {
218220
fe.fd = fd;
221+
// A file larger than the address space cannot be mapped.
222+
if (std::cmp_greater(st.st_size, std::numeric_limits<size_t>::max())) {
223+
close(fd);
224+
return std::unexpected{Error::INTEGER_OVERFLOW};
225+
}
219226
fe.len = static_cast<size_t>(st.st_size);
220227
if (fe.len) {
221228
fe.map = mmap(nullptr, fe.len, PROT_READ, MAP_SHARED, fd, 0);
@@ -321,9 +328,7 @@ void timeoutcb(struct ev_loop *loop, ev_timer *w, int revents) {
321328
}
322329

323330
if (auto rv = h->handle_expiry(); !rv) {
324-
if (rv.error() == Error::CLOSE_WAIT) {
325-
ev_timer_stop(loop, w);
326-
} else {
331+
if (rv.error() != Error::CLOSE_WAIT) {
327332
s->remove(h);
328333
}
329334

@@ -773,6 +778,7 @@ Handler::init(const Endpoint &ep, const Address &local_addr,
773778
settings.handshake_timeout = config.handshake_timeout;
774779
settings.no_pmtud = config.no_pmtud;
775780
settings.ack_thresh = config.ack_thresh;
781+
settings.write_stream_data_thresh = config.write_stream_data_thresh;
776782
if (config.max_udp_payload_size) {
777783
settings.max_tx_udp_payload_size = config.max_udp_payload_size;
778784
settings.no_tx_udp_payload_size_shaping = 1;
@@ -1705,7 +1711,9 @@ void Server::on_read(const Endpoint &ep) {
17051711
stderr,
17061712
"Received packet: local={} remote={} if={} ecn={:#x} {} bytes",
17071713
util::straddr(*local_addr), util::straddr(remote_addr),
1708-
if_indextoname(local_addr->ifindex, ifname.data()), pi.ecn, datalen);
1714+
if_indextoname(local_addr->ifindex, ifname.data()) ? ifname.data()
1715+
: "(unknown)",
1716+
pi.ecn, datalen);
17091717
}
17101718

17111719
// Packets less than 21 bytes never be a valid QUIC packet.
@@ -1735,6 +1743,11 @@ void Server::read_pkt(const Endpoint &ep, const Address &local_addr,
17351743
NGTCP2_SV_SCIDLEN);
17361744
rv) {
17371745
case 0:
1746+
if ((data[0] & 0x80U) && vc.version == 0) {
1747+
// Version Negotiation packet was received.
1748+
return;
1749+
}
1750+
17381751
break;
17391752
case NGTCP2_ERR_VERSION_NEGOTIATION:
17401753
(void)send_version_negotiation(vc.version, {vc.scid, vc.scidlen},
@@ -2658,6 +2671,15 @@ void print_help() {
26582671
to send per an event loop in a single connection. It
26592672
defaults to 0, which means it is not limited by the
26602673
configuration.
2674+
--write-stream-data-thresh=<SIZE>
2675+
The threshold for the length of STREAM frame payload
2676+
that the local endpoint sends. If there is data more
2677+
than this value to send, and the flow control does not
2678+
allow sending more than this length, the data is not
2679+
sent, waiting for the window update from the remote
2680+
endpoint.
2681+
Default: )"
2682+
<< config.write_stream_data_thresh << R"(
26612683
-h, --help Display this help and exit.
26622684
26632685
---
@@ -2732,6 +2754,7 @@ int main(int argc, char **argv) {
27322754
{"no-gso", no_argument, &flag, 35},
27332755
{"show-stat", no_argument, &flag, 36},
27342756
{"gso-burst", required_argument, &flag, 37},
2757+
{"write-stream-data-thresh", required_argument, &flag, 38},
27352758
{},
27362759
};
27372760

@@ -3163,6 +3186,25 @@ int main(int argc, char **argv) {
31633186

31643187
break;
31653188
}
3189+
case 38: {
3190+
// --write-stream-data-thresh
3191+
auto n = util::parse_uint_iec(optarg);
3192+
if (!n) {
3193+
std::println(stderr, "write-stream-data-thresh: invalid argument");
3194+
exit(EXIT_FAILURE);
3195+
}
3196+
3197+
if (auto max = std::numeric_limits<size_t>::max(); *n > max) {
3198+
std::println(
3199+
stderr,
3200+
"write-stream-data-thresh: must be less than or equal to {}", max);
3201+
exit(EXIT_FAILURE);
3202+
}
3203+
3204+
config.write_stream_data_thresh = static_cast<size_t>(*n);
3205+
3206+
break;
3207+
}
31663208
}
31673209
break;
31683210
default:
Collapse file

‎deps/ngtcp2/ngtcp2/examples/server.h‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/examples/server.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ enum FileEntryFlag {
6868
};
6969

7070
struct FileEntry {
71-
uint64_t len{};
71+
size_t len{};
7272
void *map{};
7373
int fd{};
7474
uint8_t flags{};
Collapse file

‎deps/ngtcp2/ngtcp2/examples/server_base.h‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/examples/server_base.h
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ struct Config {
169169
// gso_burst is the number of packets to aggregate in GSO. 0 means
170170
// it is not limited by the configuration.
171171
size_t gso_burst{};
172+
// write_stream_data_thresh is the threshold for the length of
173+
// STREAM frame payload that the local endpoint sends.
174+
size_t write_stream_data_thresh{255};
172175
};
173176

174177
struct HTTPHeader {
Collapse file

‎deps/ngtcp2/ngtcp2/examples/sim_test.cc‎

Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/examples/sim_test.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ void test_sim_unistream(void) {
130130

131131
assert_true(rv.has_value());
132132
assert_true(svapp.is_all_bytes_sent());
133-
assert_uint64(link.compute_expected_goodput(link.delay * 2), <=,
134-
svapp.compute_goodput());
133+
assert_lte(link.compute_expected_goodput(link.delay * 2),
134+
svapp.compute_goodput());
135135
}
136136
}
137137

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.