Skip to content

Commit 0e754fa

Browse files
committed
quic: start re-enabling quic with openssl 3.5
Start working on re-enabling QUIC support with the availability of OpenSSL 3.5. This will be a multi-step process. Signed-off-by: James M Snell <[email protected]> PR-URL: #59249 Reviewed-By: Matteo Collina <[email protected]>
1 parent 99f5931 commit 0e754fa

File tree

12 files changed

+435
-176
lines changed

12 files changed

+435
-176
lines changed

deps/ngtcp2/ngtcp2.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
'ngtcp2/crypto/shared.c'
4949
],
5050
'ngtcp2_sources_quictls': [
51-
'ngtcp2/crypto/quictls/quictls.c'
51+
#'ngtcp2/crypto/quictls/quictls.c'
5252
],
5353
'ngtcp2_sources_boringssl': [
5454
'ngtcp2/crypto/boringssl/boringssl.c'

node.gyp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@
187187
'src/udp_wrap.cc',
188188
'src/util.cc',
189189
'src/uv.cc',
190+
'src/quic/cid.cc',
191+
'src/quic/data.cc',
190192
# headers to make for a more pleasant IDE experience
191193
'src/aliased_buffer.h',
192194
'src/aliased_buffer-inl.h',
@@ -323,6 +325,10 @@
323325
'src/udp_wrap.h',
324326
'src/util.h',
325327
'src/util-inl.h',
328+
'src/quic/cid.h',
329+
'src/quic/data.h',
330+
'src/quic/defs.h',
331+
'src/quic/guard.h',
326332
],
327333
'node_crypto_sources': [
328334
'src/crypto/crypto_aes.cc',
@@ -379,8 +385,6 @@
379385
'node_quic_sources': [
380386
'src/quic/application.cc',
381387
'src/quic/bindingdata.cc',
382-
'src/quic/cid.cc',
383-
'src/quic/data.cc',
384388
'src/quic/endpoint.cc',
385389
'src/quic/http3.cc',
386390
'src/quic/logstream.cc',
@@ -394,8 +398,6 @@
394398
'src/quic/transportparams.cc',
395399
'src/quic/application.h',
396400
'src/quic/bindingdata.h',
397-
'src/quic/cid.h',
398-
'src/quic/data.h',
399401
'src/quic/endpoint.h',
400402
'src/quic/http3.h',
401403
'src/quic/logstream.h',

node.gypi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@
380380
'defines': [ 'OPENSSL_API_COMPAT=0x10100000L', ],
381381
'dependencies': [
382382
'./deps/openssl/openssl.gyp:openssl',
383+
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2',
384+
'./deps/ngtcp2/ngtcp2.gyp:nghttp3',
383385

384386
# For tests
385387
'./deps/openssl/openssl.gyp:openssl-cli',

src/quic/cid.cc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
#if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
2-
#include "cid.h"
1+
#if HAVE_OPENSSL
2+
#include "guard.h"
3+
#ifndef OPENSSL_NO_QUIC
34
#include <crypto/crypto_util.h>
45
#include <memory_tracker-inl.h>
56
#include <node_mutex.h>
67
#include <string_bytes.h>
8+
#include "cid.h"
9+
#include "defs.h"
710
#include "nbytes.h"
811
#include "ncrypto.h"
9-
#include "quic/defs.h"
1012

1113
namespace node::quic {
1214

@@ -77,7 +79,7 @@ std::string CID::ToString() const {
7779
return std::string(dest, written);
7880
}
7981

80-
CID CID::kInvalid{};
82+
const CID CID::kInvalid{};
8183

8284
// ============================================================================
8385
// CID::Hash
@@ -95,12 +97,12 @@ size_t CID::Hash::operator()(const CID& cid) const {
9597
// CID::Factory
9698

9799
namespace {
98-
class RandomCIDFactory : public CID::Factory {
100+
class RandomCIDFactory final : public CID::Factory {
99101
public:
100102
RandomCIDFactory() = default;
101103
DISALLOW_COPY_AND_MOVE(RandomCIDFactory)
102104

103-
CID Generate(size_t length_hint) const override {
105+
const CID Generate(size_t length_hint) const override {
104106
DCHECK_GE(length_hint, CID::kMinLength);
105107
DCHECK_LE(length_hint, CID::kMaxLength);
106108
Mutex::ScopedLock lock(mutex_);
@@ -110,8 +112,8 @@ class RandomCIDFactory : public CID::Factory {
110112
return CID(start, length_hint);
111113
}
112114

113-
CID GenerateInto(ngtcp2_cid* cid,
114-
size_t length_hint = CID::kMaxLength) const override {
115+
const CID GenerateInto(ngtcp2_cid* cid,
116+
size_t length_hint = CID::kMaxLength) const override {
115117
DCHECK_GE(length_hint, CID::kMinLength);
116118
DCHECK_LE(length_hint, CID::kMaxLength);
117119
Mutex::ScopedLock lock(mutex_);
@@ -135,7 +137,7 @@ class RandomCIDFactory : public CID::Factory {
135137
}
136138
}
137139

138-
static constexpr int kPoolSize = 4096;
140+
static constexpr int kPoolSize = 1024 * 16;
139141
mutable int pos_ = kPoolSize;
140142
mutable uint8_t pool_[kPoolSize];
141143
mutable Mutex mutex_;
@@ -148,4 +150,5 @@ const CID::Factory& CID::Factory::random() {
148150
}
149151

150152
} // namespace node::quic
151-
#endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
153+
#endif // OPENSSL_NO_QUIC
154+
#endif // HAVE_OPENSS

src/quic/cid.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
4-
#if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
4+
55
#include <memory_tracker.h>
66
#include <ngtcp2/ngtcp2.h>
77
#include <string>
@@ -51,7 +51,7 @@ class CID final : public MemoryRetainer {
5151

5252
CID(const CID& other);
5353
CID& operator=(const CID& other);
54-
CID(CID&&) = delete;
54+
DISALLOW_MOVE(CID)
5555

5656
struct Hash final {
5757
size_t operator()(const CID& cid) const;
@@ -68,14 +68,16 @@ class CID final : public MemoryRetainer {
6868
operator bool() const;
6969
size_t length() const;
7070

71+
// Returns a hex-encoded string representation of the CID useful
72+
// for debugging.
7173
std::string ToString() const;
7274

7375
SET_NO_MEMORY_INFO()
7476
SET_MEMORY_INFO_NAME(CID)
7577
SET_SELF_SIZE(CID)
7678

7779
template <typename T>
78-
using Map = std::unordered_map<CID, T, CID::Hash>;
80+
using Map = std::unordered_map<const CID, T, CID::Hash>;
7981

8082
// A CID::Factory, as the name suggests, is used to create new CIDs.
8183
// Per https://datatracker.ietf.org/doc/draft-ietf-quic-load-balancers/, QUIC
@@ -85,13 +87,13 @@ class CID final : public MemoryRetainer {
8587
// but will allow user code to provide their own CID::Factory implementation.
8688
class Factory;
8789

88-
static CID kInvalid;
90+
static const CID kInvalid;
8991

9092
// The default constructor creates an empty, zero-length CID.
9193
// Zero-length CIDs are not usable. We use them as a placeholder
9294
// for a missing or empty CID value. This is public only because
9395
// it is required for the CID::Map implementation. It should not
94-
// be used. Use kInvalid instead.
96+
// be used directly. Use kInvalid instead.
9597
CID();
9698

9799
private:
@@ -107,12 +109,12 @@ class CID::Factory {
107109

108110
// Generate a new CID. The length_hint must be between CID::kMinLength
109111
// and CID::kMaxLength. The implementation can choose to ignore the length.
110-
virtual CID Generate(size_t length_hint = CID::kMaxLength) const = 0;
112+
virtual const CID Generate(size_t length_hint = CID::kMaxLength) const = 0;
111113

112114
// Generate a new CID into the given ngtcp2_cid. This variation of
113115
// Generate should be used far less commonly.
114-
virtual CID GenerateInto(ngtcp2_cid* cid,
115-
size_t length_hint = CID::kMaxLength) const = 0;
116+
virtual const CID GenerateInto(
117+
ngtcp2_cid* cid, size_t length_hint = CID::kMaxLength) const = 0;
116118

117119
// The default random CID generator instance.
118120
static const Factory& random();
@@ -123,5 +125,4 @@ class CID::Factory {
123125

124126
} // namespace node::quic
125127

126-
#endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
127128
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

0 commit comments

Comments
 (0)