summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2023-05-11 17:06:22 +0200
committerWilly Tarreau <w@1wt.eu>2023-05-11 17:20:39 +0200
commitfe0ba0e9f93f29bb61f65fec7fb21bbd00d7f2a0 (patch)
treeda97570570e2741796e71f4e4f468e6f75e98648
parentea07715ccff4b46c3a9aa40afe80dd3943f1a9c6 (diff)
downloadhaproxy-fe0ba0e9f93f29bb61f65fec7fb21bbd00d7f2a0.tar.gz
MINOR: cli: make "show fd" identify QUIC connections and listeners
Now we can detect the listener associated with a QUIC listener and report a bit more info (e.g. listening port and frontend name), and provide a bit more info about connections as well, and filter on both front connections and listeners using the "l" and "f" flags.
-rw-r--r--src/cli.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/cli.c b/src/cli.c
index d8675e10f..86cc92503 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -50,6 +50,7 @@
#include <haproxy/pipe.h>
#include <haproxy/protocol.h>
#include <haproxy/proxy.h>
+#include <haproxy/quic_sock.h>
#include <haproxy/sample-t.h>
#include <haproxy/sc_strm.h>
#include <haproxy/server.h>
@@ -1285,6 +1286,7 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
const struct xprt_ops *xprt = NULL;
const void *ctx = NULL;
const void *xprt_ctx = NULL;
+ const struct quic_conn *qc = NULL;
uint32_t conn_flags = 0;
uint8_t conn_err = 0;
int is_back = 0;
@@ -1318,10 +1320,26 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
if (conn->handle.fd != fd)
suspicious = 1;
}
+#if defined(USE_QUIC)
+ else if (fdt.iocb == quic_conn_sock_fd_iocb) {
+ qc = fdtab[fd].owner;
+ li = qc ? qc->li : NULL;
+ xprt_ctx = qc ? qc->xprt_ctx : NULL;
+ conn = qc ? qc->conn : NULL;
+ xprt = conn ? conn->xprt : NULL; // in fact it's &ssl_quic
+ mux = conn ? conn->mux : NULL;
+ /* quic_conns don't always have a connection but they
+ * always have an xprt_ctx.
+ */
+ }
+ else if (fdt.iocb == quic_lstnr_sock_fd_iocb) {
+ li = objt_listener(fdtab[fd].owner);
+ }
+#endif
else if (fdt.iocb == sock_accept_iocb)
li = fdt.owner;
- if (!((conn &&
+ if (!(((conn || xprt_ctx) &&
((match & CLI_SHOWFD_F_SV && sv) ||
(match & CLI_SHOWFD_F_PX && px) ||
(match & CLI_SHOWFD_F_FE && li))) ||
@@ -1364,12 +1382,15 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
if (!fdt.owner) {
chunk_appendf(&trash, ")");
}
- else if (fdt.iocb == sock_conn_iocb) {
+ else if (conn) {
chunk_appendf(&trash, ") back=%d cflg=0x%08x cerr=%d", is_back, conn_flags, conn_err);
- if (conn->handle.fd != fd) {
+ if (!(conn->flags & CO_FL_FDLESS) && conn->handle.fd != fd) {
chunk_appendf(&trash, " fd=%d(BOGUS)", conn->handle.fd);
suspicious = 1;
+ } else if ((conn->flags & CO_FL_FDLESS) && (qc != conn->handle.qc)) {
+ chunk_appendf(&trash, " qc=%p(BOGUS)", conn->handle.qc);
+ suspicious = 1;
} else {
struct sockaddr_storage sa;
socklen_t salen;
@@ -1402,7 +1423,7 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
if (mux) {
chunk_appendf(&trash, " mux=%s ctx=%p", mux->name, ctx);
- if (!ctx)
+ if (!ctx && !qc)
suspicious = 1;
if (mux->show_fd)
suspicious |= mux->show_fd(&trash, fdt.owner);
@@ -1418,7 +1439,7 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
suspicious |= xprt->show_fd(&trash, conn, xprt_ctx);
}
}
- else if (fdt.iocb == sock_accept_iocb) {
+ else if (li && !xprt_ctx) {
struct sockaddr_storage sa;
socklen_t salen;