]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: display socket info on "show quic"
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 1 Feb 2023 16:04:26 +0000 (17:04 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 9 Feb 2023 17:14:40 +0000 (18:14 +0100)
Complete "show quic" handler by displaying information related to the
quic_conn owned socket. First, the FD is printed, followed by the
address of the local and remote endpoint.

This should be backported up to 2.7.

src/quic_conn.c

index 6602b85e4d652d17dabc7a836c1ab4251c708871..5e383979c9e19a69267e1995a4ed2dde920dde1a 100644 (file)
@@ -7646,6 +7646,7 @@ 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;
+       char bufaddr[INET6_ADDRSTRLEN], bufport[6];
        int expire;
        unsigned char cid_len;
 
@@ -7732,6 +7733,21 @@ static int cli_io_handler_dump_quic(struct appctx *appctx)
 
                chunk_appendf(&trash, "\n");
 
+               /* Socket */
+               chunk_appendf(&trash, "  fd=%d", qc->fd);
+               if (qc->local_addr.ss_family == AF_INET ||
+                   qc->local_addr.ss_family == AF_INET6) {
+                       addr_to_str(&qc->local_addr, bufaddr, sizeof(bufaddr));
+                       port_to_str(&qc->local_addr, bufport, sizeof(bufport));
+                       chunk_appendf(&trash, "               from=%s:%s", bufaddr, bufport);
+
+                       addr_to_str(&qc->peer_addr, bufaddr, sizeof(bufaddr));
+                       port_to_str(&qc->peer_addr, bufport, sizeof(bufport));
+                       chunk_appendf(&trash, " to=%s:%s", bufaddr, bufport);
+               }
+
+               chunk_appendf(&trash, "\n");
+
                if (applet_putchk(appctx, &trash) == -1) {
                        /* Register show_quic_ctx to quic_conn instance. */
                        LIST_APPEND(&qc->back_refs, &ctx->bref.users);