Merge pull request #1751 from majestrate/update-ngtcp2-2021-08-24

Update ngtcp2
This commit is contained in:
Jason Rhinelander 2021-09-27 10:46:21 -03:00 committed by GitHub
commit e32f7faf55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 20 deletions

2
external/ngtcp2 vendored

@ -1 +1 @@
Subproject commit 51e95c8d8972abd69515d9790e8fbb774262d9ea
Subproject commit 15ba6021ca352e2e60f9b43f4b96d2e97a42f60b

View File

@ -21,7 +21,7 @@ namespace llarp::quic
class Address
{
sockaddr_in6 saddr{};
ngtcp2_addr a{sizeof(saddr), reinterpret_cast<sockaddr*>(&saddr), nullptr};
ngtcp2_addr a{sizeof(saddr), reinterpret_cast<sockaddr*>(&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_;

View File

@ -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,
@ -275,17 +276,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)
@ -406,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
@ -1185,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();

View File

@ -123,7 +123,7 @@ namespace llarp::quic
};
// Packet data storage for a packet we are currently sending
std::array<std::byte, NGTCP2_MAX_PKTLEN_IPV4> send_buffer{};
std::array<std::byte, NGTCP2_MAX_UDP_PAYLOAD_SIZE> send_buffer{};
size_t send_buffer_size = 0;
ngtcp2_pkt_info send_pkt_info{};

View File

@ -199,7 +199,7 @@ namespace llarp::quic
void
Endpoint::send_version_negotiation(const version_info& vi, const Address& source)
{
std::array<std::byte, NGTCP2_MAX_PKTLEN_IPV4> buf;
std::array<std::byte, Endpoint::max_pkt_size_v4> buf;
std::array<uint32_t, NGTCP2_PROTO_VER_MAX - NGTCP2_PROTO_VER_MIN + 2> 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(),

View File

@ -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<Connection>;
using alias_conn_ptr = std::weak_ptr<Connection>;