Support both h3 and h3-29 ALPN and their corresponding QUIC versions

This commit is contained in:
Tatsuhiro Tsujikawa 2021-02-20 17:31:52 +09:00
parent 35d8ef33ef
commit 09a2e50fc2
3 changed files with 19 additions and 8 deletions

View File

@ -24,12 +24,12 @@ ngtcp2, nghttp3 and my patched OpenSSL.
https://github.com/ngtcp2/ngtcp2#build-from-git describes how to build https://github.com/ngtcp2/ngtcp2#build-from-git describes how to build
these three software. these three software.
To run h2load against HTTP/3 server, specify h3-29 ALPN with To run h2load against HTTP/3 server, specify h3 or h3-29 ALPN with
``--npn-list`` option like so: ``--npn-list`` option like so:
.. code-block:: text .. code-block:: text
$ h2load --npn-list h3-29 https://127.0.0.1:4433 $ h2load --npn-list h3 https://127.0.0.1:4433
You can use Dockerfile to skip the tedious build steps to manually You can use Dockerfile to skip the tedious build steps to manually
pull and build dependencies. In order to build Docker image, do this: pull and build dependencies. In order to build Docker image, do this:
@ -43,7 +43,7 @@ Run h2load:
.. code-block:: text .. code-block:: text
$ docker run --rm -it --network=host nghttp2-quic /usr/local/bin/h2load --npn-list h3-29 https://127.0.0.1:4433 $ docker run --rm -it --network=host nghttp2-quic /usr/local/bin/h2load --npn-list h3 https://127.0.0.1:4433
Development Status Development Status
------------------ ------------------

View File

@ -138,7 +138,8 @@ bool Config::is_timing_based_mode() const { return (this->duration > 0); }
bool Config::has_base_uri() const { return (!this->base_uri.empty()); } bool Config::has_base_uri() const { return (!this->base_uri.empty()); }
bool Config::rps_enabled() const { return this->rps > 0.0; } bool Config::rps_enabled() const { return this->rps > 0.0; }
bool Config::is_quic() const { bool Config::is_quic() const {
return !npn_list.empty() && npn_list[0] == NGHTTP3_ALPN_H3; return !npn_list.empty() &&
(npn_list[0] == NGHTTP3_ALPN_H3 || npn_list[0] == "\x5h3-29");
} }
Config config; Config config;
@ -1042,7 +1043,8 @@ int Client::connection_made() {
auto proto = StringRef{next_proto, next_proto_len}; auto proto = StringRef{next_proto, next_proto_len};
if (config.is_quic()) { if (config.is_quic()) {
assert(session); assert(session);
if (!util::streq(StringRef{&NGHTTP3_ALPN_H3[1]}, proto)) { if (!util::streq(StringRef{&NGHTTP3_ALPN_H3[1]}, proto) &&
!util::streq_l("h3-29", proto)) {
return -1; return -1;
} }
} else if (util::check_h2_is_selected(proto)) { } else if (util::check_h2_is_selected(proto)) {

View File

@ -370,9 +370,18 @@ int Client::quic_init(const sockaddr *local_addr, socklen_t local_addrlen,
{remote_addrlen, const_cast<sockaddr *>(remote_addr)}, {remote_addrlen, const_cast<sockaddr *>(remote_addr)},
}; };
rv = ngtcp2_conn_client_new(&quic.conn, &dcid, &scid, &path, assert(config->npn_list.size());
NGTCP2_PROTO_VER_MIN, &callbacks, &settings,
&params, nullptr, this); uint32_t quic_version;
if (config->npn_list[0] == NGHTTP3_ALPN_H3) {
quic_version = NGTCP2_PROTO_VER_V1;
} else {
quic_version = NGTCP2_PROTO_VER_MIN;
}
rv = ngtcp2_conn_client_new(&quic.conn, &dcid, &scid, &path, quic_version,
&callbacks, &settings, &params, nullptr, this);
if (rv != 0) { if (rv != 0) {
return -1; return -1;
} }