2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

Apply the semantic patch to remove isc_stdtime_get()

This is a simple replacement using the semantic patch from the previous
commit and as added bonus, one removal of previously undetected unused
variable in named/server.c.
This commit is contained in:
Ondřej Surý 2023-03-30 21:13:41 +02:00
parent 0ec8d7b6f3
commit 46f06c1d6e
No known key found for this signature in database
GPG Key ID: 2820F37E873DEA41
39 changed files with 97 additions and 163 deletions

View File

@ -345,8 +345,7 @@ load_parent_set(const char *path) {
} }
notbefore = isc_time_seconds(&modtime); notbefore = isc_time_seconds(&modtime);
if (startstr != NULL) { if (startstr != NULL) {
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
isc_stdtime_get(&now);
notbefore = strtotime(startstr, now, notbefore, NULL); notbefore = strtotime(startstr, now, notbefore, NULL);
} }
verbose_time(1, "child records must not be signed before", notbefore); verbose_time(1, "child records must not be signed before", notbefore);

View File

@ -302,10 +302,9 @@ main(int argc, char **argv) {
isc_log_t *log = NULL; isc_log_t *log = NULL;
dns_rdataset_t rdataset; dns_rdataset_t rdataset;
dns_rdata_t rdata; dns_rdata_t rdata;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
dns_rdata_init(&rdata); dns_rdata_init(&rdata);
isc_stdtime_get(&now);
if (argc == 1) { if (argc == 1) {
usage(); usage();

View File

@ -135,7 +135,6 @@ main(int argc, char **argv) {
dns_ttl_t ttl = 0; dns_ttl_t ttl = 0;
isc_stdtime_t publish = 0, activate = 0, revoke = 0; isc_stdtime_t publish = 0, activate = 0, revoke = 0;
isc_stdtime_t inactive = 0, deltime = 0; isc_stdtime_t inactive = 0, deltime = 0;
isc_stdtime_t now;
int prepub = -1; int prepub = -1;
bool setpub = false, setact = false; bool setpub = false, setact = false;
bool setrev = false, setinact = false; bool setrev = false, setinact = false;
@ -151,6 +150,7 @@ main(int argc, char **argv) {
isc_stdtime_t syncadd = 0, syncdel = 0; isc_stdtime_t syncadd = 0, syncdel = 0;
bool unsetsyncadd = false, setsyncadd = false; bool unsetsyncadd = false, setsyncadd = false;
bool unsetsyncdel = false, setsyncdel = false; bool unsetsyncdel = false, setsyncdel = false;
isc_stdtime_t now = isc_stdtime_now();
if (argc == 1) { if (argc == 1) {
usage(); usage();
@ -160,8 +160,6 @@ main(int argc, char **argv) {
isc_commandline_errprint = false; isc_commandline_errprint = false;
isc_stdtime_get(&now);
#define CMDLINE_FLAGS "3A:a:Cc:D:E:Ff:GhI:i:kK:L:l:n:P:p:R:S:t:v:Vy" #define CMDLINE_FLAGS "3A:a:Cc:D:E:Ff:GhI:i:kK:L:l:n:P:p:R:S:t:v:Vy"
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) { while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
switch (ch) { switch (ch) {

View File

@ -839,6 +839,7 @@ main(int argc, char **argv) {
.prepub = -1, .prepub = -1,
.protocol = -1, .protocol = -1,
.size = -1, .size = -1,
.now = isc_stdtime_now(),
}; };
if (argc == 1) { if (argc == 1) {
@ -876,7 +877,6 @@ main(int argc, char **argv) {
isc_commandline_reset = true; isc_commandline_reset = true;
isc_mem_create(&mctx); isc_mem_create(&mctx);
isc_stdtime_get(&ctx.now);
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) { while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
switch (ch) { switch (ch) {

View File

@ -190,7 +190,7 @@ main(int argc, char **argv) {
flags = dst_key_flags(key); flags = dst_key_flags(key);
if ((flags & DNS_KEYFLAG_REVOKE) == 0) { if ((flags & DNS_KEYFLAG_REVOKE) == 0) {
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
if ((flags & DNS_KEYFLAG_KSK) == 0) { if ((flags & DNS_KEYFLAG_KSK) == 0) {
fprintf(stderr, fprintf(stderr,
@ -200,7 +200,6 @@ main(int argc, char **argv) {
program); program);
} }
isc_stdtime_get(&now);
dst_key_settime(key, DST_TIME_REVOKE, now); dst_key_settime(key, DST_TIME_REVOKE, now);
dst_key_setflags(key, flags | DNS_KEYFLAG_REVOKE); dst_key_setflags(key, flags | DNS_KEYFLAG_REVOKE);

View File

@ -202,7 +202,6 @@ main(int argc, char **argv) {
int prepub = -1; int prepub = -1;
int options; int options;
dns_ttl_t ttl = 0; dns_ttl_t ttl = 0;
isc_stdtime_t now;
isc_stdtime_t dstime = 0, dnskeytime = 0; isc_stdtime_t dstime = 0, dnskeytime = 0;
isc_stdtime_t krrsigtime = 0, zrrsigtime = 0; isc_stdtime_t krrsigtime = 0, zrrsigtime = 0;
isc_stdtime_t pub = 0, act = 0, rev = 0, inact = 0, del = 0; isc_stdtime_t pub = 0, act = 0, rev = 0, inact = 0, del = 0;
@ -238,6 +237,7 @@ main(int argc, char **argv) {
bool unsetdsadd = false, setdsadd = false; bool unsetdsadd = false, setdsadd = false;
bool unsetdsdel = false, setdsdel = false; bool unsetdsdel = false, setdsdel = false;
bool printdsadd = false, printdsdel = false; bool printdsadd = false, printdsdel = false;
isc_stdtime_t now = isc_stdtime_now();
options = DST_TYPE_PUBLIC | DST_TYPE_PRIVATE | DST_TYPE_STATE; options = DST_TYPE_PUBLIC | DST_TYPE_PRIVATE | DST_TYPE_STATE;
@ -251,8 +251,6 @@ main(int argc, char **argv) {
isc_commandline_errprint = false; isc_commandline_errprint = false;
isc_stdtime_get(&now);
#define CMDLINE_FLAGS "A:D:d:E:fg:hI:i:K:k:L:P:p:R:r:S:suv:Vz:" #define CMDLINE_FLAGS "A:D:d:E:fg:hI:i:K:k:L:P:p:R:r:S:suv:Vz:"
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) { while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
switch (ch) { switch (ch) {

View File

@ -3680,7 +3680,7 @@ main(int argc, char *argv[]) {
} }
} }
isc_stdtime_get(&now); now = isc_stdtime_now();
if (startstr != NULL) { if (startstr != NULL) {
starttime = strtotime(startstr, now, now, NULL); starttime = strtotime(startstr, now, now, NULL);

View File

@ -281,7 +281,7 @@ main(int argc, char *argv[]) {
isc_result_totext(result)); isc_result_totext(result));
} }
isc_stdtime_get(&now); now = isc_stdtime_now();
rdclass = strtoclass(classname); rdclass = strtoclass(classname);

View File

@ -474,8 +474,7 @@ set_keyversion(dst_key_t *key) {
* set the creation date * set the creation date
*/ */
if (major < 1 || (major == 1 && minor <= 2)) { if (major < 1 || (major == 1 && minor <= 2)) {
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
isc_stdtime_get(&now);
dst_key_settime(key, DST_TIME_CREATED, now); dst_key_settime(key, DST_TIME_CREATED, now);
} }
} }
@ -490,7 +489,7 @@ key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir,
uint16_t id, oldid; uint16_t id, oldid;
uint32_t rid, roldid; uint32_t rid, roldid;
dns_secalg_t alg; dns_secalg_t alg;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
if (exact != NULL) { if (exact != NULL) {
*exact = false; *exact = false;
@ -501,7 +500,6 @@ key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir,
alg = dst_key_alg(dstkey); alg = dst_key_alg(dstkey);
ISC_LIST_INIT(matchkeys); ISC_LIST_INIT(matchkeys);
isc_stdtime_get(&now);
result = dns_dnssec_findmatchingkeys(name, dir, now, mctx, &matchkeys); result = dns_dnssec_findmatchingkeys(name, dir, now, mctx, &matchkeys);
if (result == ISC_R_NOTFOUND) { if (result == ISC_R_NOTFOUND) {
return (false); return (false);

View File

@ -447,7 +447,7 @@ control_recvmessage(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
goto cleanup; goto cleanup;
} }
isc_stdtime_get(&conn->now); conn->now = isc_stdtime_now();
/* /*
* Limit exposure to replay attacks. * Limit exposure to replay attacks.

View File

@ -7456,7 +7456,7 @@ generate_session_key(const char *filename, const char *keynamestr,
char key_txtsecret[256]; char key_txtsecret[256];
char key_rawsecret[64]; char key_rawsecret[64];
isc_region_t key_rawregion; isc_region_t key_rawregion;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
dns_tsigkey_t *tsigkey = NULL; dns_tsigkey_t *tsigkey = NULL;
FILE *fp = NULL; FILE *fp = NULL;
@ -7484,7 +7484,6 @@ generate_session_key(const char *filename, const char *keynamestr,
CHECK(isc_base64_totext(&key_rawregion, -1, "", &key_txtbuffer)); CHECK(isc_base64_totext(&key_rawregion, -1, "", &key_txtbuffer));
/* Store the key in tsigkey. */ /* Store the key in tsigkey. */
isc_stdtime_get(&now);
CHECK(dns_tsigkey_createfromkey(dst_key_name(key), algname, key, false, CHECK(dns_tsigkey_createfromkey(dst_key_name(key), algname, key, false,
false, NULL, now, now, mctx, NULL, false, NULL, now, now, mctx, NULL,
&tsigkey)); &tsigkey));
@ -15140,11 +15139,9 @@ named_server_zonestatus(named_server_t *server, isc_lex_t *lex,
result = dns_db_getsigningtime(db, &next, name); result = dns_db_getsigningtime(db, &next, name);
if (result == ISC_R_SUCCESS) { if (result == ISC_R_SUCCESS) {
isc_stdtime_t timenow;
char namebuf[DNS_NAME_FORMATSIZE]; char namebuf[DNS_NAME_FORMATSIZE];
char typebuf[DNS_RDATATYPE_FORMATSIZE]; char typebuf[DNS_RDATATYPE_FORMATSIZE];
isc_stdtime_get(&timenow);
dns_name_format(name, namebuf, sizeof(namebuf)); dns_name_format(name, namebuf, sizeof(namebuf));
dns_rdatatype_format(next.covers, typebuf, dns_rdatatype_format(next.covers, typebuf,
sizeof(typebuf)); sizeof(typebuf));
@ -15444,7 +15441,7 @@ named_server_nta(named_server_t *server, isc_lex_t *lex, bool readonly,
CHECK(DNS_R_SYNTAX); CHECK(DNS_R_SYNTAX);
} }
isc_stdtime_get(&now); now = isc_stdtime_now();
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause(named_g_loopmgr);
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL; for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
@ -15704,11 +15701,9 @@ mkey_dumpzone(dns_view_t *view, isc_buffer_t **text) {
dns_db_t *db = NULL; dns_db_t *db = NULL;
dns_dbversion_t *ver = NULL; dns_dbversion_t *ver = NULL;
dns_rriterator_t rrit; dns_rriterator_t rrit;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
dns_name_t *prevname = NULL; dns_name_t *prevname = NULL;
isc_stdtime_get(&now);
CHECK(dns_zone_getdb(view->managed_keys, &db)); CHECK(dns_zone_getdb(view->managed_keys, &db));
dns_db_currentversion(db, &ver); dns_db_currentversion(db, &ver);
dns_rriterator_init(&rrit, db, ver, 0); dns_rriterator_init(&rrit, db, ver, 0);

View File

@ -3826,7 +3826,6 @@ named_statschannels_shutdown(named_server_t *server) {
isc_result_t isc_result_t
named_stats_dump(named_server_t *server, FILE *fp) { named_stats_dump(named_server_t *server, FILE *fp) {
isc_stdtime_t now;
isc_result_t result; isc_result_t result;
dns_view_t *view; dns_view_t *view;
dns_zone_t *zone, *next; dns_zone_t *zone, *next;
@ -3837,6 +3836,7 @@ named_stats_dump(named_server_t *server, FILE *fp) {
uint64_t zonestat_values[dns_zonestatscounter_max]; uint64_t zonestat_values[dns_zonestatscounter_max];
uint64_t sockstat_values[isc_sockstatscounter_max]; uint64_t sockstat_values[isc_sockstatscounter_max];
uint64_t gluecachestats_values[dns_gluecachestatscounter_max]; uint64_t gluecachestats_values[dns_gluecachestatscounter_max];
isc_stdtime_t now = isc_stdtime_now();
isc_once_do(&once, init_desc); isc_once_do(&once, init_desc);
@ -3844,7 +3844,6 @@ named_stats_dump(named_server_t *server, FILE *fp) {
dumparg.type = isc_statsformat_file; dumparg.type = isc_statsformat_file;
dumparg.arg = fp; dumparg.arg = fp;
isc_stdtime_get(&now);
fprintf(fp, "+++ Statistics Dump +++ (%lu)\n", (unsigned long)now); fprintf(fp, "+++ Statistics Dump +++ (%lu)\n", (unsigned long)now);
fprintf(fp, "++ Incoming Requests ++\n"); fprintf(fp, "++ Incoming Requests ++\n");

View File

@ -104,7 +104,7 @@ add_initial_keys(const cfg_obj_t *list, dns_tsig_keyring_t *ring,
} }
secretlen = isc_buffer_usedlength(&secretbuf); secretlen = isc_buffer_usedlength(&secretbuf);
isc_stdtime_get(&now); now = isc_stdtime_now();
ret = dns_tsigkey_create(&keyname, alg, secret, secretlen, ret = dns_tsigkey_create(&keyname, alg, secret, secretlen,
false, false, NULL, now, now, mctx, false, false, NULL, now, now, mctx,
ring, &tsigkey); ring, &tsigkey);

View File

@ -397,7 +397,7 @@ rndc_recvnonce(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
isccc_region_t source; isccc_region_t source;
uint32_t nonce; uint32_t nonce;
isccc_sexpr_t *request = NULL; isccc_sexpr_t *request = NULL;
isccc_time_t now; isccc_time_t now = isc_stdtime_now();
isc_region_t r; isc_region_t r;
isccc_sexpr_t *data = NULL; isccc_sexpr_t *data = NULL;
isc_buffer_t b; isc_buffer_t b;
@ -439,8 +439,6 @@ rndc_recvnonce(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
nonce = 0; nonce = 0;
} }
isc_stdtime_get(&now);
DO("create message", isccc_cc_createmessage(1, NULL, NULL, ++serial, DO("create message", isccc_cc_createmessage(1, NULL, NULL, ++serial,
now, now + 60, &request)); now, now + 60, &request));
data = isccc_alist_lookup(request, "_data"); data = isccc_alist_lookup(request, "_data");
@ -496,7 +494,7 @@ rndc_connected(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
char socktext[ISC_SOCKADDR_FORMATSIZE]; char socktext[ISC_SOCKADDR_FORMATSIZE];
isccc_sexpr_t *request = NULL; isccc_sexpr_t *request = NULL;
isccc_sexpr_t *data = NULL; isccc_sexpr_t *data = NULL;
isccc_time_t now; isccc_time_t now = isc_stdtime_now();
isc_region_t r; isc_region_t r;
isc_buffer_t b; isc_buffer_t b;
isc_nmhandle_t *connhandle = NULL; isc_nmhandle_t *connhandle = NULL;
@ -521,7 +519,6 @@ rndc_connected(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
isc_nmhandle_attach(handle, &connhandle); isc_nmhandle_attach(handle, &connhandle);
isc_stdtime_get(&now);
DO("create message", isccc_cc_createmessage(1, NULL, NULL, ++serial, DO("create message", isccc_cc_createmessage(1, NULL, NULL, ++serial,
now, now + 60, &request)); now, now + 60, &request));
data = isccc_alist_lookup(request, "_data"); data = isccc_alist_lookup(request, "_data");

View File

@ -2087,7 +2087,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_loop_t *loop, isc_job_cb cb, void *cbarg,
} }
if (now == 0) { if (now == 0) {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
/* /*
@ -2456,7 +2456,7 @@ dns_adb_cancelfind(dns_adbfind_t *find) {
void void
dns_adb_dump(dns_adb_t *adb, FILE *f) { dns_adb_dump(dns_adb_t *adb, FILE *f) {
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
REQUIRE(DNS_ADB_VALID(adb)); REQUIRE(DNS_ADB_VALID(adb));
REQUIRE(f != NULL); REQUIRE(f != NULL);
@ -2465,7 +2465,6 @@ dns_adb_dump(dns_adb_t *adb, FILE *f) {
return; return;
} }
isc_stdtime_get(&now);
cleanup_names(adb, now); cleanup_names(adb, now);
cleanup_entries(adb, now); cleanup_entries(adb, now);
dump_adb(adb, f, false, now); dump_adb(adb, f, false, now);
@ -2956,7 +2955,7 @@ fetch_callback(void *arg) {
goto out; goto out;
} }
isc_stdtime_get(&now); now = isc_stdtime_now();
/* /*
* If we got a negative cache response, remember it. * If we got a negative cache response, remember it.
@ -3197,7 +3196,7 @@ dns_adb_adjustsrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr, unsigned int rtt,
LOCK(&entry->lock); LOCK(&entry->lock);
if (entry->expires == 0 || factor == DNS_ADB_RTTADJAGE) { if (entry->expires == 0 || factor == DNS_ADB_RTTADJAGE) {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
adjustsrtt(addr, rtt, factor, now); adjustsrtt(addr, rtt, factor, now);
@ -3258,7 +3257,7 @@ dns_adb_changeflags(dns_adb_t *adb, dns_adbaddrinfo_t *addr, unsigned int bits,
entry->flags = (entry->flags & ~mask) | (bits & mask); entry->flags = (entry->flags & ~mask) | (bits & mask);
if (entry->expires == 0) { if (entry->expires == 0) {
isc_stdtime_get(&now); now = isc_stdtime_now();
entry->expires = now + ADB_ENTRY_WINDOW; entry->expires = now + ADB_ENTRY_WINDOW;
} }
@ -3555,7 +3554,7 @@ dns_adb_freeaddrinfo(dns_adb_t *adb, dns_adbaddrinfo_t **addrp) {
REQUIRE(DNS_ADBENTRY_VALID(entry)); REQUIRE(DNS_ADBENTRY_VALID(entry));
if (entry->expires == 0) { if (entry->expires == 0) {
isc_stdtime_get(&now); now = isc_stdtime_now();
entry->expires = now + ADB_ENTRY_WINDOW; entry->expires = now + ADB_ENTRY_WINDOW;
} }

View File

@ -408,7 +408,7 @@ dns_dnssec_verify(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
} }
if (!ignoretime) { if (!ignoretime) {
isc_stdtime_get(&now); now = isc_stdtime_now();
/* /*
* Is SIG temporally valid? * Is SIG temporally valid?
@ -971,7 +971,7 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
if (msg->fuzzing) { if (msg->fuzzing) {
now = msg->fuzztime; now = msg->fuzztime;
} else { } else {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
sig.timesigned = now - DNS_TSIG_FUDGE; sig.timesigned = now - DNS_TSIG_FUDGE;
sig.timeexpire = now + DNS_TSIG_FUDGE; sig.timeexpire = now + DNS_TSIG_FUDGE;
@ -1119,7 +1119,7 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg,
if (msg->fuzzing) { if (msg->fuzzing) {
now = msg->fuzztime; now = msg->fuzztime;
} else { } else {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
if (isc_serial_lt((uint32_t)now, sig.timesigned)) { if (isc_serial_lt((uint32_t)now, sig.timesigned)) {
@ -1907,7 +1907,7 @@ publish_key(dns_diff_t *diff, dns_dnsseckey_t *key, const dns_name_t *origin,
"(%u).", "(%u).",
keystr, ttl); keystr, ttl);
isc_stdtime_get(&now); now = isc_stdtime_now();
dst_key_settime(key->key, DST_TIME_ACTIVATE, now + ttl); dst_key_settime(key->key, DST_TIME_ACTIVATE, now + ttl);
} }

View File

@ -554,7 +554,7 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, unsigned int options,
isc_lex_setcomments(lctx->lex, ISC_LEXCOMMENT_DNSMASTERFILE); isc_lex_setcomments(lctx->lex, ISC_LEXCOMMENT_DNSMASTERFILE);
} }
isc_stdtime_get(&lctx->now); lctx->now = isc_stdtime_now();
lctx->top = dns_fixedname_initname(&lctx->fixed_top); lctx->top = dns_fixedname_initname(&lctx->fixed_top);
dns_name_toregion(top, &r); dns_name_toregion(top, &r);
@ -1227,9 +1227,9 @@ load_text(dns_loadctx_t *lctx) {
} else if (strcasecmp(DNS_AS_STR(token), "$DATE") == 0) } else if (strcasecmp(DNS_AS_STR(token), "$DATE") == 0)
{ {
int64_t dump_time64; int64_t dump_time64;
isc_stdtime_t dump_time, current_time; isc_stdtime_t dump_time;
isc_stdtime_t current_time = isc_stdtime_now();
GETTOKEN(lctx->lex, 0, &token, false); GETTOKEN(lctx->lex, 0, &token, false);
isc_stdtime_get(&current_time);
result = dns_time64_fromtext(DNS_AS_STR(token), result = dns_time64_fromtext(DNS_AS_STR(token),
&dump_time64); &dump_time64);
if (MANYERRS(lctx, result)) { if (MANYERRS(lctx, result)) {

View File

@ -1545,7 +1545,7 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
goto cleanup; goto cleanup;
} }
isc_stdtime_get(&dctx->now); dctx->now = isc_stdtime_now();
dns_db_attach(db, &dctx->db); dns_db_attach(db, &dctx->db);
dctx->do_date = dns_db_iscache(dctx->db); dctx->do_date = dns_db_iscache(dctx->db);
@ -1913,7 +1913,7 @@ dns_master_dumpnodetostream(isc_mem_t *mctx, dns_db_t *db,
isc_result_t result; isc_result_t result;
isc_buffer_t buffer; isc_buffer_t buffer;
char *bufmem; char *bufmem;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
dns_totext_ctx_t ctx; dns_totext_ctx_t ctx;
dns_rdatasetiter_t *rdsiter = NULL; dns_rdatasetiter_t *rdsiter = NULL;
unsigned int options = DNS_DB_STALEOK; unsigned int options = DNS_DB_STALEOK;
@ -1928,8 +1928,6 @@ dns_master_dumpnodetostream(isc_mem_t *mctx, dns_db_t *db,
return (ISC_R_UNEXPECTED); return (ISC_R_UNEXPECTED);
} }
isc_stdtime_get(&now);
bufmem = isc_mem_get(mctx, initial_buffer_length); bufmem = isc_mem_get(mctx, initial_buffer_length);
isc_buffer_init(&buffer, bufmem, initial_buffer_length); isc_buffer_init(&buffer, bufmem, initial_buffer_length);

View File

@ -161,7 +161,7 @@ fetch_done(void *arg) {
isc_result_t eresult = resp->result; isc_result_t eresult = resp->result;
dns_ntatable_t *ntatable = nta->ntatable; dns_ntatable_t *ntatable = nta->ntatable;
dns_view_t *view = ntatable->view; dns_view_t *view = ntatable->view;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
if (dns_rdataset_isassociated(&nta->rdataset)) { if (dns_rdataset_isassociated(&nta->rdataset)) {
dns_rdataset_disassociate(&nta->rdataset); dns_rdataset_disassociate(&nta->rdataset);
@ -182,7 +182,6 @@ fetch_done(void *arg) {
} }
isc_mem_putanddetach(&resp->mctx, resp, sizeof(*resp)); isc_mem_putanddetach(&resp->mctx, resp, sizeof(*resp));
isc_stdtime_get(&now);
switch (eresult) { switch (eresult) {
case ISC_R_SUCCESS: case ISC_R_SUCCESS:
@ -478,12 +477,10 @@ dns_ntatable_totext(dns_ntatable_t *ntatable, const char *view,
dns_rbtnode_t *node; dns_rbtnode_t *node;
dns_rbtnodechain_t chain; dns_rbtnodechain_t chain;
bool first = true; bool first = true;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
REQUIRE(VALID_NTATABLE(ntatable)); REQUIRE(VALID_NTATABLE(ntatable));
isc_stdtime_get(&now);
RWLOCK(&ntatable->rwlock, isc_rwlocktype_read); RWLOCK(&ntatable->rwlock, isc_rwlocktype_read);
dns_rbtnodechain_init(&chain); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, ntatable->table, NULL, NULL); result = dns_rbtnodechain_first(&chain, ntatable->table, NULL, NULL);
@ -557,13 +554,11 @@ dns_ntatable_save(dns_ntatable_t *ntatable, FILE *fp) {
isc_result_t result; isc_result_t result;
dns_rbtnode_t *node; dns_rbtnode_t *node;
dns_rbtnodechain_t chain; dns_rbtnodechain_t chain;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
bool written = false; bool written = false;
REQUIRE(VALID_NTATABLE(ntatable)); REQUIRE(VALID_NTATABLE(ntatable));
isc_stdtime_get(&now);
RWLOCK(&ntatable->rwlock, isc_rwlocktype_read); RWLOCK(&ntatable->rwlock, isc_rwlocktype_read);
dns_rbtnodechain_init(&chain); dns_rbtnodechain_init(&chain);
result = dns_rbtnodechain_first(&chain, ntatable->table, NULL, NULL); result = dns_rbtnodechain_first(&chain, ntatable->table, NULL, NULL);

View File

@ -5016,7 +5016,7 @@ cache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
REQUIRE(version == NULL); REQUIRE(version == NULL);
if (now == 0) { if (now == 0) {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
search.rbtversion = NULL; search.rbtversion = NULL;
@ -5417,7 +5417,7 @@ cache_findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options,
REQUIRE(VALID_RBTDB(search.rbtdb)); REQUIRE(VALID_RBTDB(search.rbtdb));
if (now == 0) { if (now == 0) {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
search.rbtversion = NULL; search.rbtversion = NULL;
@ -5667,7 +5667,7 @@ expirenode(dns_db_t *db, dns_dbnode_t *node, isc_stdtime_t now) {
*/ */
if (now == 0) { if (now == 0) {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
if (isc_mem_isovermem(rbtdb->common.mctx)) { if (isc_mem_isovermem(rbtdb->common.mctx)) {
@ -5950,7 +5950,7 @@ cache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;
if (now == 0) { if (now == 0) {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
lock = &rbtdb->node_locks[rbtnode->locknum].lock; lock = &rbtdb->node_locks[rbtnode->locknum].lock;
@ -6058,7 +6058,7 @@ allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
} }
} else { } else {
if (now == 0) { if (now == 0) {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
rbtversion = NULL; rbtversion = NULL;
} }
@ -6923,7 +6923,7 @@ addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
if (rbtversion == NULL) { if (rbtversion == NULL) {
if (now == 0) { if (now == 0) {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
} else { } else {
now = 0; now = 0;
@ -7623,11 +7623,7 @@ beginload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
loadctx = isc_mem_get(rbtdb->common.mctx, sizeof(*loadctx)); loadctx = isc_mem_get(rbtdb->common.mctx, sizeof(*loadctx));
loadctx->rbtdb = rbtdb; loadctx->rbtdb = rbtdb;
if (IS_CACHE(rbtdb)) { loadctx->now = IS_CACHE(rbtdb) ? isc_stdtime_now() : 0;
isc_stdtime_get(&loadctx->now);
} else {
loadctx->now = 0;
}
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write); RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write);

View File

@ -207,9 +207,7 @@ totext_keydata(ARGS_TOTEXT) {
RETERR(str_totext(buf, target)); RETERR(str_totext(buf, target));
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) { if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
isc_stdtime_get(&now);
RETERR(str_totext(tctx->linebreak, target)); RETERR(str_totext(tctx->linebreak, target));
RETERR(str_totext("; next refresh: ", target)); RETERR(str_totext("; next refresh: ", target));

View File

@ -1093,7 +1093,7 @@ fctx_cancelquery(resquery_t **queryp, isc_time_t *finish, bool no_response,
fetchctx_t *fctx = NULL; fetchctx_t *fctx = NULL;
dns_adbfind_t *find = NULL; dns_adbfind_t *find = NULL;
dns_adbaddrinfo_t *addrinfo; dns_adbaddrinfo_t *addrinfo;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
REQUIRE(queryp != NULL); REQUIRE(queryp != NULL);
@ -1217,7 +1217,6 @@ fctx_cancelquery(resquery_t **queryp, isc_time_t *finish, bool no_response,
/* /*
* Age RTTs of servers not tried. * Age RTTs of servers not tried.
*/ */
isc_stdtime_get(&now);
if (finish != NULL || age_untried) { if (finish != NULL || age_untried) {
for (addrinfo = ISC_LIST_HEAD(fctx->forwaddrs); for (addrinfo = ISC_LIST_HEAD(fctx->forwaddrs);
addrinfo != NULL; addrinfo != NULL;
@ -1374,7 +1373,7 @@ fcount_logspill(fetchctx_t *fctx, fctxcount_t *counter, bool final) {
} }
/* Do not log the cumulative message if the previous log is recent. */ /* Do not log the cumulative message if the previous log is recent. */
isc_stdtime_get(&now); now = isc_stdtime_now();
if (!final && counter->logged > now - 60) { if (!final && counter->logged > now - 60) {
return; return;
} }
@ -3556,7 +3555,7 @@ normal_nses:
return (DNS_R_SERVFAIL); return (DNS_R_SERVFAIL);
} }
isc_stdtime_get(&now); now = isc_stdtime_now();
INSIST(ISC_LIST_EMPTY(fctx->finds)); INSIST(ISC_LIST_EMPTY(fctx->finds));
INSIST(ISC_LIST_EMPTY(fctx->altfinds)); INSIST(ISC_LIST_EMPTY(fctx->altfinds));
@ -5178,7 +5177,7 @@ validated(void *arg) {
goto cleanup_fetchctx; goto cleanup_fetchctx;
} }
isc_stdtime_get(&now); now = isc_stdtime_now();
/* /*
* If chaining, we need to make sure that the right result code * If chaining, we need to make sure that the right result code

View File

@ -154,13 +154,11 @@ check_hints(dns_db_t *db) {
dns_rdataset_t rootns; dns_rdataset_t rootns;
dns_dbiterator_t *dbiter = NULL; dns_dbiterator_t *dbiter = NULL;
dns_dbnode_t *node = NULL; dns_dbnode_t *node = NULL;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
dns_fixedname_t fixname; dns_fixedname_t fixname;
dns_name_t *name; dns_name_t *name;
dns_rdatasetiter_t *rdsiter = NULL; dns_rdatasetiter_t *rdsiter = NULL;
isc_stdtime_get(&now);
name = dns_fixedname_initname(&fixname); name = dns_fixedname_initname(&fixname);
dns_rdataset_init(&rootns); dns_rdataset_init(&rootns);
@ -460,7 +458,7 @@ dns_root_checkhints(dns_view_t *view, dns_db_t *hints, dns_db_t *db) {
dns_rdata_ns_t ns; dns_rdata_ns_t ns;
dns_rdataset_t hintns, rootns; dns_rdataset_t hintns, rootns;
const char *viewname = "", *sep = ""; const char *viewname = "", *sep = "";
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
dns_name_t *name; dns_name_t *name;
dns_fixedname_t fixed; dns_fixedname_t fixed;
@ -468,8 +466,6 @@ dns_root_checkhints(dns_view_t *view, dns_db_t *hints, dns_db_t *db) {
REQUIRE(db != NULL); REQUIRE(db != NULL);
REQUIRE(view != NULL); REQUIRE(view != NULL);
isc_stdtime_get(&now);
if (strcmp(view->name, "_bind") != 0 && if (strcmp(view->name, "_bind") != 0 &&
strcmp(view->name, "_default") != 0) strcmp(view->name, "_default") != 0)
{ {

View File

@ -1342,7 +1342,7 @@ dns_rrl_init(dns_rrl_t **rrlp, dns_view_t *view, int min_entries) {
rrl = isc_mem_getx(view->mctx, sizeof(*rrl), ISC_MEM_ZERO); rrl = isc_mem_getx(view->mctx, sizeof(*rrl), ISC_MEM_ZERO);
isc_mem_attach(view->mctx, &rrl->mctx); isc_mem_attach(view->mctx, &rrl->mctx);
isc_mutex_init(&rrl->lock); isc_mutex_init(&rrl->lock);
isc_stdtime_get(&rrl->ts_bases[0]); rrl->ts_bases[0] = isc_stdtime_now();
view->rrl = rrl; view->rrl = rrl;

View File

@ -101,7 +101,7 @@ dns_time64_totext(int64_t t, isc_buffer_t *target) {
int64_t int64_t
dns_time64_from32(uint32_t value) { dns_time64_from32(uint32_t value) {
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
int64_t start; int64_t start;
int64_t t; int64_t t;
@ -111,7 +111,7 @@ dns_time64_from32(uint32_t value) {
* is defined, but even the current code is good until the year * is defined, but even the current code is good until the year
* 2106. * 2106.
*/ */
isc_stdtime_get(&now);
start = (int64_t)now; start = (int64_t)now;
if (isc_serial_gt(value, now)) { if (isc_serial_gt(value, now)) {
t = start + (value - now); t = start + (value - now);

View File

@ -180,7 +180,7 @@ process_gsstkey(dns_message_t *msg, dns_name_t *name, dns_rdata_tkey_t *tkeyin,
dns_tsigkey_t *tsigkey = NULL; dns_tsigkey_t *tsigkey = NULL;
dns_fixedname_t fixed; dns_fixedname_t fixed;
dns_name_t *principal; dns_name_t *principal;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
isc_region_t intoken; isc_region_t intoken;
isc_buffer_t *outtoken = NULL; isc_buffer_t *outtoken = NULL;
dns_gss_ctx_id_t gss_ctx = NULL; dns_gss_ctx_id_t gss_ctx = NULL;
@ -243,8 +243,6 @@ process_gsstkey(dns_message_t *msg, dns_name_t *name, dns_rdata_tkey_t *tkeyin,
* XXXDCL Section 4.1.3: Limit GSS_S_CONTINUE_NEEDED to 10 times. * XXXDCL Section 4.1.3: Limit GSS_S_CONTINUE_NEEDED to 10 times.
*/ */
isc_stdtime_get(&now);
if (dns_name_countlabels(principal) == 0U) { if (dns_name_countlabels(principal) == 0U) {
if (tsigkey != NULL) { if (tsigkey != NULL) {
dns_tsigkey_detach(&tsigkey); dns_tsigkey_detach(&tsigkey);
@ -685,7 +683,7 @@ dns_tkey_buildgssquery(dns_message_t *msg, const dns_name_t *name,
isc_mem_t *mctx, char **err_message) { isc_mem_t *mctx, char **err_message) {
dns_rdata_tkey_t tkey; dns_rdata_tkey_t tkey;
isc_result_t result; isc_result_t result;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
isc_buffer_t token; isc_buffer_t token;
unsigned char array[TEMP_BUFFER_SZ]; unsigned char array[TEMP_BUFFER_SZ];
@ -716,7 +714,6 @@ dns_tkey_buildgssquery(dns_message_t *msg, const dns_name_t *name,
dns_name_clone(DNS_TSIG_GSSAPI_NAME, &tkey.algorithm); dns_name_clone(DNS_TSIG_GSSAPI_NAME, &tkey.algorithm);
} }
isc_stdtime_get(&now);
tkey.inception = now; tkey.inception = now;
tkey.expire = now + lifetime; tkey.expire = now + lifetime;
tkey.mode = DNS_TKEYMODE_GSSAPI; tkey.mode = DNS_TKEYMODE_GSSAPI;

View File

@ -389,14 +389,13 @@ cleanup_ring(dns_tsig_keyring_t *ring) {
dns_name_t foundname; dns_name_t foundname;
dns_fixedname_t fixedorigin; dns_fixedname_t fixedorigin;
dns_name_t *origin; dns_name_t *origin;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
dns_rbtnode_t *node; dns_rbtnode_t *node;
dns_tsigkey_t *tkey; dns_tsigkey_t *tkey;
/* /*
* Start up a new iterator each time. * Start up a new iterator each time.
*/ */
isc_stdtime_get(&now);
dns_name_init(&foundname, NULL); dns_name_init(&foundname, NULL);
origin = dns_fixedname_initname(&fixedorigin); origin = dns_fixedname_initname(&fixedorigin);
@ -601,7 +600,7 @@ dns_tsigkeyring_dumpanddetach(dns_tsig_keyring_t **ringp, FILE *fp) {
dns_name_t foundname; dns_name_t foundname;
dns_fixedname_t fixedorigin; dns_fixedname_t fixedorigin;
dns_name_t *origin; dns_name_t *origin;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
dns_rbtnode_t *node; dns_rbtnode_t *node;
dns_tsigkey_t *tkey; dns_tsigkey_t *tkey;
dns_tsig_keyring_t *ring; dns_tsig_keyring_t *ring;
@ -615,7 +614,6 @@ dns_tsigkeyring_dumpanddetach(dns_tsig_keyring_t **ringp, FILE *fp) {
return (DNS_R_CONTINUE); return (DNS_R_CONTINUE);
} }
isc_stdtime_get(&now);
dns_name_init(&foundname, NULL); dns_name_init(&foundname, NULL);
origin = dns_fixedname_initname(&fixedorigin); origin = dns_fixedname_initname(&fixedorigin);
dns_rbtnodechain_init(&chain); dns_rbtnodechain_init(&chain);
@ -805,7 +803,7 @@ dns_tsig_sign(dns_message_t *msg) {
if (msg->fuzzing) { if (msg->fuzzing) {
now = msg->fuzztime; now = msg->fuzztime;
} else { } else {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
tsig.timesigned = now + msg->timeadjust; tsig.timesigned = now + msg->timeadjust;
@ -1159,7 +1157,7 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg,
if (msg->fuzzing) { if (msg->fuzzing) {
now = msg->fuzztime; now = msg->fuzztime;
} else { } else {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
/* /*
@ -1659,7 +1657,7 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) {
if (msg->fuzzing) { if (msg->fuzzing) {
now = msg->fuzztime; now = msg->fuzztime;
} else { } else {
isc_stdtime_get(&now); now = isc_stdtime_now();
} }
if (now + msg->timeadjust > tsig.timesigned + tsig.fudge) { if (now + msg->timeadjust > tsig.timesigned + tsig.fudge) {
@ -1738,7 +1736,7 @@ isc_result_t
dns_tsigkey_find(dns_tsigkey_t **tsigkey, const dns_name_t *name, dns_tsigkey_find(dns_tsigkey_t **tsigkey, const dns_name_t *name,
const dns_name_t *algorithm, dns_tsig_keyring_t *ring) { const dns_name_t *algorithm, dns_tsig_keyring_t *ring) {
dns_tsigkey_t *key; dns_tsigkey_t *key;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
isc_result_t result; isc_result_t result;
REQUIRE(tsigkey != NULL); REQUIRE(tsigkey != NULL);
@ -1750,7 +1748,6 @@ dns_tsigkey_find(dns_tsigkey_t **tsigkey, const dns_name_t *name,
cleanup_ring(ring); cleanup_ring(ring);
RWUNLOCK(&ring->lock, isc_rwlocktype_write); RWUNLOCK(&ring->lock, isc_rwlocktype_write);
isc_stdtime_get(&now);
RWLOCK(&ring->lock, isc_rwlocktype_read); RWLOCK(&ring->lock, isc_rwlocktype_read);
key = NULL; key = NULL;
result = dns_rbt_findname(ring->keys, name, 0, NULL, (void *)&key); result = dns_rbt_findname(ring->keys, name, 0, NULL, (void *)&key);
@ -1880,10 +1877,9 @@ dns_tsigkeyring_detach(dns_tsig_keyring_t **ringp) {
void void
dns_keyring_restore(dns_tsig_keyring_t *ring, FILE *fp) { dns_keyring_restore(dns_tsig_keyring_t *ring, FILE *fp) {
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
isc_result_t result; isc_result_t result;
isc_stdtime_get(&now);
do { do {
result = restore_key(ring, now, fp); result = restore_key(ring, now, fp);
if (result == ISC_R_NOMORE) { if (result == ISC_R_NOMORE) {

View File

@ -1059,12 +1059,11 @@ find_zone_keys(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver,
isc_mem_t *mctx, unsigned int maxkeys, dst_key_t **keys, isc_mem_t *mctx, unsigned int maxkeys, dst_key_t **keys,
unsigned int *nkeys) { unsigned int *nkeys) {
isc_result_t result; isc_result_t result;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
dns_dbnode_t *node = NULL; dns_dbnode_t *node = NULL;
const char *directory = dns_zone_getkeydirectory(zone); const char *directory = dns_zone_getkeydirectory(zone);
CHECK(dns_db_findnode(db, dns_db_origin(db), false, &node)); CHECK(dns_db_findnode(db, dns_db_origin(db), false, &node));
isc_stdtime_get(&now);
dns_zone_lock_keyfiles(zone); dns_zone_lock_keyfiles(zone);
result = dns_dnssec_findzonekeys(db, ver, node, dns_db_origin(db), result = dns_dnssec_findzonekeys(db, ver, node, dns_db_origin(db),
@ -1561,7 +1560,7 @@ dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db,
goto failure; goto failure;
} }
isc_stdtime_get(&now); now = isc_stdtime_now();
state->inception = now - 3600; /* Allow for some clock skew. */ state->inception = now - 3600; /* Allow for some clock skew. */
state->expire = now + state->expire = now +
dns__jitter_expire(zone, sigvalidityinterval); dns__jitter_expire(zone, sigvalidityinterval);
@ -2221,10 +2220,10 @@ dns__update_soaserial(uint32_t serial, dns_updatemethod_t method) {
case dns_updatemethod_none: case dns_updatemethod_none:
return (serial); return (serial);
case dns_updatemethod_unixtime: case dns_updatemethod_unixtime:
isc_stdtime_get(&now); now = isc_stdtime_now();
return (now); return (now);
case dns_updatemethod_date: case dns_updatemethod_date:
isc_stdtime_get(&now); now = isc_stdtime_now();
return (epoch_to_yyyymmdd((time_t)now) * 100); return (epoch_to_yyyymmdd((time_t)now) * 100);
case dns_updatemethod_increment: case dns_updatemethod_increment:
/* RFC1982 */ /* RFC1982 */

View File

@ -3019,7 +3019,7 @@ dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
dns_rdataset_init(&val->fsigrdataset); dns_rdataset_init(&val->fsigrdataset);
dns_fixedname_init(&val->wild); dns_fixedname_init(&val->wild);
dns_fixedname_init(&val->closest); dns_fixedname_init(&val->closest);
isc_stdtime_get(&val->start); val->start = isc_stdtime_now();
val->magic = VALIDATOR_MAGIC; val->magic = VALIDATOR_MAGIC;
if ((options & DNS_VALIDATOR_DEFER) == 0) { if ((options & DNS_VALIDATOR_DEFER) == 0) {

View File

@ -2017,7 +2017,7 @@ dns_view_loadnta(dns_view_t *view) {
dns_ntatable_t *ntatable = NULL; dns_ntatable_t *ntatable = NULL;
isc_lex_t *lex = NULL; isc_lex_t *lex = NULL;
isc_token_t token; isc_token_t token;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
REQUIRE(DNS_VIEW_VALID(view)); REQUIRE(DNS_VIEW_VALID(view));
@ -2028,7 +2028,6 @@ dns_view_loadnta(dns_view_t *view) {
isc_lex_create(view->mctx, 1025, &lex); isc_lex_create(view->mctx, 1025, &lex);
CHECK(isc_lex_openfile(lex, view->nta_file)); CHECK(isc_lex_openfile(lex, view->nta_file));
CHECK(dns_view_getntatable(view, &ntatable)); CHECK(dns_view_getntatable(view, &ntatable));
isc_stdtime_get(&now);
for (;;) { for (;;) {
int options = (ISC_LEXOPT_EOL | ISC_LEXOPT_EOF); int options = (ISC_LEXOPT_EOL | ISC_LEXOPT_EOF);

View File

@ -4003,12 +4003,11 @@ create_keydata(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver,
dns_rdata_keydata_t kd; dns_rdata_keydata_t kd;
unsigned char rrdata[4096]; unsigned char rrdata[4096];
isc_buffer_t rrdatabuf; isc_buffer_t rrdatabuf;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
REQUIRE(keynode != NULL); REQUIRE(keynode != NULL);
ENTER; ENTER;
isc_stdtime_get(&now);
/* /*
* If the keynode has no trust anchor set, we shouldn't be here. * If the keynode has no trust anchor set, we shouldn't be here.
@ -4169,11 +4168,9 @@ load_secroots(dns_zone_t *zone, dns_name_t *name, dns_rdataset_t *rdataset) {
dns_rdata_keydata_t keydata; dns_rdata_keydata_t keydata;
dns_rdata_dnskey_t dnskey; dns_rdata_dnskey_t dnskey;
int trusted = 0, revoked = 0, pending = 0; int trusted = 0, revoked = 0, pending = 0;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
dns_keytable_t *sr = NULL; dns_keytable_t *sr = NULL;
isc_stdtime_get(&now);
result = dns_view_getsecroots(zone->view, &sr); result = dns_view_getsecroots(zone->view, &sr);
if (result == ISC_R_SUCCESS) { if (result == ISC_R_SUCCESS) {
dns_keytable_delete(sr, name, sfd_del, zone->view); dns_keytable_delete(sr, name, sfd_del, zone->view);
@ -4513,13 +4510,11 @@ sync_keyzone(dns_zone_t *zone, dns_db_t *db) {
dns_rdataset_t *rdataset = NULL; dns_rdataset_t *rdataset = NULL;
dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdata_keydata_t keydata; dns_rdata_keydata_t keydata;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
bool load = true; bool load = true;
dns_name_t *rrname = NULL; dns_name_t *rrname = NULL;
uint32_t ttl; uint32_t ttl;
isc_stdtime_get(&now);
dns_rriterator_current(&rrit, &rrname, &ttl, &rdataset, NULL); dns_rriterator_current(&rrit, &rrname, &ttl, &rdataset, NULL);
if (!dns_rdataset_isassociated(rdataset)) { if (!dns_rdataset_isassociated(rdataset)) {
dns_rriterator_destroy(&rrit); dns_rriterator_destroy(&rrit);
@ -5158,11 +5153,10 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
result = dns_db_getsigningtime(db, &next, name); result = dns_db_getsigningtime(db, &next, name);
if (result == ISC_R_SUCCESS) { if (result == ISC_R_SUCCESS) {
isc_stdtime_t timenow; isc_stdtime_t timenow = isc_stdtime_now();
char namebuf[DNS_NAME_FORMATSIZE]; char namebuf[DNS_NAME_FORMATSIZE];
char typebuf[DNS_RDATATYPE_FORMATSIZE]; char typebuf[DNS_RDATATYPE_FORMATSIZE];
isc_stdtime_get(&timenow);
dns_name_format(name, namebuf, sizeof(namebuf)); dns_name_format(name, namebuf, sizeof(namebuf));
dns_rdatatype_format(next.covers, typebuf, dns_rdatatype_format(next.covers, typebuf,
sizeof(typebuf)); sizeof(typebuf));
@ -6832,7 +6826,7 @@ zone_resigninc(dns_zone_t *zone) {
goto failure; goto failure;
} }
isc_stdtime_get(&now); now = isc_stdtime_now();
result = dns__zone_findkeys(zone, db, version, now, zone->mctx, result = dns__zone_findkeys(zone, db, version, now, zone->mctx,
DNS_MAXZONEKEYS, zone_keys, &nkeys); DNS_MAXZONEKEYS, zone_keys, &nkeys);
@ -8048,7 +8042,7 @@ zone_nsec3chain(dns_zone_t *zone) {
goto failure; goto failure;
} }
isc_stdtime_get(&now); now = isc_stdtime_now();
result = dns__zone_findkeys(zone, db, version, now, zone->mctx, result = dns__zone_findkeys(zone, db, version, now, zone->mctx,
DNS_MAXZONEKEYS, zone_keys, &nkeys); DNS_MAXZONEKEYS, zone_keys, &nkeys);
@ -9136,7 +9130,7 @@ zone_sign(dns_zone_t *zone) {
goto cleanup; goto cleanup;
} }
isc_stdtime_get(&now); now = isc_stdtime_now();
result = dns__zone_findkeys(zone, db, version, now, zone->mctx, result = dns__zone_findkeys(zone, db, version, now, zone->mctx,
DNS_MAXZONEKEYS, zone_keys, &nkeys); DNS_MAXZONEKEYS, zone_keys, &nkeys);
@ -9792,9 +9786,7 @@ refresh_time(dns_keyfetch_t *kfetch, bool retry) {
dns_rdataset_t *rdset; dns_rdataset_t *rdset;
dns_rdata_t sigrr = DNS_RDATA_INIT; dns_rdata_t sigrr = DNS_RDATA_INIT;
dns_rdata_sig_t sig; dns_rdata_sig_t sig;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
isc_stdtime_get(&now);
if (dns_rdataset_isassociated(&kfetch->dnskeysigset)) { if (dns_rdataset_isassociated(&kfetch->dnskeysigset)) {
rdset = &kfetch->dnskeysigset; rdset = &kfetch->dnskeysigset;
@ -9864,10 +9856,9 @@ minimal_update(dns_keyfetch_t *kfetch, dns_dbversion_t *ver, dns_diff_t *diff) {
dns_rdata_keydata_t keydata; dns_rdata_keydata_t keydata;
dns_name_t *name; dns_name_t *name;
dns_zone_t *zone = kfetch->zone; dns_zone_t *zone = kfetch->zone;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
name = dns_fixedname_name(&kfetch->name); name = dns_fixedname_name(&kfetch->name);
isc_stdtime_get(&now);
for (result = dns_rdataset_first(&kfetch->keydataset); for (result = dns_rdataset_first(&kfetch->keydataset);
result == ISC_R_SUCCESS; result == ISC_R_SUCCESS;
@ -10041,7 +10032,7 @@ keyfetch_done(void *arg) {
goto cleanup; goto cleanup;
} }
isc_stdtime_get(&now); now = isc_stdtime_now();
dns_name_format(keyname, namebuf, sizeof(namebuf)); dns_name_format(keyname, namebuf, sizeof(namebuf));
result = dns_view_getsecroots(zone->view, &secroots); result = dns_view_getsecroots(zone->view, &secroots);
@ -10742,7 +10733,7 @@ zone_refreshkeys(dns_zone_t *zone) {
dns_diff_t diff; dns_diff_t diff;
dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdata_keydata_t kd; dns_rdata_keydata_t kd;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
bool commit = false; bool commit = false;
bool fetching = false; bool fetching = false;
bool timerset = false; bool timerset = false;
@ -10750,8 +10741,6 @@ zone_refreshkeys(dns_zone_t *zone) {
ENTER; ENTER;
REQUIRE(zone->db != NULL); REQUIRE(zone->db != NULL);
isc_stdtime_get(&now);
LOCK_ZONE(zone); LOCK_ZONE(zone);
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) { if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) {
isc_time_settoepoch(&zone->refreshkeytime); isc_time_settoepoch(&zone->refreshkeytime);

View File

@ -42,9 +42,8 @@ static atomic_uint_fast32_t last_tcpquota_log = 0;
static bool static bool
can_log_tcp_quota(void) { can_log_tcp_quota(void) {
isc_stdtime_t now, last; isc_stdtime_t last;
isc_stdtime_t now = isc_stdtime_now();
isc_stdtime_get(&now);
last = atomic_exchange_relaxed(&last_tcpquota_log, now); last = atomic_exchange_relaxed(&last_tcpquota_log, now);
if (now != last) { if (now != last) {
return (true); return (true);

View File

@ -997,11 +997,10 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message,
no_nsid: no_nsid:
if ((client->attributes & NS_CLIENTATTR_WANTCOOKIE) != 0) { if ((client->attributes & NS_CLIENTATTR_WANTCOOKIE) != 0) {
isc_buffer_t buf; isc_buffer_t buf;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
uint32_t nonce; uint32_t nonce;
isc_buffer_init(&buf, cookie, sizeof(cookie)); isc_buffer_init(&buf, cookie, sizeof(cookie));
isc_stdtime_get(&now);
isc_random_buf(&nonce, sizeof(nonce)); isc_random_buf(&nonce, sizeof(nonce));
@ -1292,7 +1291,7 @@ process_cookie(ns_client_t *client, isc_buffer_t *buf, size_t optlen) {
* Allow for a 5 minute clock skew between servers sharing a secret. * Allow for a 5 minute clock skew between servers sharing a secret.
* Only accept COOKIE if we have talked to the client in the last hour. * Only accept COOKIE if we have talked to the client in the last hour.
*/ */
isc_stdtime_get(&now); now = isc_stdtime_now();
if (isc_serial_gt(when, (now + 300)) || /* In the future. */ if (isc_serial_gt(when, (now + 300)) || /* In the future. */
isc_serial_lt(when, (now - 3600))) isc_serial_lt(when, (now - 3600)))
{ /* In the past. */ { /* In the past. */

View File

@ -2286,7 +2286,7 @@ mark_secure(ns_client_t *client, dns_db_t *db, dns_name_t *name,
return; return;
} }
isc_stdtime_get(&now); now = isc_stdtime_now();
dns_rdataset_trimttl(rdataset, sigrdataset, rrsig, now, dns_rdataset_trimttl(rdataset, sigrdataset, rrsig, now,
client->view->acceptexpired); client->view->acceptexpired);
@ -2583,7 +2583,7 @@ stale_refresh_aftermath(ns_client_t *client, isc_result_t result) {
* database, starting the stale-refresh-time window for it. * database, starting the stale-refresh-time window for it.
* This is a condensed form of query_lookup(). * This is a condensed form of query_lookup().
*/ */
isc_stdtime_get(&client->now); client->now = isc_stdtime_now();
client->query.attributes &= ~NS_QUERYATTR_RECURSIONOK; client->query.attributes &= ~NS_QUERYATTR_RECURSIONOK;
qctx_init(client, NULL, 0, &qctx); qctx_init(client, NULL, 0, &qctx);
@ -6280,7 +6280,7 @@ fetch_callback(void *arg) {
/* /*
* Update client->now. * Update client->now.
*/ */
isc_stdtime_get(&client->now); client->now = isc_stdtime_now();
} else { } else {
/* /*
* This is a fetch completion event for a canceled fetch. * This is a fetch completion event for a canceled fetch.
@ -6412,9 +6412,7 @@ recparam_update(ns_query_recparam_t *param, dns_rdatatype_t qtype,
static void static void
recursionquota_log(ns_client_t *client, atomic_uint_fast32_t *last_log_time, recursionquota_log(ns_client_t *client, atomic_uint_fast32_t *last_log_time,
const char *format, isc_quota_t *quota) { const char *format, isc_quota_t *quota) {
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
isc_stdtime_get(&now);
if (now == atomic_load_relaxed(last_log_time)) { if (now == atomic_load_relaxed(last_log_time)) {
return; return;
} }
@ -6757,7 +6755,7 @@ query_hookresume(void *arg) {
INSIST(rev->ctx == client->query.hookactx); INSIST(rev->ctx == client->query.hookactx);
client->query.hookactx = NULL; client->query.hookactx = NULL;
canceled = false; canceled = false;
isc_stdtime_get(&client->now); client->now = isc_stdtime_now();
} else { } else {
canceled = true; canceled = true;
} }

View File

@ -141,7 +141,8 @@ ISC_RUN_TEST_IMPL(dns_dt_send) {
isc_sockaddr_t qaddr; isc_sockaddr_t qaddr;
isc_sockaddr_t raddr; isc_sockaddr_t raddr;
struct in_addr in; struct in_addr in;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
isc_time_t p, f; isc_time_t p, f;
struct fstrm_iothr_options *fopt; struct fstrm_iothr_options *fopt;
@ -182,7 +183,6 @@ ISC_RUN_TEST_IMPL(dns_dt_send) {
in.s_addr = inet_addr("10.53.0.2"); in.s_addr = inet_addr("10.53.0.2");
isc_sockaddr_fromin(&raddr, &in, 2112); isc_sockaddr_fromin(&raddr, &in, 2112);
isc_stdtime_get(&now);
isc_time_set(&p, now - 3600, 0); /* past */ isc_time_set(&p, now - 3600, 0); /* past */
isc_time_set(&f, now + 3600, 0); /* future */ isc_time_set(&f, now + 3600, 0); /* future */

View File

@ -170,7 +170,7 @@ create_tables(void) {
dns_rdata_ds_t ds; dns_rdata_ds_t ds;
dns_fixedname_t fn; dns_fixedname_t fn;
dns_name_t *keyname = dns_fixedname_name(&fn); dns_name_t *keyname = dns_fixedname_name(&fn);
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
assert_int_equal(dns_test_makeview("view", false, &view), assert_int_equal(dns_test_makeview("view", false, &view),
ISC_R_SUCCESS); ISC_R_SUCCESS);
@ -199,7 +199,6 @@ create_tables(void) {
ISC_R_SUCCESS); ISC_R_SUCCESS);
/* Add a negative trust anchor, duration 1 hour */ /* Add a negative trust anchor, duration 1 hour */
isc_stdtime_get(&now);
assert_int_equal(dns_ntatable_add(ntatable, assert_int_equal(dns_ntatable_add(ntatable,
str2name("insecure.example"), false, str2name("insecure.example"), false,
now, 3600), now, 3600),
@ -604,7 +603,7 @@ ISC_LOOP_TEST_IMPL(nta) {
unsigned char digest[ISC_MAX_MD_SIZE]; unsigned char digest[ISC_MAX_MD_SIZE];
dns_rdata_ds_t ds; dns_rdata_ds_t ds;
dns_view_t *myview = NULL; dns_view_t *myview = NULL;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
result = dns_test_makeview("view", false, &myview); result = dns_test_makeview("view", false, &myview);
assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(result, ISC_R_SUCCESS);
@ -625,7 +624,6 @@ ISC_LOOP_TEST_IMPL(nta) {
NULL), NULL),
assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(result, ISC_R_SUCCESS);
isc_stdtime_get(&now);
result = dns_ntatable_add(ntatable, str2name("insecure.example"), false, result = dns_ntatable_add(ntatable, str2name("insecure.example"), false,
now, 1); now, 1);
assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(result, ISC_R_SUCCESS);

View File

@ -294,7 +294,7 @@ ISC_RUN_TEST_IMPL(updatesigs_next) {
dns_db_t *db = NULL; dns_db_t *db = NULL;
isc_result_t result; isc_result_t result;
unsigned int nkeys; unsigned int nkeys;
isc_stdtime_t now; isc_stdtime_t now = isc_stdtime_now();
size_t i; size_t i;
UNUSED(state); UNUSED(state);
@ -313,7 +313,6 @@ ISC_RUN_TEST_IMPL(updatesigs_next) {
result = dns_zone_setkeydirectory(zone, TESTS_DIR "/testkeys"); result = dns_zone_setkeydirectory(zone, TESTS_DIR "/testkeys");
assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(result, ISC_R_SUCCESS);
isc_stdtime_get(&now);
result = dns__zone_findkeys(zone, db, NULL, now, mctx, DNS_MAXZONEKEYS, result = dns__zone_findkeys(zone, db, NULL, now, mctx, DNS_MAXZONEKEYS,
zone_keys, &nkeys); zone_keys, &nkeys);
assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(result, ISC_R_SUCCESS);

View File

@ -104,7 +104,6 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target) {
isc_buffer_t sigbuf; isc_buffer_t sigbuf;
isc_region_t r; isc_region_t r;
isc_result_t result = ISC_R_SUCCESS; isc_result_t result = ISC_R_SUCCESS;
isc_stdtime_t now;
unsigned char tsigbuf[1024]; unsigned char tsigbuf[1024];
unsigned int count; unsigned int count;
unsigned int sigsize = 0; unsigned int sigsize = 0;
@ -119,8 +118,7 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target) {
dns_name_init(&tsig.algorithm, NULL); dns_name_init(&tsig.algorithm, NULL);
dns_name_clone(key->algorithm, &tsig.algorithm); dns_name_clone(key->algorithm, &tsig.algorithm);
isc_stdtime_get(&now); tsig.timesigned = isc_stdtime_now();
tsig.timesigned = now;
tsig.fudge = DNS_TSIG_FUDGE; tsig.fudge = DNS_TSIG_FUDGE;
tsig.originalid = 50; tsig.originalid = 50;
tsig.error = dns_rcode_noerror; tsig.error = dns_rcode_noerror;

View File

@ -67,9 +67,9 @@ set_mystdtime(int year, int month, int day) {
mystdtime = timegm(&tm); mystdtime = timegm(&tm);
} }
void isc_stdtime_t
isc_stdtime_get(isc_stdtime_t *now) { isc_stdtime_now(void) {
*now = mystdtime; return (mystdtime);
} }
/* simple increment by 1 */ /* simple increment by 1 */