From dfaecfd752b7e3a8fdaa4edb53d8c96c18cee8b9 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Mon, 17 Apr 2023 12:22:38 +0000 Subject: [PATCH] Implement new -T options for xfer system tests '-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 | 18 ++++++++++++++++++ bin/named/zoneconf.c | 18 ++++++++++++++---- lib/ns/include/ns/server.h | 31 +++++++++++++++++-------------- lib/ns/xfrout.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 18 deletions(-) diff --git a/bin/named/main.c b/bin/named/main.c index 5372b902fd..d134215207 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -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 diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 470069ac8d..6fa7b07c82 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -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); diff --git a/lib/ns/include/ns/server.h b/lib/ns/include/ns/server.h index 41e8fc0d03..8dc8b1cf3e 100644 --- a/lib/ns/include/ns/server.h +++ b/lib/ns/include/ns/server.h @@ -32,20 +32,23 @@ #include -#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. diff --git a/lib/ns/xfrout.c b/lib/ns/xfrout.c index 041c6a109f..b782a29654 100644 --- a/lib/ns/xfrout.c +++ b/lib/ns/xfrout.c @@ -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);