nghttpx: Add --frontend-quic-initial-rtt option

This commit is contained in:
Tatsuhiro Tsujikawa 2021-10-10 17:24:02 +09:00
parent 07128719c4
commit 69c4187100
5 changed files with 40 additions and 0 deletions

View File

@ -197,6 +197,7 @@ OPTIONS = [
"rlimit-memlock", "rlimit-memlock",
"max-worker-processes", "max-worker-processes",
"worker-process-grace-shutdown-period", "worker-process-grace-shutdown-period",
"frontend-quic-initial-rtt",
] ]
LOGVARS = [ LOGVARS = [

View File

@ -1958,6 +1958,8 @@ void fill_default_config(Config *config) {
assert(0); assert(0);
abort(); abort();
} }
upstreamconf.initial_rtt = NGTCP2_DEFAULT_INITIAL_RTT;
} }
auto &http3conf = config->http3; auto &http3conf = config->http3;
@ -3399,6 +3401,13 @@ HTTP/3 and QUIC:
(which is 8 bytes long). If this option is omitted, a (which is 8 bytes long). If this option is omitted, a
random server ID is generated on startup and random server ID is generated on startup and
configuration reload. configuration reload.
--frontend-quic-initial-rtt=<DURATION>
Specify the initial RTT of the frontend QUIC connection.
Default: )"
<< util::duration_str(
static_cast<double>(config->quic.upstream.initial_rtt) /
NGTCP2_SECONDS)
<< R"(
--no-quic-bpf --no-quic-bpf
Disable eBPF. Disable eBPF.
--frontend-http3-window-size=<SIZE> --frontend-http3-window-size=<SIZE>
@ -4218,6 +4227,8 @@ int main(int argc, char **argv) {
{SHRPX_OPT_MAX_WORKER_PROCESSES.c_str(), required_argument, &flag, 188}, {SHRPX_OPT_MAX_WORKER_PROCESSES.c_str(), required_argument, &flag, 188},
{SHRPX_OPT_WORKER_PROCESS_GRACE_SHUTDOWN_PERIOD.c_str(), {SHRPX_OPT_WORKER_PROCESS_GRACE_SHUTDOWN_PERIOD.c_str(),
required_argument, &flag, 189}, required_argument, &flag, 189},
{SHRPX_OPT_FRONTEND_QUIC_INITIAL_RTT.c_str(), required_argument, &flag,
190},
{nullptr, 0, nullptr, 0}}; {nullptr, 0, nullptr, 0}};
int option_index = 0; int option_index = 0;
@ -5118,6 +5129,11 @@ int main(int argc, char **argv) {
cmdcfgs.emplace_back(SHRPX_OPT_WORKER_PROCESS_GRACE_SHUTDOWN_PERIOD, cmdcfgs.emplace_back(SHRPX_OPT_WORKER_PROCESS_GRACE_SHUTDOWN_PERIOD,
StringRef{optarg}); StringRef{optarg});
break; break;
case 190:
// --frontend-quic-initial-rtt
cmdcfgs.emplace_back(SHRPX_OPT_FRONTEND_QUIC_INITIAL_RTT,
StringRef{optarg});
break;
default: default:
break; break;
} }

View File

@ -2440,6 +2440,11 @@ int option_lookup_token(const char *name, size_t namelen) {
return SHRPX_OPTID_MAX_REQUEST_HEADER_FIELDS; return SHRPX_OPTID_MAX_REQUEST_HEADER_FIELDS;
} }
break; break;
case 't':
if (util::strieq_l("frontend-quic-initial-rt", name, 24)) {
return SHRPX_OPTID_FRONTEND_QUIC_INITIAL_RTT;
}
break;
} }
break; break;
case 26: case 26:
@ -4152,6 +4157,19 @@ int parse_config(Config *config, int optid, const StringRef &opt,
case SHRPX_OPTID_WORKER_PROCESS_GRACE_SHUTDOWN_PERIOD: case SHRPX_OPTID_WORKER_PROCESS_GRACE_SHUTDOWN_PERIOD:
return parse_duration(&config->worker_process_grace_shutdown_period, opt, return parse_duration(&config->worker_process_grace_shutdown_period, opt,
optarg); optarg);
case SHRPX_OPTID_FRONTEND_QUIC_INITIAL_RTT: {
#ifdef ENABLE_HTTP3
ev_tstamp d;
if (parse_duration(&d, opt, optarg) != 0) {
return -1;
}
config->quic.upstream.initial_rtt =
static_cast<ngtcp2_duration>(d * NGTCP2_SECONDS);
#endif // ENABLE_HTTP3
return 0;
}
case SHRPX_OPTID_CONF: case SHRPX_OPTID_CONF:
LOG(WARN) << "conf: ignored"; LOG(WARN) << "conf: ignored";

View File

@ -400,6 +400,8 @@ constexpr auto SHRPX_OPT_MAX_WORKER_PROCESSES =
StringRef::from_lit("max-worker-processes"); StringRef::from_lit("max-worker-processes");
constexpr auto SHRPX_OPT_WORKER_PROCESS_GRACE_SHUTDOWN_PERIOD = constexpr auto SHRPX_OPT_WORKER_PROCESS_GRACE_SHUTDOWN_PERIOD =
StringRef::from_lit("worker-process-grace-shutdown-period"); StringRef::from_lit("worker-process-grace-shutdown-period");
constexpr auto SHRPX_OPT_FRONTEND_QUIC_INITIAL_RTT =
StringRef::from_lit("frontend-quic-initial-rtt");
constexpr size_t SHRPX_OBFUSCATED_NODE_LENGTH = 8; constexpr size_t SHRPX_OBFUSCATED_NODE_LENGTH = 8;
@ -780,6 +782,7 @@ struct QUICConfig {
bool require_token; bool require_token;
std::array<uint8_t, SHRPX_QUIC_SERVER_IDLEN> server_id; std::array<uint8_t, SHRPX_QUIC_SERVER_IDLEN> server_id;
StringRef secret_file; StringRef secret_file;
ngtcp2_duration initial_rtt;
} upstream; } upstream;
struct { struct {
StringRef prog_file; StringRef prog_file;
@ -1242,6 +1245,7 @@ enum {
SHRPX_OPTID_FRONTEND_QUIC_DEBUG_LOG, SHRPX_OPTID_FRONTEND_QUIC_DEBUG_LOG,
SHRPX_OPTID_FRONTEND_QUIC_EARLY_DATA, SHRPX_OPTID_FRONTEND_QUIC_EARLY_DATA,
SHRPX_OPTID_FRONTEND_QUIC_IDLE_TIMEOUT, SHRPX_OPTID_FRONTEND_QUIC_IDLE_TIMEOUT,
SHRPX_OPTID_FRONTEND_QUIC_INITIAL_RTT,
SHRPX_OPTID_FRONTEND_QUIC_QLOG_DIR, SHRPX_OPTID_FRONTEND_QUIC_QLOG_DIR,
SHRPX_OPTID_FRONTEND_QUIC_REQUIRE_TOKEN, SHRPX_OPTID_FRONTEND_QUIC_REQUIRE_TOKEN,
SHRPX_OPTID_FRONTEND_QUIC_SECRET_FILE, SHRPX_OPTID_FRONTEND_QUIC_SECRET_FILE,

View File

@ -592,6 +592,7 @@ int Http3Upstream::init(const UpstreamAddr *faddr, const Address &remote_addr,
} }
settings.initial_ts = quic_timestamp(); settings.initial_ts = quic_timestamp();
settings.initial_rtt = quicconf.upstream.initial_rtt;
settings.cc_algo = quicconf.upstream.congestion_controller; settings.cc_algo = quicconf.upstream.congestion_controller;
settings.max_window = http3conf.upstream.max_connection_window_size; settings.max_window = http3conf.upstream.max_connection_window_size;
settings.max_stream_window = http3conf.upstream.max_window_size; settings.max_stream_window = http3conf.upstream.max_window_size;