mirror of
https://github.com/nginx/nginx.git
synced 2026-06-29 05:12:15 +00:00
Merge 88717384cc into 42f8df65b6
This commit is contained in:
commit
356dfcdaa0
13 changed files with 1685 additions and 7 deletions
|
|
@ -1399,7 +1399,8 @@ if [ $USE_OPENSSL_QUIC = YES ]; then
|
|||
src/event/quic/ngx_event_quic_ack.h \
|
||||
src/event/quic/ngx_event_quic_output.h \
|
||||
src/event/quic/ngx_event_quic_socket.h \
|
||||
src/event/quic/ngx_event_quic_openssl_compat.h"
|
||||
src/event/quic/ngx_event_quic_openssl_compat.h \
|
||||
src/event/quic/ngx_event_quic_qlog.h"
|
||||
ngx_module_srcs="src/event/quic/ngx_event_quic.c \
|
||||
src/event/quic/ngx_event_quic_udp.c \
|
||||
src/event/quic/ngx_event_quic_transport.c \
|
||||
|
|
@ -1415,6 +1416,12 @@ if [ $USE_OPENSSL_QUIC = YES ]; then
|
|||
src/event/quic/ngx_event_quic_socket.c \
|
||||
src/event/quic/ngx_event_quic_openssl_compat.c"
|
||||
|
||||
if [ $QUIC_QLOG = YES ]; then
|
||||
ngx_module_srcs="$ngx_module_srcs \
|
||||
src/event/quic/ngx_event_quic_qlog.c"
|
||||
have=NGX_QUIC_QLOG . auto/have
|
||||
fi
|
||||
|
||||
ngx_module_libs=
|
||||
ngx_module_link=YES
|
||||
ngx_module_order=
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ USE_THREADS=NO
|
|||
NGX_FILE_AIO=NO
|
||||
|
||||
QUIC_BPF=NO
|
||||
QUIC_QLOG=NO
|
||||
|
||||
HTTP=YES
|
||||
|
||||
|
|
@ -223,6 +224,7 @@ do
|
|||
--with-file-aio) NGX_FILE_AIO=YES ;;
|
||||
|
||||
--without-quic_bpf_module) QUIC_BPF=NONE ;;
|
||||
--with-quic_qlog_module) QUIC_QLOG=YES ;;
|
||||
|
||||
--with-ipv6)
|
||||
NGX_POST_CONF_MSG="$NGX_POST_CONF_MSG
|
||||
|
|
@ -471,6 +473,7 @@ cat << END
|
|||
--with-file-aio enable file AIO support
|
||||
|
||||
--without-quic_bpf_module disable ngx_quic_bpf_module
|
||||
--with-quic_qlog_module enable QUIC qlog support
|
||||
|
||||
--with-http_ssl_module enable ngx_http_ssl_module
|
||||
--with-http_v2_module enable ngx_http_v2_module
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <ngx_event.h>
|
||||
#include <ngx_sha1.h>
|
||||
#include <ngx_event_quic_connection.h>
|
||||
#include <ngx_event_quic_qlog.h>
|
||||
|
||||
|
||||
static ngx_quic_connection_t *ngx_quic_new_connection(ngx_connection_t *c,
|
||||
|
|
@ -347,6 +348,15 @@ ngx_quic_new_connection(ngx_connection_t *c, ngx_quic_conf_t *conf,
|
|||
c->idle = 1;
|
||||
ngx_reusable_connection(c, 1);
|
||||
|
||||
if (ngx_quic_qlog_init(c, qc) == NGX_ERROR) {
|
||||
ngx_log_error(NGX_LOG_WARN, c->log, 0,
|
||||
"quic qlog init failed, continuing without qlog");
|
||||
}
|
||||
|
||||
ngx_quic_qlog_connection_started(c, qc);
|
||||
ngx_quic_qlog_transport_parameters_set(c, qc, &qc->tp,
|
||||
NGX_QUIC_QLOG_SIDE_LOCAL);
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||
"quic connection created");
|
||||
|
||||
|
|
@ -589,6 +599,9 @@ ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc)
|
|||
ngx_delete_posted_event(&qc->close);
|
||||
}
|
||||
|
||||
ngx_quic_qlog_connection_closed(c, qc);
|
||||
ngx_quic_qlog_close(qc);
|
||||
|
||||
ngx_quic_close_sockets(c);
|
||||
|
||||
ngx_quic_keys_cleanup(qc->keys);
|
||||
|
|
@ -1067,12 +1080,12 @@ ngx_quic_handle_payload(ngx_connection_t *c, ngx_quic_header_t *pkt)
|
|||
|
||||
c->log->action = "handling payload";
|
||||
|
||||
if (pkt->level != NGX_QUIC_ENCRYPTION_APPLICATION) {
|
||||
return ngx_quic_handle_frames(c, pkt);
|
||||
}
|
||||
ngx_quic_qlog_pkt_received_start(c, qc);
|
||||
|
||||
if (!pkt->key_update) {
|
||||
return ngx_quic_handle_frames(c, pkt);
|
||||
if (pkt->level != NGX_QUIC_ENCRYPTION_APPLICATION || !pkt->key_update) {
|
||||
rc = ngx_quic_handle_frames(c, pkt);
|
||||
ngx_quic_qlog_pkt_received_end(c, qc, pkt);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* switch keys and generate next on Key Phase change */
|
||||
|
|
@ -1081,6 +1094,8 @@ ngx_quic_handle_payload(ngx_connection_t *c, ngx_quic_header_t *pkt)
|
|||
ngx_quic_keys_switch(c, qc->keys);
|
||||
|
||||
rc = ngx_quic_handle_frames(c, pkt);
|
||||
ngx_quic_qlog_pkt_received_end(c, qc, pkt);
|
||||
|
||||
if (rc != NGX_OK) {
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -1210,6 +1225,7 @@ ngx_quic_handle_frames(ngx_connection_t *c, ngx_quic_header_t *pkt)
|
|||
}
|
||||
|
||||
ngx_quic_log_frame(c->log, &frame, 0);
|
||||
ngx_quic_qlog_write_frame(qc, &frame);
|
||||
|
||||
c->log->action = "handling frames";
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,12 @@
|
|||
#define NGX_QUIC_STREAM_SERVER_INITIATED 0x01
|
||||
#define NGX_QUIC_STREAM_UNIDIRECTIONAL 0x02
|
||||
|
||||
#if (NGX_QUIC_QLOG)
|
||||
#define NGX_QUIC_QLOG_LEVEL_CORE 0
|
||||
#define NGX_QUIC_QLOG_LEVEL_BASE 1
|
||||
#define NGX_QUIC_QLOG_LEVEL_EXTRA 2
|
||||
#endif
|
||||
|
||||
|
||||
typedef ngx_int_t (*ngx_quic_init_pt)(ngx_connection_t *c);
|
||||
typedef void (*ngx_quic_shutdown_pt)(ngx_connection_t *c);
|
||||
|
|
@ -94,6 +100,15 @@ typedef struct {
|
|||
ngx_int_t stream_reject_code_uni;
|
||||
ngx_int_t stream_reject_code_bidi;
|
||||
|
||||
#if (NGX_QUIC_QLOG)
|
||||
ngx_flag_t qlog_enabled;
|
||||
ngx_str_t qlog_path;
|
||||
ngx_uint_t qlog_sample_n;
|
||||
size_t qlog_max_size;
|
||||
ngx_uint_t qlog_importance;
|
||||
ngx_array_t *qlog_allow; /* array of ngx_cidr_t */
|
||||
#endif
|
||||
|
||||
ngx_quic_init_pt init;
|
||||
ngx_quic_shutdown_pt shutdown;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <ngx_core.h>
|
||||
#include <ngx_event.h>
|
||||
#include <ngx_event_quic_connection.h>
|
||||
#include <ngx_event_quic_qlog.h>
|
||||
|
||||
|
||||
#define NGX_QUIC_MAX_ACK_GAP 2
|
||||
|
|
@ -246,6 +247,8 @@ ngx_quic_rtt_sample(ngx_connection_t *c, ngx_quic_ack_frame_t *ack,
|
|||
ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||
"quic rtt sample latest:%M min:%M avg:%M var:%M",
|
||||
latest_rtt, qc->min_rtt, qc->avg_rtt, qc->rttvar);
|
||||
|
||||
ngx_quic_qlog_metrics_updated(c, qc);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -337,6 +340,8 @@ ngx_quic_handle_ack_frame_range(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx,
|
|||
|
||||
qc->pto_count = 0;
|
||||
|
||||
ngx_quic_qlog_metrics_updated(c, qc);
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
|
@ -448,6 +453,8 @@ done:
|
|||
if (blocked && cg->in_flight < cg->window) {
|
||||
ngx_post_event(&qc->push, &ngx_posted_events);
|
||||
}
|
||||
|
||||
ngx_quic_qlog_metrics_updated(c, qc);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -660,6 +667,10 @@ ngx_quic_detect_lost(ngx_connection_t *c, ngx_quic_ack_stat_t *st)
|
|||
nlost++;
|
||||
}
|
||||
|
||||
ngx_quic_qlog_pkt_lost(c, qc, ctx, start,
|
||||
(ngx_msec_int_t) wait <= 0
|
||||
? NGX_QUIC_QLOG_PKT_LOST_TIME
|
||||
: NGX_QUIC_QLOG_PKT_LOST_REORDERING);
|
||||
ngx_quic_resend_frames(c, ctx);
|
||||
}
|
||||
}
|
||||
|
|
@ -721,6 +732,8 @@ ngx_quic_persistent_congestion(ngx_connection_t *c)
|
|||
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||
"quic congestion persistent t:%M win:%uz",
|
||||
ngx_current_msec, cg->window);
|
||||
|
||||
ngx_quic_qlog_metrics_updated(c, qc);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -921,6 +934,8 @@ done:
|
|||
if (blocked && cg->in_flight < cg->window) {
|
||||
ngx_post_event(&qc->push, &ngx_posted_events);
|
||||
}
|
||||
|
||||
ngx_quic_qlog_metrics_updated(c, qc);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1163,6 +1178,8 @@ ngx_quic_pto_handler(ngx_event_t *ev)
|
|||
|
||||
qc->pto_count++;
|
||||
|
||||
ngx_quic_qlog_metrics_updated(c, qc);
|
||||
|
||||
ngx_quic_set_lost_timer(c);
|
||||
|
||||
ngx_quic_connstate_dbg(c);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ typedef struct ngx_quic_send_ctx_s ngx_quic_send_ctx_t;
|
|||
typedef struct ngx_quic_socket_s ngx_quic_socket_t;
|
||||
typedef struct ngx_quic_path_s ngx_quic_path_t;
|
||||
typedef struct ngx_quic_keys_s ngx_quic_keys_t;
|
||||
#if (NGX_QUIC_QLOG)
|
||||
typedef struct ngx_quic_qlog_s ngx_quic_qlog_t;
|
||||
#endif
|
||||
|
||||
#if (NGX_QUIC_OPENSSL_COMPAT)
|
||||
#include <ngx_event_quic_openssl_compat.h>
|
||||
|
|
@ -247,6 +250,10 @@ struct ngx_quic_connection_s {
|
|||
|
||||
ngx_quic_conf_t *conf;
|
||||
|
||||
#if (NGX_QUIC_QLOG)
|
||||
ngx_quic_qlog_t *qlog;
|
||||
#endif
|
||||
|
||||
ngx_event_t push;
|
||||
ngx_event_t pto;
|
||||
ngx_event_t close;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <ngx_core.h>
|
||||
#include <ngx_event.h>
|
||||
#include <ngx_event_quic_connection.h>
|
||||
#include <ngx_event_quic_qlog.h>
|
||||
|
||||
|
||||
#define NGX_QUIC_PATH_MTU_DELAY 100
|
||||
|
|
@ -190,6 +191,8 @@ valid:
|
|||
qc->congestion.recovery_start = ngx_current_msec - 1;
|
||||
|
||||
ngx_quic_init_rtt(qc);
|
||||
|
||||
ngx_quic_qlog_metrics_updated(c, qc);
|
||||
}
|
||||
|
||||
path->validated = 1;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <ngx_core.h>
|
||||
#include <ngx_event.h>
|
||||
#include <ngx_event_quic_connection.h>
|
||||
#include <ngx_event_quic_qlog.h>
|
||||
|
||||
|
||||
#define NGX_QUIC_MAX_UDP_SEGMENT_BUF 65487 /* 65K - IPv6 header */
|
||||
|
|
@ -230,6 +231,7 @@ ngx_quic_commit_send(ngx_connection_t *c)
|
|||
|
||||
cg->in_flight += f->plen;
|
||||
|
||||
ngx_quic_qlog_metrics_updated(c, qc);
|
||||
} else {
|
||||
ngx_quic_free_frame(c, f);
|
||||
}
|
||||
|
|
@ -570,6 +572,8 @@ ngx_quic_output_packet(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx,
|
|||
|
||||
ngx_quic_init_packet(c, ctx, &pkt, qc->path);
|
||||
|
||||
ngx_quic_qlog_pkt_sent_start(c, qc);
|
||||
|
||||
min_payload = ngx_quic_payload_size(&pkt, min);
|
||||
max_payload = ngx_quic_payload_size(&pkt, max);
|
||||
|
||||
|
|
@ -621,6 +625,7 @@ ngx_quic_output_packet(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx,
|
|||
f->plen = 0;
|
||||
|
||||
ngx_quic_log_frame(c->log, f, 1);
|
||||
ngx_quic_qlog_write_frame(qc, f);
|
||||
|
||||
flen = ngx_quic_create_frame(p, f);
|
||||
if (flen == -1) {
|
||||
|
|
@ -653,6 +658,9 @@ ngx_quic_output_packet(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx,
|
|||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
pkt.len = res.len;
|
||||
ngx_quic_qlog_pkt_sent_end(c, qc, &pkt);
|
||||
|
||||
ctx->pnum++;
|
||||
|
||||
if (pkt.need_ack) {
|
||||
|
|
@ -1350,6 +1358,12 @@ ngx_quic_frame_sendto(ngx_connection_t *c, ngx_quic_frame_t *frame,
|
|||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
pkt.len = res.len;
|
||||
|
||||
ngx_quic_qlog_pkt_sent_start(c, qc);
|
||||
ngx_quic_qlog_write_frame(qc, frame);
|
||||
ngx_quic_qlog_pkt_sent_end(c, qc, &pkt);
|
||||
|
||||
frame->pnum = ctx->pnum;
|
||||
frame->send_time = now;
|
||||
frame->plen = res.len;
|
||||
|
|
@ -1368,6 +1382,7 @@ ngx_quic_frame_sendto(ngx_connection_t *c, ngx_quic_frame_t *frame,
|
|||
ngx_queue_insert_tail(&ctx->sent, &frame->queue);
|
||||
|
||||
cg->in_flight += frame->plen;
|
||||
ngx_quic_qlog_metrics_updated(c, qc);
|
||||
|
||||
} else {
|
||||
ngx_quic_free_frame(c, frame);
|
||||
|
|
|
|||
1363
src/event/quic/ngx_event_quic_qlog.c
Normal file
1363
src/event/quic/ngx_event_quic_qlog.c
Normal file
File diff suppressed because it is too large
Load diff
76
src/event/quic/ngx_event_quic_qlog.h
Normal file
76
src/event/quic/ngx_event_quic_qlog.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (C) Nginx, Inc.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _NGX_EVENT_QUIC_QLOG_H_INCLUDED_
|
||||
#define _NGX_EVENT_QUIC_QLOG_H_INCLUDED_
|
||||
|
||||
#include <ngx_config.h>
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_event_quic.h>
|
||||
#include <ngx_event_quic_connection.h>
|
||||
|
||||
|
||||
typedef enum {
|
||||
NGX_QUIC_QLOG_SIDE_LOCAL = 0,
|
||||
NGX_QUIC_QLOG_SIDE_REMOTE
|
||||
} ngx_quic_qlog_side_e;
|
||||
|
||||
|
||||
typedef enum {
|
||||
NGX_QUIC_QLOG_PKT_LOST_TIME = 0,
|
||||
NGX_QUIC_QLOG_PKT_LOST_REORDERING
|
||||
} ngx_quic_qlog_pkt_lost_e;
|
||||
|
||||
|
||||
#if (NGX_QUIC_QLOG)
|
||||
|
||||
typedef struct ngx_quic_qlog_s ngx_quic_qlog_t;
|
||||
|
||||
|
||||
ngx_int_t ngx_quic_qlog_init(ngx_connection_t *c, ngx_quic_connection_t *qc);
|
||||
void ngx_quic_qlog_close(ngx_quic_connection_t *qc);
|
||||
|
||||
void ngx_quic_qlog_connection_started(ngx_connection_t *c,
|
||||
ngx_quic_connection_t *qc);
|
||||
void ngx_quic_qlog_connection_closed(ngx_connection_t *c,
|
||||
ngx_quic_connection_t *qc);
|
||||
void ngx_quic_qlog_transport_parameters_set(ngx_connection_t *c,
|
||||
ngx_quic_connection_t *qc, ngx_quic_tp_t *params,
|
||||
ngx_quic_qlog_side_e side);
|
||||
void ngx_quic_qlog_metrics_updated(ngx_connection_t *c,
|
||||
ngx_quic_connection_t *qc);
|
||||
void ngx_quic_qlog_pkt_lost(ngx_connection_t *c, ngx_quic_connection_t *qc,
|
||||
ngx_quic_send_ctx_t *ctx, ngx_quic_frame_t *start,
|
||||
ngx_quic_qlog_pkt_lost_e trigger);
|
||||
|
||||
void ngx_quic_qlog_pkt_received_start(ngx_connection_t *c,
|
||||
ngx_quic_connection_t *qc);
|
||||
void ngx_quic_qlog_pkt_received_end(ngx_connection_t *c,
|
||||
ngx_quic_connection_t *qc, ngx_quic_header_t *pkt);
|
||||
void ngx_quic_qlog_pkt_sent_start(ngx_connection_t *c,
|
||||
ngx_quic_connection_t *qc);
|
||||
void ngx_quic_qlog_pkt_sent_end(ngx_connection_t *c, ngx_quic_connection_t *qc,
|
||||
ngx_quic_header_t *pkt);
|
||||
void ngx_quic_qlog_write_frame(ngx_quic_connection_t *qc, ngx_quic_frame_t *f);
|
||||
|
||||
#else /* NGX_QUIC_QLOG */
|
||||
|
||||
#define ngx_quic_qlog_init(c, qc) NGX_OK
|
||||
#define ngx_quic_qlog_close(qc)
|
||||
#define ngx_quic_qlog_connection_started(c, qc)
|
||||
#define ngx_quic_qlog_connection_closed(c, qc)
|
||||
#define ngx_quic_qlog_transport_parameters_set(c, qc, params, side)
|
||||
#define ngx_quic_qlog_metrics_updated(c, qc)
|
||||
#define ngx_quic_qlog_pkt_lost(c, qc, ctx, start, trigger)
|
||||
#define ngx_quic_qlog_pkt_received_start(c, qc)
|
||||
#define ngx_quic_qlog_pkt_received_end(c, qc, pkt)
|
||||
#define ngx_quic_qlog_pkt_sent_start(c, qc)
|
||||
#define ngx_quic_qlog_pkt_sent_end(c, qc, pkt)
|
||||
#define ngx_quic_qlog_write_frame(qc, f)
|
||||
|
||||
#endif /* NGX_QUIC_QLOG */
|
||||
|
||||
|
||||
#endif /* _NGX_EVENT_QUIC_QLOG_H_INCLUDED_ */
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
#include <ngx_core.h>
|
||||
#include <ngx_event.h>
|
||||
#include <ngx_event_quic_connection.h>
|
||||
#include <ngx_event_quic_qlog.h>
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -287,6 +288,9 @@ ngx_quic_cbs_got_transport_params(ngx_ssl_conn_t *ssl_conn,
|
|||
return 1;
|
||||
}
|
||||
|
||||
ngx_quic_qlog_transport_parameters_set(c, qc, &ctp,
|
||||
NGX_QUIC_QLOG_SIDE_REMOTE);
|
||||
|
||||
if (ngx_quic_apply_transport_params(c, &ctp) != NGX_OK) {
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -544,6 +548,9 @@ ngx_quic_add_handshake_data(ngx_ssl_conn_t *ssl_conn,
|
|||
return 1;
|
||||
}
|
||||
|
||||
ngx_quic_qlog_transport_parameters_set(c, qc, &ctp,
|
||||
NGX_QUIC_QLOG_SIDE_REMOTE);
|
||||
|
||||
if (ngx_quic_apply_transport_params(c, &ctp) != NGX_OK) {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1143,8 +1143,9 @@ ngx_quic_parse_frame(ngx_quic_header_t *pkt, u_char *start, u_char *end,
|
|||
#if (NGX_DEBUG)
|
||||
f->pnum = pkt->pn;
|
||||
#endif
|
||||
f->len = p - start;
|
||||
|
||||
return p - start;
|
||||
return f->len;
|
||||
|
||||
error:
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,18 @@ static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent,
|
|||
void *child);
|
||||
static char *ngx_http_quic_host_key(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
void *conf);
|
||||
#if (NGX_QUIC_QLOG)
|
||||
static char *ngx_http_quic_qlog_allow(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
void *conf);
|
||||
|
||||
|
||||
static ngx_conf_enum_t ngx_http_quic_qlog_importance[] = {
|
||||
{ ngx_string("core"), NGX_QUIC_QLOG_LEVEL_CORE },
|
||||
{ ngx_string("base"), NGX_QUIC_QLOG_LEVEL_BASE },
|
||||
{ ngx_string("extra"), NGX_QUIC_QLOG_LEVEL_EXTRA },
|
||||
{ ngx_null_string, 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
static ngx_command_t ngx_http_v3_commands[] = {
|
||||
|
|
@ -78,6 +90,50 @@ static ngx_command_t ngx_http_v3_commands[] = {
|
|||
offsetof(ngx_http_v3_srv_conf_t, quic.active_connection_id_limit),
|
||||
NULL },
|
||||
|
||||
#if (NGX_QUIC_QLOG)
|
||||
{ ngx_string("quic_qlog"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
|
||||
ngx_conf_set_flag_slot,
|
||||
NGX_HTTP_SRV_CONF_OFFSET,
|
||||
offsetof(ngx_http_v3_srv_conf_t, quic.qlog_enabled),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("quic_qlog_path"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_str_slot,
|
||||
NGX_HTTP_SRV_CONF_OFFSET,
|
||||
offsetof(ngx_http_v3_srv_conf_t, quic.qlog_path),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("quic_qlog_importance"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_enum_slot,
|
||||
NGX_HTTP_SRV_CONF_OFFSET,
|
||||
offsetof(ngx_http_v3_srv_conf_t, quic.qlog_importance),
|
||||
&ngx_http_quic_qlog_importance },
|
||||
|
||||
{ ngx_string("quic_qlog_sample"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_num_slot,
|
||||
NGX_HTTP_SRV_CONF_OFFSET,
|
||||
offsetof(ngx_http_v3_srv_conf_t, quic.qlog_sample_n),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("quic_qlog_max_size"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_size_slot,
|
||||
NGX_HTTP_SRV_CONF_OFFSET,
|
||||
offsetof(ngx_http_v3_srv_conf_t, quic.qlog_max_size),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("quic_qlog_allow"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
||||
ngx_http_quic_qlog_allow,
|
||||
NGX_HTTP_SRV_CONF_OFFSET,
|
||||
0,
|
||||
NULL },
|
||||
#endif
|
||||
|
||||
ngx_null_command
|
||||
};
|
||||
|
||||
|
|
@ -194,6 +250,8 @@ ngx_http_v3_create_srv_conf(ngx_conf_t *cf)
|
|||
* h3scf->quic.disable_active_migration = 0;
|
||||
* h3scf->quic.idle_timeout = 0;
|
||||
* h3scf->max_blocked_streams = 0;
|
||||
* (NGX_QUIC_QLOG) h3scf->quic.qlog_path = { 0, NULL }
|
||||
* (NGX_QUIC_QLOG) h3scf->quic.qlog_allow = NULL;
|
||||
*/
|
||||
|
||||
h3scf->enable = NGX_CONF_UNSET;
|
||||
|
|
@ -210,6 +268,13 @@ ngx_http_v3_create_srv_conf(ngx_conf_t *cf)
|
|||
h3scf->quic.stream_reject_code_bidi = NGX_HTTP_V3_ERR_REQUEST_REJECTED;
|
||||
h3scf->quic.active_connection_id_limit = NGX_CONF_UNSET_UINT;
|
||||
|
||||
#if (NGX_QUIC_QLOG)
|
||||
h3scf->quic.qlog_enabled = NGX_CONF_UNSET;
|
||||
h3scf->quic.qlog_importance = NGX_CONF_UNSET_UINT;
|
||||
h3scf->quic.qlog_sample_n = NGX_CONF_UNSET_UINT;
|
||||
h3scf->quic.qlog_max_size = NGX_CONF_UNSET_SIZE;
|
||||
#endif
|
||||
|
||||
h3scf->quic.init = ngx_http_v3_init;
|
||||
h3scf->quic.shutdown = ngx_http_v3_shutdown;
|
||||
|
||||
|
|
@ -250,6 +315,42 @@ ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
prev->quic.active_connection_id_limit,
|
||||
2);
|
||||
|
||||
#if (NGX_QUIC_QLOG)
|
||||
ngx_conf_merge_value(conf->quic.qlog_enabled, prev->quic.qlog_enabled, 0);
|
||||
ngx_conf_merge_str_value(conf->quic.qlog_path, prev->quic.qlog_path, "");
|
||||
ngx_conf_merge_uint_value(conf->quic.qlog_importance,
|
||||
prev->quic.qlog_importance,
|
||||
NGX_QUIC_QLOG_LEVEL_BASE);
|
||||
ngx_conf_merge_uint_value(conf->quic.qlog_sample_n,
|
||||
prev->quic.qlog_sample_n,
|
||||
1);
|
||||
ngx_conf_merge_size_value(conf->quic.qlog_max_size,
|
||||
prev->quic.qlog_max_size,
|
||||
0);
|
||||
|
||||
if (conf->quic.qlog_sample_n < 1) {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"quic_qlog_sample must be at least 1");
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (conf->quic.qlog_allow == NULL) {
|
||||
conf->quic.qlog_allow = prev->quic.qlog_allow;
|
||||
}
|
||||
|
||||
if (conf->quic.qlog_path.len) {
|
||||
if (ngx_conf_full_name(cf->cycle, &conf->quic.qlog_path, 0) != NGX_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (conf->quic.qlog_enabled && conf->quic.qlog_path.len == 0) {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"quic_qlog enabled but quic_qlog_path is not set");
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (conf->quic.host_key.len == 0) {
|
||||
|
||||
conf->quic.host_key.len = NGX_QUIC_DEFAULT_HOST_KEY_LEN;
|
||||
|
|
@ -391,3 +492,50 @@ failed:
|
|||
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
|
||||
#if (NGX_QUIC_QLOG)
|
||||
|
||||
static char *
|
||||
ngx_http_quic_qlog_allow(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
ngx_http_v3_srv_conf_t *h3scf = conf;
|
||||
|
||||
ngx_int_t rc;
|
||||
ngx_str_t *value;
|
||||
ngx_cidr_t cidr, *pcidr;
|
||||
|
||||
if (h3scf->quic.qlog_allow == NULL) {
|
||||
h3scf->quic.qlog_allow = ngx_array_create(cf->pool, 2,
|
||||
sizeof(ngx_cidr_t));
|
||||
if (h3scf->quic.qlog_allow == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
value = cf->args->elts;
|
||||
|
||||
rc = ngx_ptocidr(&value[1], &cidr);
|
||||
if (rc == NGX_ERROR) {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"invalid parameter \"%V\"", &value[1]);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (rc == NGX_DONE) {
|
||||
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
||||
"low address bits of %V are meaningless",
|
||||
&value[1]);
|
||||
}
|
||||
|
||||
pcidr = ngx_array_push(h3scf->quic.qlog_allow);
|
||||
if (pcidr == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
*pcidr = cidr;
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
#endif /* NGX_QUIC_QLOG */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue