GeezerVison is showing github.com — deps: update ngtcp2 to 1.26.0 · nodejs/node@222866c
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/crypto/ossl/ossl.c +15-2Lines changed: 15 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -411,6 +411,7 @@ static void crypto_buf_write(crypto_buf *cbuf, const uint8_t *data, | 411 | 411 |
| 412 | 412 | struct ngtcp2_crypto_ossl_ctx { | 413 | 413 | SSL *ssl; | | 414 | + ngtcp2_encryption_level rx_level; | 414 | 415 | ngtcp2_encryption_level tx_level; | 415 | 416 | crypto_buf *crypto_head, *crypto_read, *crypto_write; | 416 | 417 | size_t crypto_head_released; | @@ -425,6 +426,7 @@ int ngtcp2_crypto_ossl_ctx_new(ngtcp2_crypto_ossl_ctx **possl_ctx, SSL *ssl) { | 425 | 426 | } | 426 | 427 |
| 427 | 428 | ossl_ctx->ssl = ssl; | | 429 | + ossl_ctx->rx_level = NGTCP2_ENCRYPTION_LEVEL_INITIAL; | 428 | 430 | ossl_ctx->tx_level = NGTCP2_ENCRYPTION_LEVEL_INITIAL; | 429 | 431 | ossl_ctx->crypto_head = ossl_ctx->crypto_read = ossl_ctx->crypto_write = NULL; | 430 | 432 | ossl_ctx->crypto_head_released = 0; | @@ -962,7 +964,10 @@ int ngtcp2_crypto_read_write_crypto_data( | 962 | 964 | SSL *ssl = ossl_ctx->ssl; | 963 | 965 | int rv; | 964 | 966 | int err; | 965 | | - (void)encryption_level; | | 967 | + | | 968 | + if (encryption_level != ossl_ctx->rx_level) { | | 969 | + return -1; | | 970 | + } | 966 | 971 |
| 967 | 972 | if (crypto_ossl_ctx_write_crypto_data(ossl_ctx, data, datalen) != 0) { | 968 | 973 | return -1; | @@ -1128,7 +1133,10 @@ static int ossl_yield_secret(SSL *ssl, uint32_t ossl_level, int direction, | 1128 | 1133 | return 0; | 1129 | 1134 | } | 1130 | 1135 |
| 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 | + } | 1132 | 1140 |
| 1133 | 1141 | return 1; | 1134 | 1142 | } | @@ -1138,6 +1146,11 @@ static int ossl_yield_secret(SSL *ssl, uint32_t ossl_level, int direction, | 1138 | 1146 | return 0; | 1139 | 1147 | } | 1140 | 1148 |
| | 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 | + | 1141 | 1154 | return 1; | 1142 | 1155 | } | 1143 | 1156 |
| |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/crypto/picotls/picotls.c +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -387,9 +387,11 @@ int ngtcp2_crypto_read_write_crypto_data( | 387 | 387 | size_t i; | 388 | 388 | int rv; | 389 | 389 |
| 390 | | - ptls_buffer_init(&sendbuf, (void *)"", 0); | | 390 | + if (epoch != ptls_get_read_epoch(cptls->ptls)) { | | 391 | + return -1; | | 392 | + } | 391 | 393 |
| 392 | | - assert(datalen == 0 || epoch == ptls_get_read_epoch(cptls->ptls)); | | 394 | + ptls_buffer_init(&sendbuf, (void *)"", 0); | 393 | 395 |
| 394 | 396 | rv = ptls_handle_message(cptls->ptls, &sendbuf, epoch_offsets, epoch, data, | 395 | 397 | datalen, &cptls->handshake_properties); | |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/crypto/shared.c +32-3Lines changed: 32 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -236,6 +236,35 @@ int ngtcp2_crypto_update_traffic_secret(uint8_t *dest, uint32_t version, | 236 | 236 | return 0; | 237 | 237 | } | 238 | 238 |
| | 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 | + | 239 | 268 | int ngtcp2_crypto_derive_and_install_rx_key(ngtcp2_conn *conn, uint8_t *key, | 240 | 269 | uint8_t *iv, uint8_t *hp_key, | 241 | 270 | ngtcp2_encryption_level level, | @@ -282,7 +311,7 @@ int ngtcp2_crypto_derive_and_install_rx_key(ngtcp2_conn *conn, uint8_t *key, | 282 | 311 | case NGTCP2_ENCRYPTION_LEVEL_HANDSHAKE: | 283 | 312 | if (ngtcp2_conn_is_server2(conn) && | 284 | 313 | !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); | 286 | 315 | if (rv != 0) { | 287 | 316 | return -1; | 288 | 317 | } | @@ -340,7 +369,7 @@ int ngtcp2_crypto_derive_and_install_rx_key(ngtcp2_conn *conn, uint8_t *key, | 340 | 369 | break; | 341 | 370 | case NGTCP2_ENCRYPTION_LEVEL_1RTT: | 342 | 371 | 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); | 344 | 373 | if (rv != 0) { | 345 | 374 | goto fail; | 346 | 375 | } | @@ -443,7 +472,7 @@ int ngtcp2_crypto_derive_and_install_tx_key(ngtcp2_conn *conn, uint8_t *key, | 443 | 472 | case NGTCP2_ENCRYPTION_LEVEL_HANDSHAKE: | 444 | 473 | if (ngtcp2_conn_is_server2(conn) && | 445 | 474 | !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); | 447 | 476 | if (rv != 0) { | 448 | 477 | return -1; | 449 | 478 | } | |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/examples/client.cc +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1721,7 +1721,8 @@ std::expected<void, Error> Client::make_stream_early() { | 1721 | 1721 | void Client::on_extend_max_streams() { | 1722 | 1722 | int64_t stream_id; | 1723 | 1723 |
| 1724 | | - if ((config.delay_stream && !handshake_confirmed_) || | | 1724 | + if (config.requests.empty() || | | 1725 | + (config.delay_stream && !handshake_confirmed_) || | 1725 | 1726 | ev_is_active(&delay_stream_timer_)) { | 1726 | 1727 | return; | 1727 | 1728 | } | |
Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -82,6 +82,10 @@ ProtoCodec::on_stream_close(int64_t stream_id, | 82 | 82 | return {}; | 83 | 83 | } | 84 | 84 |
| | 85 | + if (auto stream = client_->find_stream(stream_id); stream) { | | 86 | + sendq_.erase(stream); | | 87 | + } | | 88 | + | 85 | 89 | if (!config.quiet) { | 86 | 90 | std::println(stderr, | 87 | 91 | "HTTP stream {:#x} closed with error codes (RX:{}, TX:{})", | |
Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -63,7 +63,7 @@ class ProtoCodec { | 63 | 63 | std::expected<void, Error> extend_max_stream_data(int64_t stream_id, | 64 | 64 | uint64_t max_data); | 65 | 65 |
| 66 | | - void early_data_rejected() {} | | 66 | + void early_data_rejected() { sendq_.clear(); } | 67 | 67 |
| 68 | 68 | std::expected<void, Error> | 69 | 69 | on_stream_close(int64_t stream_id, std::optional<uint64_t> rx_app_error_code, | |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/examples/server.cc +46-4Lines changed: 46 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 31 | 31 | #include <memory> | 32 | 32 | #include <fstream> | 33 | 33 | #include <iomanip> | | 34 | +#include <limits> | | 35 | +#include <utility> | 34 | 36 |
| 35 | 37 | #include <unistd.h> | 36 | 38 | #include <getopt.h> | @@ -216,6 +218,11 @@ Stream::open_file(const std::filesystem::path &path) { | 216 | 218 | close(fd); | 217 | 219 | } else { | 218 | 220 | 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 | + } | 219 | 226 | fe.len = static_cast<size_t>(st.st_size); | 220 | 227 | if (fe.len) { | 221 | 228 | 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) { | 321 | 328 | } | 322 | 329 |
| 323 | 330 | 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) { | 327 | 332 | s->remove(h); | 328 | 333 | } | 329 | 334 |
| @@ -773,6 +778,7 @@ Handler::init(const Endpoint &ep, const Address &local_addr, | 773 | 778 | settings.handshake_timeout = config.handshake_timeout; | 774 | 779 | settings.no_pmtud = config.no_pmtud; | 775 | 780 | settings.ack_thresh = config.ack_thresh; | | 781 | + settings.write_stream_data_thresh = config.write_stream_data_thresh; | 776 | 782 | if (config.max_udp_payload_size) { | 777 | 783 | settings.max_tx_udp_payload_size = config.max_udp_payload_size; | 778 | 784 | settings.no_tx_udp_payload_size_shaping = 1; | @@ -1705,7 +1711,9 @@ void Server::on_read(const Endpoint &ep) { | 1705 | 1711 | stderr, | 1706 | 1712 | "Received packet: local={} remote={} if={} ecn={:#x} {} bytes", | 1707 | 1713 | 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); | 1709 | 1717 | } | 1710 | 1718 |
| 1711 | 1719 | // 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, | 1735 | 1743 | NGTCP2_SV_SCIDLEN); | 1736 | 1744 | rv) { | 1737 | 1745 | case 0: | | 1746 | + if ((data[0] & 0x80U) && vc.version == 0) { | | 1747 | + // Version Negotiation packet was received. | | 1748 | + return; | | 1749 | + } | | 1750 | + | 1738 | 1751 | break; | 1739 | 1752 | case NGTCP2_ERR_VERSION_NEGOTIATION: | 1740 | 1753 | (void)send_version_negotiation(vc.version, {vc.scid, vc.scidlen}, | @@ -2658,6 +2671,15 @@ void print_help() { | 2658 | 2671 | to send per an event loop in a single connection. It | 2659 | 2672 | defaults to 0, which means it is not limited by the | 2660 | 2673 | 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"( | 2661 | 2683 | -h, --help Display this help and exit. | 2662 | 2684 |
| 2663 | 2685 | --- | @@ -2732,6 +2754,7 @@ int main(int argc, char **argv) { | 2732 | 2754 | {"no-gso", no_argument, &flag, 35}, | 2733 | 2755 | {"show-stat", no_argument, &flag, 36}, | 2734 | 2756 | {"gso-burst", required_argument, &flag, 37}, | | 2757 | + {"write-stream-data-thresh", required_argument, &flag, 38}, | 2735 | 2758 | {}, | 2736 | 2759 | }; | 2737 | 2760 |
| @@ -3163,6 +3186,25 @@ int main(int argc, char **argv) { | 3163 | 3186 |
| 3164 | 3187 | break; | 3165 | 3188 | } | | 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 | + } | 3166 | 3208 | } | 3167 | 3209 | break; | 3168 | 3210 | default: | |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/examples/server.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -68,7 +68,7 @@ enum FileEntryFlag { | 68 | 68 | }; | 69 | 69 |
| 70 | 70 | struct FileEntry { | 71 | | - uint64_t len{}; | | 71 | + size_t len{}; | 72 | 72 | void *map{}; | 73 | 73 | int fd{}; | 74 | 74 | uint8_t flags{}; | |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/examples/server_base.h +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -169,6 +169,9 @@ struct Config { | 169 | 169 | // gso_burst is the number of packets to aggregate in GSO. 0 means | 170 | 170 | // it is not limited by the configuration. | 171 | 171 | 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}; | 172 | 175 | }; | 173 | 176 |
| 174 | 177 | struct HTTPHeader { | |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/ngtcp2/examples/sim_test.cc +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -130,8 +130,8 @@ void test_sim_unistream(void) { | 130 | 130 |
| 131 | 131 | assert_true(rv.has_value()); | 132 | 132 | 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()); | 135 | 135 | } | 136 | 136 | } | 137 | 137 |
| |
|