From 3c61af1de9b836f1ef2a4e8a0f318cb6a80164ea Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Tue, 24 Aug 2021 11:43:10 -0400 Subject: [PATCH 1/4] bump ngtcp2 submodule --- external/ngtcp2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/ngtcp2 b/external/ngtcp2 index 51e95c8d8..bd19d73eb 160000 --- a/external/ngtcp2 +++ b/external/ngtcp2 @@ -1 +1 @@ -Subproject commit 51e95c8d8972abd69515d9790e8fbb774262d9ea +Subproject commit bd19d73eb949d8cdd665342ffe29e772f3103506 From 45b5fec314af8edeadb4789b11518eed1dce113d Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 25 Aug 2021 10:12:15 -0400 Subject: [PATCH 2/4] make it compile again (squashme) --- llarp/quic/address.hpp | 5 ++--- llarp/quic/connection.cpp | 10 +++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/llarp/quic/address.hpp b/llarp/quic/address.hpp index 42150ed3e..5f7bc3522 100644 --- a/llarp/quic/address.hpp +++ b/llarp/quic/address.hpp @@ -21,7 +21,7 @@ namespace llarp::quic class Address { sockaddr_in6 saddr{}; - ngtcp2_addr a{sizeof(saddr), reinterpret_cast(&saddr), nullptr}; + ngtcp2_addr a{sizeof(saddr), reinterpret_cast(&saddr)}; public: Address() = default; @@ -102,8 +102,7 @@ namespace llarp::quic Address local_, remote_; public: - ngtcp2_path path{ - {local_.sockaddr_size(), local_, nullptr}, {remote_.sockaddr_size(), remote_, nullptr}}; + ngtcp2_path path{{local_.sockaddr_size(), local_}, {remote_.sockaddr_size(), remote_}, nullptr}; // Public accessors are const: const Address& local = local_; diff --git a/llarp/quic/connection.cpp b/llarp/quic/connection.cpp index c3b21d597..f7413463f 100644 --- a/llarp/quic/connection.cpp +++ b/llarp/quic/connection.cpp @@ -275,17 +275,13 @@ namespace llarp::quic return 0; } - int - rand( - uint8_t* dest, - size_t destlen, - const ngtcp2_rand_ctx* rand_ctx, - [[maybe_unused]] ngtcp2_rand_usage usage) + void + rand(uint8_t* dest, size_t destlen, const ngtcp2_rand_ctx* rand_ctx) { LogTrace("######################", __func__); randombytes_buf(dest, destlen); - return 0; } + int get_new_connection_id( ngtcp2_conn* conn_, ngtcp2_cid* cid_, uint8_t* token, size_t cidlen, void* user_data) From ec83641ee888b88254df20d1f3a2789fe0cc6240 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 24 Sep 2021 16:50:19 -0400 Subject: [PATCH 3/4] update submodule --- external/ngtcp2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/ngtcp2 b/external/ngtcp2 index bd19d73eb..15ba6021c 160000 --- a/external/ngtcp2 +++ b/external/ngtcp2 @@ -1 +1 @@ -Subproject commit bd19d73eb949d8cdd665342ffe29e772f3103506 +Subproject commit 15ba6021ca352e2e60f9b43f4b96d2e97a42f60b From 9c37e0146e0ec7930d038dc29b1960ea5301617d Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 24 Sep 2021 17:15:50 -0400 Subject: [PATCH 4/4] make it compile again --- llarp/quic/connection.cpp | 6 +++--- llarp/quic/connection.hpp | 2 +- llarp/quic/endpoint.cpp | 8 +++++--- llarp/quic/endpoint.hpp | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/llarp/quic/connection.cpp b/llarp/quic/connection.cpp index f7413463f..8d7cc8728 100644 --- a/llarp/quic/connection.cpp +++ b/llarp/quic/connection.cpp @@ -244,6 +244,7 @@ namespace llarp::quic int stream_close_cb( ngtcp2_conn* conn, + uint32_t flags, int64_t stream_id, uint64_t app_error_code, void* user_data, @@ -402,7 +403,7 @@ namespace llarp::quic settings.initial_ts = get_timestamp(); // FIXME: IPv6 - settings.max_udp_payload_size = NGTCP2_MAX_PKTLEN_IPV4; + settings.max_udp_payload_size = Endpoint::max_pkt_size_v4; settings.cc_algo = NGTCP2_CC_ALGO_CUBIC; // settings.initial_rtt = ???; # NGTCP2's default is 333ms @@ -1181,8 +1182,7 @@ namespace llarp::quic ngtcp2_conn_get_local_transport_params(*this, &tparams); assert(conn_buffer.empty()); - static_assert(NGTCP2_MAX_PKTLEN_IPV4 > NGTCP2_MAX_PKTLEN_IPV6); - conn_buffer.resize(NGTCP2_MAX_PKTLEN_IPV4); + conn_buffer.resize(Endpoint::max_pkt_size_v4); auto* buf = u8data(conn_buffer); auto* bufend = buf + conn_buffer.size(); diff --git a/llarp/quic/connection.hpp b/llarp/quic/connection.hpp index 828e99d23..be8eb715c 100644 --- a/llarp/quic/connection.hpp +++ b/llarp/quic/connection.hpp @@ -123,7 +123,7 @@ namespace llarp::quic }; // Packet data storage for a packet we are currently sending - std::array send_buffer{}; + std::array send_buffer{}; size_t send_buffer_size = 0; ngtcp2_pkt_info send_pkt_info{}; diff --git a/llarp/quic/endpoint.cpp b/llarp/quic/endpoint.cpp index 16444c1a4..5d57e9010 100644 --- a/llarp/quic/endpoint.cpp +++ b/llarp/quic/endpoint.cpp @@ -199,7 +199,7 @@ namespace llarp::quic void Endpoint::send_version_negotiation(const version_info& vi, const Address& source) { - std::array buf; + std::array buf; std::array versions; std::iota(versions.begin() + 1, versions.end(), NGTCP2_PROTO_VER_MIN); // we're supposed to send some 0x?a?a?a?a version to trigger version negotiation @@ -234,11 +234,13 @@ namespace llarp::quic Path path; ngtcp2_pkt_info pi; - auto write_close_func = - application ? ngtcp2_conn_write_application_close : ngtcp2_conn_write_connection_close; + auto write_close_func = application ? ngtcp2_conn_write_application_close_versioned + : ngtcp2_conn_write_connection_close_versioned; + auto written = write_close_func( conn, path, + NGTCP2_PKT_INFO_VERSION, &pi, u8data(conn.conn_buffer), conn.conn_buffer.size(), diff --git a/llarp/quic/endpoint.hpp b/llarp/quic/endpoint.hpp index 53a850ea4..cfbf92c54 100644 --- a/llarp/quic/endpoint.hpp +++ b/llarp/quic/endpoint.hpp @@ -64,8 +64,8 @@ namespace llarp::quic // Max theoretical size of a UDP packet is 2^16-1 minus IP/UDP header overhead static constexpr size_t max_buf_size = 64 * 1024; // Max size of a UDP packet that we'll send - static constexpr size_t max_pkt_size_v4 = NGTCP2_MAX_PKTLEN_IPV4; - static constexpr size_t max_pkt_size_v6 = NGTCP2_MAX_PKTLEN_IPV6; + static constexpr size_t max_pkt_size_v4 = NGTCP2_MAX_UDP_PAYLOAD_SIZE; + static constexpr size_t max_pkt_size_v6 = NGTCP2_MAX_UDP_PAYLOAD_SIZE; using primary_conn_ptr = std::shared_ptr; using alias_conn_ptr = std::weak_ptr;