]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: fix alignment of oneline show quic
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 22 May 2023 08:57:56 +0000 (10:57 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 22 May 2023 12:18:02 +0000 (14:18 +0200)
Output of 'show quic' CLI in oneline mode was not correctly done. This
was caused both due to differing qc pointer size and ports length. Force
proper alignment by using maximum sizes as expected and complete with
blanks if needed.

This should be backported up to 2.7.

src/quic_conn.c

index daa687322c44720b0d3b86348388026ceb2d2167..edcaf6b7b2bfab193561edf4decee8b582c12ea1 100644 (file)
@@ -8662,10 +8662,12 @@ static int cli_parse_show_quic(char **args, char *payload, struct appctx *appctx
 static void dump_quic_oneline(struct show_quic_ctx *ctx, struct quic_conn *qc)
 {
        char bufaddr[INET6_ADDRSTRLEN], bufport[6];
+       int ret;
        unsigned char cid_len;
 
-       chunk_appendf(&trash, "%p[%02u]/%-.12s ", qc, ctx->thr,
-                     qc->li->bind_conf->frontend->id);
+       ret = chunk_appendf(&trash, "%p[%02u]/%-.12s ", qc, ctx->thr,
+                           qc->li->bind_conf->frontend->id);
+       chunk_appendf(&trash, "%*s", 36 - ret, " "); /* align output */
 
        /* State */
        if (qc->flags & QUIC_FL_CONN_CLOSING)
@@ -8688,11 +8690,11 @@ static void dump_quic_oneline(struct show_quic_ctx *ctx, struct quic_conn *qc)
            qc->local_addr.ss_family == AF_INET6) {
                addr_to_str(&qc->peer_addr, bufaddr, sizeof(bufaddr));
                port_to_str(&qc->peer_addr, bufport, sizeof(bufport));
-               chunk_appendf(&trash, "%15s:%s ", bufaddr, bufport);
+               chunk_appendf(&trash, "%15s:%-5s ", bufaddr, bufport);
 
                addr_to_str(&qc->local_addr, bufaddr, sizeof(bufaddr));
                port_to_str(&qc->local_addr, bufport, sizeof(bufport));
-               chunk_appendf(&trash, "%15s:%s      ", bufaddr, bufport);
+               chunk_appendf(&trash, "%15s:%-5s   ", bufaddr, bufport);
        }
 
        /* CIDs */
@@ -8848,9 +8850,9 @@ static int cli_io_handler_dump_quic(struct appctx *appctx)
 
                /* Print legend for oneline format. */
                if (ctx->format == QUIC_DUMP_FMT_ONELINE) {
-                       chunk_appendf(&trash, "# conn/frontend       state   "
-                                     "in_flight infl_p lost_p                    "
-                                     "from                    to      "
+                       chunk_appendf(&trash, "# conn/frontend                     state   "
+                                     "in_flight infl_p lost_p               "
+                                     "from                    to          "
                                      "local & remote CIDs\n");
                        applet_putchk(appctx, &trash);
                }