mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
MINOR: quic: add format argument for "show quic"
Add an extra optional argument for "show quic" to specify desired output format. Its objective is to control the verbosity per connections. For the moment, only "full" is supported, which is the already implemented output with maximum information. This should be backported up to 2.7.
This commit is contained in:
parent
4537ac115a
commit
bc1f5fed72
@ -2984,11 +2984,14 @@ show resolvers [<resolvers section id>]
|
||||
too_big: too big response
|
||||
outdated: number of response arrived too late (after another name server)
|
||||
|
||||
show quic [all]
|
||||
show quic [<format>] [all]
|
||||
Dump information on all active QUIC frontend connections. This command is
|
||||
restricted and can only be issued on sockets configured for levels "operator"
|
||||
or "admin". By default, connections on closing or draining state are not
|
||||
displayed. Use the extra argument "all" to include them in the output.
|
||||
or "admin". An optional format can be specified as first argument to control
|
||||
the verbosity. Currently only supported value is "full" which is the default
|
||||
if format is unspecified. By default, connections on closing or draining
|
||||
state are not displayed. Use the extra argument "all" to include them in the
|
||||
output.
|
||||
|
||||
show servers conn [<backend>]
|
||||
Dump the current and idle connections state of the servers belonging to the
|
||||
|
166
src/quic_conn.c
166
src/quic_conn.c
@ -8595,12 +8595,17 @@ void qc_finalize_affinity_rebind(struct quic_conn *qc)
|
||||
TRACE_LEAVE(QUIC_EV_CONN_SET_AFFINITY, qc);
|
||||
}
|
||||
|
||||
enum quic_dump_format {
|
||||
QUIC_DUMP_FMT_FULL,
|
||||
};
|
||||
|
||||
/* appctx context used by "show quic" command */
|
||||
struct show_quic_ctx {
|
||||
unsigned int epoch;
|
||||
struct bref bref; /* back-reference to the quic-conn being dumped */
|
||||
unsigned int thr;
|
||||
int flags;
|
||||
enum quic_dump_format format;
|
||||
};
|
||||
|
||||
#define QC_CLI_FL_SHOW_ALL 0x1 /* show closing/draining connections */
|
||||
@ -8608,6 +8613,7 @@ struct show_quic_ctx {
|
||||
static int cli_parse_show_quic(char **args, char *payload, struct appctx *appctx, void *private)
|
||||
{
|
||||
struct show_quic_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
|
||||
int argc = 2;
|
||||
|
||||
if (!cli_has_level(appctx, ACCESS_LVL_OPER))
|
||||
return 1;
|
||||
@ -8615,91 +8621,35 @@ static int cli_parse_show_quic(char **args, char *payload, struct appctx *appctx
|
||||
ctx->epoch = _HA_ATOMIC_FETCH_ADD(&qc_epoch, 1);
|
||||
ctx->thr = 0;
|
||||
ctx->flags = 0;
|
||||
ctx->format = QUIC_DUMP_FMT_FULL;
|
||||
|
||||
if (*args[2] && strcmp(args[2], "all") == 0)
|
||||
if (strcmp(args[argc], "full") == 0) {
|
||||
/* format already used as default value */
|
||||
++argc;
|
||||
}
|
||||
|
||||
while (*args[argc]) {
|
||||
if (strcmp(args[argc], "all") == 0)
|
||||
ctx->flags |= QC_CLI_FL_SHOW_ALL;
|
||||
|
||||
++argc;
|
||||
}
|
||||
|
||||
LIST_INIT(&ctx->bref.users);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cli_io_handler_dump_quic(struct appctx *appctx)
|
||||
/* Dump for "show quic" with "full" format. */
|
||||
static void dump_quic_full(struct show_quic_ctx *ctx, struct quic_conn *qc)
|
||||
{
|
||||
struct show_quic_ctx *ctx = appctx->svcctx;
|
||||
struct stconn *sc = appctx_sc(appctx);
|
||||
struct quic_conn *qc;
|
||||
struct quic_pktns *pktns;
|
||||
struct eb64_node *node;
|
||||
struct qc_stream_desc *stream;
|
||||
char bufaddr[INET6_ADDRSTRLEN], bufport[6];
|
||||
int expire;
|
||||
int expire, i;
|
||||
unsigned char cid_len;
|
||||
|
||||
thread_isolate();
|
||||
|
||||
if (ctx->thr >= global.nbthread)
|
||||
goto done;
|
||||
|
||||
/* FIXME: Don't watch the other side !*/
|
||||
if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUT_DONE)) {
|
||||
/* If we're forced to shut down, we might have to remove our
|
||||
* reference to the last stream being dumped.
|
||||
*/
|
||||
if (!LIST_ISEMPTY(&ctx->bref.users))
|
||||
LIST_DEL_INIT(&ctx->bref.users);
|
||||
goto done;
|
||||
}
|
||||
|
||||
chunk_reset(&trash);
|
||||
|
||||
if (!LIST_ISEMPTY(&ctx->bref.users)) {
|
||||
/* Remove show_quic_ctx from previous quic_conn instance. */
|
||||
LIST_DEL_INIT(&ctx->bref.users);
|
||||
}
|
||||
else if (!ctx->bref.ref) {
|
||||
/* First invocation. */
|
||||
ctx->bref.ref = ha_thread_ctx[ctx->thr].quic_conns.n;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
int done = 0;
|
||||
int i;
|
||||
|
||||
if (ctx->bref.ref == &ha_thread_ctx[ctx->thr].quic_conns) {
|
||||
/* If closing connections requested through "all", move
|
||||
* to quic_conns_clo list after browsing quic_conns.
|
||||
* Else move directly to the next quic_conns thread.
|
||||
*/
|
||||
if (ctx->flags & QC_CLI_FL_SHOW_ALL) {
|
||||
ctx->bref.ref = ha_thread_ctx[ctx->thr].quic_conns_clo.n;
|
||||
continue;
|
||||
}
|
||||
|
||||
done = 1;
|
||||
}
|
||||
else if (ctx->bref.ref == &ha_thread_ctx[ctx->thr].quic_conns_clo) {
|
||||
/* Closing list entirely browsed, go to next quic_conns
|
||||
* thread.
|
||||
*/
|
||||
done = 1;
|
||||
}
|
||||
else {
|
||||
/* Retrieve next element of the current list. */
|
||||
qc = LIST_ELEM(ctx->bref.ref, struct quic_conn *, el_th_ctx);
|
||||
if ((int)(qc->qc_epoch - ctx->epoch) > 0)
|
||||
done = 1;
|
||||
}
|
||||
|
||||
if (done) {
|
||||
++ctx->thr;
|
||||
if (ctx->thr >= global.nbthread)
|
||||
break;
|
||||
/* Switch to next thread quic_conns list. */
|
||||
ctx->bref.ref = ha_thread_ctx[ctx->thr].quic_conns.n;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* CIDs */
|
||||
chunk_appendf(&trash, "* %p[%02u]: scid=", qc, ctx->thr);
|
||||
for (cid_len = 0; cid_len < qc->scid.len; ++cid_len)
|
||||
@ -8797,6 +8747,82 @@ static int cli_io_handler_dump_quic(struct appctx *appctx)
|
||||
}
|
||||
|
||||
chunk_appendf(&trash, "\n");
|
||||
}
|
||||
|
||||
static int cli_io_handler_dump_quic(struct appctx *appctx)
|
||||
{
|
||||
struct show_quic_ctx *ctx = appctx->svcctx;
|
||||
struct stconn *sc = appctx_sc(appctx);
|
||||
struct quic_conn *qc;
|
||||
|
||||
thread_isolate();
|
||||
|
||||
if (ctx->thr >= global.nbthread)
|
||||
goto done;
|
||||
|
||||
/* FIXME: Don't watch the other side !*/
|
||||
if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUT_DONE)) {
|
||||
/* If we're forced to shut down, we might have to remove our
|
||||
* reference to the last stream being dumped.
|
||||
*/
|
||||
if (!LIST_ISEMPTY(&ctx->bref.users))
|
||||
LIST_DEL_INIT(&ctx->bref.users);
|
||||
goto done;
|
||||
}
|
||||
|
||||
chunk_reset(&trash);
|
||||
|
||||
if (!LIST_ISEMPTY(&ctx->bref.users)) {
|
||||
/* Remove show_quic_ctx from previous quic_conn instance. */
|
||||
LIST_DEL_INIT(&ctx->bref.users);
|
||||
}
|
||||
else if (!ctx->bref.ref) {
|
||||
/* First invocation. */
|
||||
ctx->bref.ref = ha_thread_ctx[ctx->thr].quic_conns.n;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
int done = 0;
|
||||
|
||||
if (ctx->bref.ref == &ha_thread_ctx[ctx->thr].quic_conns) {
|
||||
/* If closing connections requested through "all", move
|
||||
* to quic_conns_clo list after browsing quic_conns.
|
||||
* Else move directly to the next quic_conns thread.
|
||||
*/
|
||||
if (ctx->flags & QC_CLI_FL_SHOW_ALL) {
|
||||
ctx->bref.ref = ha_thread_ctx[ctx->thr].quic_conns_clo.n;
|
||||
continue;
|
||||
}
|
||||
|
||||
done = 1;
|
||||
}
|
||||
else if (ctx->bref.ref == &ha_thread_ctx[ctx->thr].quic_conns_clo) {
|
||||
/* Closing list entirely browsed, go to next quic_conns
|
||||
* thread.
|
||||
*/
|
||||
done = 1;
|
||||
}
|
||||
else {
|
||||
/* Retrieve next element of the current list. */
|
||||
qc = LIST_ELEM(ctx->bref.ref, struct quic_conn *, el_th_ctx);
|
||||
if ((int)(qc->qc_epoch - ctx->epoch) > 0)
|
||||
done = 1;
|
||||
}
|
||||
|
||||
if (done) {
|
||||
++ctx->thr;
|
||||
if (ctx->thr >= global.nbthread)
|
||||
break;
|
||||
/* Switch to next thread quic_conns list. */
|
||||
ctx->bref.ref = ha_thread_ctx[ctx->thr].quic_conns.n;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (ctx->format) {
|
||||
case QUIC_DUMP_FMT_FULL:
|
||||
dump_quic_full(ctx, qc);
|
||||
break;
|
||||
}
|
||||
|
||||
if (applet_putchk(appctx, &trash) == -1) {
|
||||
/* Register show_quic_ctx to quic_conn instance. */
|
||||
|
Loading…
Reference in New Issue
Block a user