Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
95601d31
Commit
95601d31
authored
Aug 31, 2021
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Utilize the latest ngtcp2 features
parent
0566a583
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
src/shrpx_http3_upstream.cc
src/shrpx_http3_upstream.cc
+13
-12
src/shrpx_quic.h
src/shrpx_quic.h
+1
-1
src/shrpx_quic_connection_handler.cc
src/shrpx_quic_connection_handler.cc
+3
-3
No files found.
src/shrpx_http3_upstream.cc
View file @
95601d31
...
...
@@ -507,7 +507,8 @@ int Http3Upstream::init(const UpstreamAddr *faddr, const Address &remote_addr,
settings
.
cc_algo
=
NGTCP2_CC_ALGO_BBR
;
settings
.
max_window
=
http3conf
.
upstream
.
max_connection_window_size
;
settings
.
max_stream_window
=
http3conf
.
upstream
.
max_window_size
;
settings
.
max_udp_payload_size
=
SHRPX_MAX_UDP_PAYLOAD_SIZE
;
settings
.
max_udp_payload_size
=
SHRPX_QUIC_MAX_UDP_PAYLOAD_SIZE
;
settings
.
assume_symmetric_path
=
1
;
settings
.
rand_ctx
.
native_handle
=
&
worker
->
get_randgen
();
settings
.
token
=
ngtcp2_vec
{
const_cast
<
uint8_t
*>
(
token
),
tokenlen
};
...
...
@@ -581,9 +582,10 @@ int Http3Upstream::on_write() {
int
Http3Upstream
::
write_streams
()
{
std
::
array
<
nghttp3_vec
,
16
>
vec
;
std
::
array
<
uint8_t
,
64
_k
>
buf
;
auto
max_udp_payload_size
=
ngtcp2_conn_get_path_max_udp_payload_size
(
conn_
);
size_t
max_pktcnt
=
std
::
min
(
static_cast
<
size_t
>
(
64
_k
),
ngtcp2_conn_get_send_quantum
(
conn_
))
/
SHRPX_MAX_UDP_PAYLOAD_SIZE
;
max_udp_payload_size
;
ngtcp2_pkt_info
pi
;
uint8_t
*
bufpos
=
buf
.
data
();
ngtcp2_path_storage
ps
,
prev_ps
;
...
...
@@ -620,8 +622,8 @@ int Http3Upstream::write_streams() {
}
auto
nwrite
=
ngtcp2_conn_writev_stream
(
conn_
,
&
ps
.
path
,
&
pi
,
bufpos
,
SHRPX_MAX_UDP_PAYLOAD_SIZE
,
&
ndatalen
,
flags
,
stream_id
,
reinterpret_cast
<
const
ngtcp2_vec
*>
(
v
),
vcnt
,
ts
);
conn_
,
&
ps
.
path
,
&
pi
,
bufpos
,
max_udp_payload_size
,
&
ndatalen
,
flags
,
stream_id
,
reinterpret_cast
<
const
ngtcp2_vec
*>
(
v
),
vcnt
,
ts
);
if
(
nwrite
<
0
)
{
switch
(
nwrite
)
{
case
NGTCP2_ERR_STREAM_DATA_BLOCKED
:
...
...
@@ -678,8 +680,7 @@ int Http3Upstream::write_streams() {
quic_send_packet
(
static_cast
<
UpstreamAddr
*>
(
prev_ps
.
path
.
user_data
),
prev_ps
.
path
.
remote
.
addr
,
prev_ps
.
path
.
remote
.
addrlen
,
prev_ps
.
path
.
local
.
addr
,
prev_ps
.
path
.
local
.
addrlen
,
buf
.
data
(),
bufpos
-
buf
.
data
(),
SHRPX_MAX_UDP_PAYLOAD_SIZE
);
buf
.
data
(),
bufpos
-
buf
.
data
(),
max_udp_payload_size
);
ngtcp2_conn_update_pkt_tx_time
(
conn_
,
ts
);
reset_idle_timer
();
...
...
@@ -700,12 +701,12 @@ int Http3Upstream::write_streams() {
prev_ps
.
path
.
remote
.
addr
,
prev_ps
.
path
.
remote
.
addrlen
,
prev_ps
.
path
.
local
.
addr
,
prev_ps
.
path
.
local
.
addrlen
,
buf
.
data
(),
bufpos
-
buf
.
data
()
-
nwrite
,
SHRPX_MAX_UDP_PAYLOAD_SIZE
);
max_udp_payload_size
);
quic_send_packet
(
static_cast
<
UpstreamAddr
*>
(
ps
.
path
.
user_data
),
ps
.
path
.
remote
.
addr
,
ps
.
path
.
remote
.
addrlen
,
ps
.
path
.
local
.
addr
,
ps
.
path
.
local
.
addrlen
,
bufpos
-
nwrite
,
nwrite
,
SHRPX_MAX_UDP_PAYLOAD_SIZE
);
bufpos
-
nwrite
,
nwrite
,
max_udp_payload_size
);
ngtcp2_conn_update_pkt_tx_time
(
conn_
,
ts
);
reset_idle_timer
();
...
...
@@ -716,11 +717,11 @@ int Http3Upstream::write_streams() {
}
if
(
++
pktcnt
==
max_pktcnt
||
static_cast
<
size_t
>
(
nwrite
)
<
SHRPX_MAX_UDP_PAYLOAD_SIZE
)
{
static_cast
<
size_t
>
(
nwrite
)
<
max_udp_payload_size
)
{
quic_send_packet
(
static_cast
<
UpstreamAddr
*>
(
ps
.
path
.
user_data
),
ps
.
path
.
remote
.
addr
,
ps
.
path
.
remote
.
addrlen
,
ps
.
path
.
local
.
addr
,
ps
.
path
.
local
.
addrlen
,
buf
.
data
(),
bufpos
-
buf
.
data
(),
SHRPX_MAX_UDP_PAYLOAD_SIZE
);
bufpos
-
buf
.
data
(),
max_udp_payload_size
);
ngtcp2_conn_update_pkt_tx_time
(
conn_
,
ts
);
reset_idle_timer
();
...
...
@@ -1241,7 +1242,7 @@ void Http3Upstream::on_handler_delete() {
!
ngtcp2_conn_is_in_draining_period
(
conn_
))
{
ngtcp2_path_storage
ps
;
ngtcp2_pkt_info
pi
;
std
::
array
<
uint8_t
,
SHRPX_MAX_UDP_PAYLOAD_SIZE
>
buf
;
std
::
array
<
uint8_t
,
NGTCP2_DEFAULT_MAX_PKTLEN
>
buf
;
ngtcp2_path_storage_zero
(
&
ps
);
...
...
@@ -1529,7 +1530,7 @@ int Http3Upstream::handle_error() {
auto
ts
=
quic_timestamp
();
std
::
array
<
uint8_t
,
SHRPX_MAX_UDP_PAYLOAD_SIZE
>
buf
;
std
::
array
<
uint8_t
,
NGTCP2_DEFAULT_MAX_PKTLEN
>
buf
;
ngtcp2_ssize
nwrite
;
if
(
last_error_
.
type
==
quic
::
ErrorType
::
Transport
)
{
...
...
src/shrpx_quic.h
View file @
95601d31
...
...
@@ -37,7 +37,7 @@ struct UpstreamAddr;
constexpr
size_t
SHRPX_QUIC_SCIDLEN
=
20
;
constexpr
size_t
SHRPX_QUIC_CID_PREFIXLEN
=
8
;
constexpr
size_t
SHRPX_
MAX_UDP_PAYLOAD_SIZE
=
NGTCP2_MAX_PKTLEN_IPV4
;
constexpr
size_t
SHRPX_
QUIC_MAX_UDP_PAYLOAD_SIZE
=
1472
;
constexpr
size_t
SHRPX_QUIC_STATELESS_RESET_SECRETLEN
=
32
;
constexpr
size_t
SHRPX_QUIC_TOKEN_SECRETLEN
=
32
;
constexpr
size_t
SHRPX_QUIC_TOKEN_RAND_DATALEN
=
16
;
...
...
src/shrpx_quic_connection_handler.cc
View file @
95601d31
...
...
@@ -315,7 +315,7 @@ int QUICConnectionHandler::send_retry(
return
-
1
;
}
std
::
array
<
uint8_t
,
SHRPX_MAX_UDP_PAYLOAD_SIZE
>
buf
;
std
::
array
<
uint8_t
,
NGTCP2_DEFAULT_MAX_PKTLEN
>
buf
;
auto
nwrite
=
ngtcp2_crypto_write_retry
(
buf
.
data
(),
buf
.
size
(),
version
,
&
iscid
,
...
...
@@ -339,7 +339,7 @@ int QUICConnectionHandler::send_version_negotiation(
sv
[
0
]
=
generate_reserved_version
(
remote_addr
,
version
);
sv
[
1
]
=
NGTCP2_PROTO_VER_V1
;
std
::
array
<
uint8_t
,
SHRPX_MAX_UDP_PAYLOAD_SIZE
>
buf
;
std
::
array
<
uint8_t
,
NGTCP2_DEFAULT_MAX_PKTLEN
>
buf
;
uint8_t
rand_byte
;
util
::
random_bytes
(
&
rand_byte
,
&
rand_byte
+
1
,
worker_
->
get_randgen
());
...
...
@@ -384,7 +384,7 @@ int QUICConnectionHandler::send_stateless_reset(const UpstreamAddr *faddr,
return
-
1
;
}
std
::
array
<
uint8_t
,
SHRPX_MAX_UDP_PAYLOAD_SIZE
>
buf
;
std
::
array
<
uint8_t
,
NGTCP2_DEFAULT_MAX_PKTLEN
>
buf
;
auto
nwrite
=
ngtcp2_pkt_write_stateless_reset
(
buf
.
data
(),
buf
.
size
(),
token
.
data
(),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment