From: Willy Tarreau Date: Wed, 20 Jan 2021 14:30:56 +0000 (+0100) Subject: MINOR: xprt: add a new show_fd() helper to complete some "show fd" dumps. X-Git-Tag: v2.4-dev6~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=108a27104960da8196eb6ce3686a2b65be3c6067;p=thirdparty%2Fhaproxy.git MINOR: xprt: add a new show_fd() helper to complete some "show fd" dumps. Just like we did for the muxes, now the transport layers will have the ability to provide helpers to report more detailed information about their internal context. When the helper is not known, the pointer continues to be dumped as-is if it's not NULL. This way a transport with no context nor dump function will not add a useless "xprt_ctx=(nil)" but the pointer will be emitted if valid or if a helper is defined. --- diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index 91048d5288..7dd3d15d90 100644 --- a/include/haproxy/connection-t.h +++ b/include/haproxy/connection-t.h @@ -381,6 +381,7 @@ struct xprt_ops { int (*unsubscribe)(struct connection *conn, void *xprt_ctx, int event_type, struct wait_event *es); /* Unsubscribe from events */ int (*remove_xprt)(struct connection *conn, void *xprt_ctx, void *toremove_ctx, const struct xprt_ops *newops, void *newctx); /* Remove an xprt from the connection, used by temporary xprt such as the handshake one */ int (*add_xprt)(struct connection *conn, void *xprt_ctx, void *toadd_ctx, const struct xprt_ops *toadd_ops, void **oldxprt_ctx, const struct xprt_ops **oldxprt_ops); /* Add a new XPRT as the new xprt, and return the old one */ + void (*show_fd)(struct buffer *, const struct connection *, const void *ctx); /* append some data about xprt for "show fd" */ }; /* mux_ops describes the mux operations, which are to be performed at the diff --git a/src/cli.c b/src/cli.c index b7378019d2..060372988e 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1106,8 +1106,12 @@ static int cli_io_handler_show_fd(struct appctx *appctx) chunk_appendf(&trash, " nomux"); chunk_appendf(&trash, " xprt=%s", xprt ? xprt->name : ""); - if (xprt) - chunk_appendf(&trash, " xprt_ctx=%p", xprt_ctx); + if (xprt) { + if (xprt_ctx || xprt->show_fd) + chunk_appendf(&trash, " xprt_ctx=%p", xprt_ctx); + if (xprt->show_fd) + xprt->show_fd(&trash, conn, xprt_ctx); + } } else if (fdt.iocb == sock_accept_iocb) { chunk_appendf(&trash, ") l.st=%s fe=%s",