]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Try to improve rrl timing
authorMark Andrews <marka@isc.org>
Wed, 16 Sep 2020 02:40:52 +0000 (12:40 +1000)
committerMark Andrews <marka@isc.org>
Thu, 15 Oct 2020 00:47:08 +0000 (11:47 +1100)
Add a +burst option to mdig so that we have a second to setup the
mdig calls then they run at the start of the next second.

RRL uses 'queries in a second' as a approximation to
'queries per second'. Getting the bursts of traffic to all happen in
the same second should prevent false negatives in the system test.

We now have a second to setup the traffic in.  Then the traffic should
be sent at the start of the next second.  If that still fails we
should move to +burst=<now+2> (further extend mdig) instead of the
implicit <now+1> as the trigger second.

(cherry picked from commit 92cdc7b6c7eec674fa03e7f87854cd5528c37f48)

bin/tests/system/rrl/tests.sh
bin/tools/mdig.c
bin/tools/mdig.docbook

index b458092bd56d47885e7ca8fb42cc063dc6f95f1b..9b8c81074802d6175a9ccdf279b5b5bd2866bfb5 100644 (file)
@@ -81,7 +81,7 @@ burst () {
         eval BURST_DOM="$BURST_DOM_BASE"
         DOMS="$DOMS $BURST_DOM"
     done
-    ARGS="+nocookie +continue +time=1 +tries=1 -p ${PORT} $* @$ns2 $DOMS"
+    ARGS="+burst +nocookie +continue +time=1 +tries=1 -p ${PORT} $* @$ns2 $DOMS"
     $MDIG $ARGS 2>&1 |                                                  \
         tr -d '\r' |                                                    \
         tee -a full-$FILENAME |                                         \
@@ -93,7 +93,7 @@ burst () {
                -e 's/;; .* status: NOERROR.*/NOERROR/p'                \
                -e 's/;; .* status: SERVFAIL.*/SERVFAIL/p'              \
                -e 's/response failed with timed out.*/drop/p'          \
-               -e 's/;; communications error to.*/drop/p' >> $FILENAME
+               -e 's/;; communications error to.*/drop/p' >> $FILENAME &
     QNUM=`expr $QNUM + $BURST_LIMIT`
 }
 
@@ -105,6 +105,8 @@ range () {
 #   $1=domain  $2=IP address  $3=# of IP addresses  $4=TC  $5=drop
 #      $6=NXDOMAIN  $7=SERVFAIL or other errors
 ck_result() {
+    # wait to the background mdig calls to complete.
+    wait
     BAD=no
     ADDRS=`egrep "^$2$" mdig.out-$1                            2>/dev/null | wc -l`
     # count simple truncated and truncated NXDOMAIN as TC
index 4dd12ee6f4e06235092b6660d0688f74b9e7ac74..26fa609c726112db13e6fb7b26cf101ed30a79c6 100644 (file)
 #define UDPTIMEOUT 5
 #define MAXTRIES 0xffffffff
 
+#define NS_PER_US  1000           /*%< Nanoseconds per microsecond. */
+#define US_PER_SEC 1000000 /*%< Microseconds per second. */
+#define US_PER_MS  1000           /*%< Microseconds per millisecond. */
+
 static isc_mem_t *mctx;
 static dns_requestmgr_t *requestmgr;
 static const char *batchname;
 static FILE *batchfp;
+static bool burst = false;
 static bool have_ipv4 = false;
 static bool have_ipv6 = false;
 static bool have_src = false;
@@ -1151,16 +1156,29 @@ plus_option(char *option, struct query *query, bool global)
                        GLOBAL();
                        besteffort = state;
                        break;
-               case 'u':/* bufsize */
-                       FULLCHECK("bufsize");
-                       if (value == NULL)
-                               goto need_value;
-                       if (!state)
+               case 'u':
+                       switch (cmd[2]) {
+                       case 'f': /* bufsize */
+                               FULLCHECK("bufsize");
+                               if (value == NULL) {
+                                       goto need_value;
+                               }
+                               if (!state) {
+                                       goto invalid_option;
+                               }
+                               result = parse_uint(&num, value, COMMSIZE,
+                                                   "buffer size");
+                               CHECK("parse_uint(buffer size)", result);
+                               query->udpsize = num;
+                               break;
+                       case 'r': /* burst */
+                               FULLCHECK("burst");
+                               GLOBAL();
+                               burst = state;
+                               break;
+                       default:
                                goto invalid_option;
-                       result = parse_uint(&num, value, COMMSIZE,
-                                           "buffer size");
-                       CHECK("parse_uint(buffer size)", result);
-                       query->udpsize = num;
+                       }
                        break;
                default:
                        goto invalid_option;
@@ -1930,6 +1948,21 @@ parse_args(bool is_batchfile, int argc, char **argv)
        }
 }
 
+#ifdef WIN32
+static void
+usleep(unsigned int usec) {
+       HANDLE timer;
+       LARGE_INTEGER ft;
+
+       ft.QuadPart = -(10 * (__int64)usec);
+
+       timer = CreateWaitableTimer(NULL, TRUE, NULL);
+       SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
+       WaitForSingleObject(timer, INFINITE);
+       CloseHandle(timer);
+}
+#endif
+
 /*% Main processing routine for mdig */
 int
 main(int argc, char *argv[]) {
@@ -2043,6 +2076,32 @@ main(int argc, char *argv[]) {
        query = ISC_LIST_HEAD(queries);
        RUNCHECK(isc_app_onrun(mctx, task, sendqueries, query));
 
+       /*
+        * Stall to the start of a new second.
+        */
+       if (burst) {
+               isc_time_t start, now;
+               RUNCHECK(isc_time_now(&start));
+               /*
+                * Sleep to 1ms of the end of the second then run a busy loop
+                * until the second changes.
+                */
+               do {
+                       RUNCHECK(isc_time_now(&now));
+                       if (isc_time_seconds(&start) == isc_time_seconds(&now))
+                       {
+                               int us = US_PER_SEC -
+                                        (isc_time_nanoseconds(&now) /
+                                         NS_PER_US);
+                               if (us > US_PER_MS) {
+                                       usleep(us - US_PER_MS);
+                               }
+                       } else {
+                               break;
+                       }
+               } while (1);
+       }
+
        (void)isc_app_run();
 
        query = ISC_LIST_HEAD(queries);
index da6b491e9cc2adb81b25f05d6a590d55fa7d4037..212e560c2833eac32e467e4333801854d0a5b57e 100644 (file)
           </listitem>
         </varlistentry>
 
+        <varlistentry>
+          <term><option>+burst</option></term>
+          <listitem>
+            This option delays queries until the start of the next second.
+          </listitem>
+        </varlistentry>
+
         <varlistentry>
           <term><option>+[no]cl</option></term>
           <listitem>