]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
kdig: implemented message read delay...
authorLibor Peltan <libor.peltan@nic.cz>
Mon, 14 Apr 2025 12:33:04 +0000 (14:33 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Mon, 14 Apr 2025 15:31:02 +0000 (17:31 +0200)
...in order to debug slow XFRs and their interferences

doc/man_kdig.rst
src/utils/kdig/kdig_exec.c
src/utils/kdig/kdig_params.c
src/utils/kdig/kdig_params.h

index 358f34b8eae25ed1ba9075a1283f465aad5124a1..02e64ac5e1d53dbf33c71f6b7dc20082d9f7cf15 100644 (file)
@@ -308,6 +308,9 @@ Options
 **+**\ [\ **no**\ ]\ **edns**\[\ =\ *N*\]
   Use EDNS version (default is 0).
 
+**+**\ [\ **no**\ ]\ **msgdelay**\ =\ *T*
+  Wait the specified number of milliseconds before receiving each AXFR/IXFR message.
+
 **+**\ [\ **no**\ ]\ **timeout**\ =\ *T*
   Set the wait-for-reply interval in seconds (default is 5 seconds). This timeout
   applies to each query attempt. Zero value or *notimeout* is interpreted as
index 873a8ec36847999cbf7820970dcf5194c3b3158d..4a47c4f09940b27297d9cb540bc98c9c3e5d59bc 100644 (file)
@@ -1025,6 +1025,8 @@ static int process_xfr_packet(const knot_pkt_t      *query,
        while (true) {
                reply = NULL;
 
+               usleep(query_ctx->msgdelay * 1000LU);
+
                // Receive a reply message.
                in_len = net_receive(net, in, sizeof(in));
                t_end = time_now();
index 03ece548c12026c61a2cb53bbc51608103e96d16..a37def275e8964abde014b1b5e885ec11a475c4f 100644 (file)
@@ -1261,6 +1261,27 @@ static int opt_noedns(const char *arg, void *query)
        return KNOT_EOK;
 }
 
+static int opt_msgdelay(const char *arg, void *query)
+{
+       query_t *q = query;
+
+       if (str_to_u32(arg, &q->msgdelay) != KNOT_EOK) {
+               ERR("invalid +msgdelay=%s", arg);
+               return KNOT_EINVAL;
+       }
+
+       return KNOT_EOK;
+}
+
+static int opt_nomsgdelay(const char *arg, void *query)
+{
+       query_t *q = query;
+
+       q->msgdelay = 0;
+
+       return KNOT_EOK;
+}
+
 static int opt_timeout(const char *arg, void *query)
 {
        query_t *q = query;
@@ -1645,6 +1666,9 @@ static const param_t kdig_opts2[] = {
        { "edns",           ARG_OPTIONAL, opt_edns },
        { "noedns",         ARG_NONE,     opt_noedns },
 
+       { "msgdelay",       ARG_REQUIRED, opt_msgdelay },
+       { "nomsgdelay",     ARG_NONE,     opt_nomsgdelay },
+
        { "timeout",        ARG_REQUIRED, opt_timeout },
        { "notimeout",      ARG_NONE,     opt_notimeout },
 
@@ -2400,6 +2424,7 @@ static void print_help(void)
               "       +[no]alignment[=N]         Pad with EDNS(0) to blocksize (%u or specify size).\n"
               "       +[no]subnet=SUBN           Set EDNS(0) client subnet addr/prefix.\n"
               "       +[no]edns[=N]              Use EDNS(=version).\n"
+              "       +[no]msgdelay=T            Wait this ms before receiving each XFR message.\n"
               "       +[no]timeout=T             Set wait for reply interval in seconds.\n"
               "       +[no]retry=N               Set number of retries.\n"
               "       +[no]expire                Set the EXPIRE EDNS option.\n"
index 7667fc335422b2e6667b117354b26a5f6c447b57..24c8bc27b4cbed2ce3b557211a23ecc85cb8025b 100644 (file)
@@ -79,6 +79,8 @@ struct query {
        int32_t         udp_size;
        /*!< Number of UDP retries. */
        uint32_t        retries;
+       /*!< Wait this milliseconds before receiving each XFR message. */
+       uint32_t        msgdelay;
        /*!< Wait for network response in seconds (-1 means forever). */
        int32_t         wait;
        /*!< Ignore truncated response. */