]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Implement new -T options for xfer system tests
authorAram Sargsyan <aram@isc.org>
Mon, 17 Apr 2023 12:22:38 +0000 (12:22 +0000)
committerOndřej Surý <ondrej@isc.org>
Fri, 21 Apr 2023 10:53:02 +0000 (12:53 +0200)
'-T transferinsecs' makes named interpret the max-transfer-time-out,
max-transfer-idle-out, max-transfer-time-in and max-transfer-idle-in
configuration options as seconds instead of minutes.

'-T transferslowly' makes named to sleep for one second for every
xfrout message.

'-T transferstuck' makes named to sleep for one minute for every
xfrout message.

bin/named/main.c
bin/named/zoneconf.c
lib/ns/include/ns/server.h
lib/ns/xfrout.c

index 5372b902fd368ce0234d19dafc3bc455a505202c..d1342152077ca94c0d337befc3c8c594580df610 100644 (file)
@@ -133,6 +133,9 @@ static bool nonearest = false;
 static bool nosoa = false;
 static bool notcp = false;
 static bool sigvalinsecs = false;
+static bool transferinsecs = false;
+static bool transferslowly = false;
+static bool transferstuck = false;
 
 /*
  * -4 and -6
@@ -765,6 +768,12 @@ parse_T_opt(char *option) {
                }
        } else if (!strcmp(option, "sigvalinsecs")) {
                sigvalinsecs = true;
+       } else if (!strcmp(option, "transferinsecs")) {
+               transferinsecs = true;
+       } else if (!strcmp(option, "transferslowly")) {
+               transferslowly = true;
+       } else if (!strcmp(option, "transferstuck")) {
+               transferstuck = true;
        } else if (!strncmp(option, "tat=", 4)) {
                named_g_tat_interval = atoi(option + 4);
        } else {
@@ -1311,6 +1320,15 @@ setup(void) {
        if (sigvalinsecs) {
                ns_server_setoption(sctx, NS_SERVER_SIGVALINSECS, true);
        }
+       if (transferinsecs) {
+               ns_server_setoption(sctx, NS_SERVER_TRANSFERINSECS, true);
+       }
+       if (transferslowly) {
+               ns_server_setoption(sctx, NS_SERVER_TRANSFERSLOWLY, true);
+       }
+       if (transferstuck) {
+               ns_server_setoption(sctx, NS_SERVER_TRANSFERSTUCK, true);
+       }
 }
 
 static void
index 470069ac8d70ec7ee09bd93b3d3c0526962355a5..6fa7b07c8231776bc9497d28a7943bfeb67a3c73 100644 (file)
@@ -905,6 +905,8 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
        int seconds;
        dns_ttl_t maxttl = 0; /* unlimited */
        dns_zone_t *mayberaw = (raw != NULL) ? raw : zone;
+       bool transferinsecs = ns_server_getoption(named_g_server->sctx,
+                                                 NS_SERVER_TRANSFERINSECS);
 
        i = 0;
        if (zconfig != NULL) {
@@ -1312,12 +1314,16 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
                obj = NULL;
                result = named_config_get(maps, "max-transfer-time-out", &obj);
                INSIST(result == ISC_R_SUCCESS && obj != NULL);
-               dns_zone_setmaxxfrout(zone, cfg_obj_asuint32(obj) * 60);
+               dns_zone_setmaxxfrout(
+                       zone, transferinsecs ? cfg_obj_asuint32(obj)
+                                            : cfg_obj_asuint32(obj) * 60);
 
                obj = NULL;
                result = named_config_get(maps, "max-transfer-idle-out", &obj);
                INSIST(result == ISC_R_SUCCESS && obj != NULL);
-               dns_zone_setidleout(zone, cfg_obj_asuint32(obj) * 60);
+               dns_zone_setidleout(zone, transferinsecs
+                                                 ? cfg_obj_asuint32(obj)
+                                                 : cfg_obj_asuint32(obj) * 60);
 
                obj = NULL;
                result = named_config_get(maps, "max-journal-size", &obj);
@@ -1913,12 +1919,16 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
                obj = NULL;
                result = named_config_get(maps, "max-transfer-time-in", &obj);
                INSIST(result == ISC_R_SUCCESS && obj != NULL);
-               dns_zone_setmaxxfrin(mayberaw, cfg_obj_asuint32(obj) * 60);
+               dns_zone_setmaxxfrin(
+                       mayberaw, transferinsecs ? cfg_obj_asuint32(obj)
+                                                : cfg_obj_asuint32(obj) * 60);
 
                obj = NULL;
                result = named_config_get(maps, "max-transfer-idle-in", &obj);
                INSIST(result == ISC_R_SUCCESS && obj != NULL);
-               dns_zone_setidlein(mayberaw, cfg_obj_asuint32(obj) * 60);
+               dns_zone_setidlein(mayberaw,
+                                  transferinsecs ? cfg_obj_asuint32(obj)
+                                                 : cfg_obj_asuint32(obj) * 60);
 
                obj = NULL;
                result = named_config_get(maps, "max-refresh-time", &obj);
index 41e8fc0d032465daf9778e3eaf42711adc073039..8dc8b1cf3e7b8719c5f99bbcf3603a9622752131 100644 (file)
 
 #include <ns/types.h>
 
-#define NS_SERVER_LOGQUERIES   0x00000001U /*%< log queries */
-#define NS_SERVER_NOAA        0x00000002U /*%< -T noaa */
-#define NS_SERVER_NOSOA               0x00000004U /*%< -T nosoa */
-#define NS_SERVER_NONEAREST    0x00000008U /*%< -T nonearest */
-#define NS_SERVER_NOEDNS       0x00000020U /*%< -T noedns */
-#define NS_SERVER_DROPEDNS     0x00000040U /*%< -T dropedns */
-#define NS_SERVER_NOTCP               0x00000080U /*%< -T notcp */
-#define NS_SERVER_DISABLE4     0x00000100U /*%< -6 */
-#define NS_SERVER_DISABLE6     0x00000200U /*%< -4 */
-#define NS_SERVER_FIXEDLOCAL   0x00000400U /*%< -T fixedlocal */
-#define NS_SERVER_SIGVALINSECS 0x00000800U /*%< -T sigvalinsecs */
-#define NS_SERVER_EDNSFORMERR  0x00001000U /*%< -T ednsformerr (STD13) */
-#define NS_SERVER_EDNSNOTIMP   0x00002000U /*%< -T ednsnotimp */
-#define NS_SERVER_EDNSREFUSED  0x00004000U /*%< -T ednsrefused */
+#define NS_SERVER_LOGQUERIES    0x00000001U /*%< log queries */
+#define NS_SERVER_NOAA          0x00000002U /*%< -T noaa */
+#define NS_SERVER_NOSOA                 0x00000004U /*%< -T nosoa */
+#define NS_SERVER_NONEAREST     0x00000008U /*%< -T nonearest */
+#define NS_SERVER_NOEDNS        0x00000020U /*%< -T noedns */
+#define NS_SERVER_DROPEDNS      0x00000040U /*%< -T dropedns */
+#define NS_SERVER_NOTCP                 0x00000080U /*%< -T notcp */
+#define NS_SERVER_DISABLE4      0x00000100U /*%< -6 */
+#define NS_SERVER_DISABLE6      0x00000200U /*%< -4 */
+#define NS_SERVER_FIXEDLOCAL    0x00000400U /*%< -T fixedlocal */
+#define NS_SERVER_SIGVALINSECS  0x00000800U /*%< -T sigvalinsecs */
+#define NS_SERVER_EDNSFORMERR   0x00001000U /*%< -T ednsformerr (STD13) */
+#define NS_SERVER_EDNSNOTIMP    0x00002000U /*%< -T ednsnotimp */
+#define NS_SERVER_EDNSREFUSED   0x00004000U /*%< -T ednsrefused */
+#define NS_SERVER_TRANSFERINSECS 0x00008000U /*%< -T transferinsecs */
+#define NS_SERVER_TRANSFERSLOWLY 0x00010000U /*%< -T transferslowly */
+#define NS_SERVER_TRANSFERSTUCK         0x00020000U /*%< -T transferstuck */
 
 /*%
  * Type for callback function to get hostname.
index 041c6a109ff717ed4870320bae3418540d9dc205..b782a29654e90f4e58b446fe9cdb0a3c3942e332 100644 (file)
@@ -1534,6 +1534,22 @@ sendstream(xfrout_ctx_t *xfr) {
                xfrout_log(xfr, ISC_LOG_DEBUG(8),
                           "sending TCP message of %d bytes", used.length);
 
+               /* System test helper options to simulate network issues. */
+               if (ns_server_getoption(xfr->client->manager->sctx,
+                                       NS_SERVER_TRANSFERSLOWLY))
+               {
+                       /* Sleep for a bit over a second. */
+                       select(0, NULL, NULL, NULL,
+                              &(struct timeval){ 1, 1000 });
+               }
+               if (ns_server_getoption(xfr->client->manager->sctx,
+                                       NS_SERVER_TRANSFERSTUCK))
+               {
+                       /* Sleep for a bit over a minute. */
+                       select(0, NULL, NULL, NULL,
+                              &(struct timeval){ 60, 1000 });
+               }
+
                isc_nmhandle_attach(xfr->client->handle,
                                    &xfr->client->sendhandle);
                if (xfr->idletime > 0) {
@@ -1546,6 +1562,23 @@ sendstream(xfrout_ctx_t *xfr) {
                xfr->cbytes = used.length;
        } else {
                xfrout_log(xfr, ISC_LOG_DEBUG(8), "sending IXFR UDP response");
+
+               /* System test helper options to simulate network issues. */
+               if (ns_server_getoption(xfr->client->manager->sctx,
+                                       NS_SERVER_TRANSFERSLOWLY))
+               {
+                       /* Sleep for a bit over a second. */
+                       select(0, NULL, NULL, NULL,
+                              &(struct timeval){ 1, 1000 });
+               }
+               if (ns_server_getoption(xfr->client->manager->sctx,
+                                       NS_SERVER_TRANSFERSTUCK))
+               {
+                       /* Sleep for a bit over a minute. */
+                       select(0, NULL, NULL, NULL,
+                              &(struct timeval){ 60, 1000 });
+               }
+
                ns_client_send(xfr->client);
                xfr->stream->methods->pause(xfr->stream);
                isc_nmhandle_detach(&xfr->client->reqhandle);