diff --git a/services/authzone.c b/services/authzone.c index d41f76587..0e0e74ef6 100644 --- a/services/authzone.c +++ b/services/authzone.c @@ -1390,9 +1390,6 @@ az_insert_rr_decompress(struct auth_zone* z, uint8_t* pkt, size_t pktlen, } rr = sldns_buffer_begin(scratch_buffer); rr_len = sldns_buffer_limit(scratch_buffer); - char buf[512]; - (void)sldns_wire2str_rr_buf(rr, rr_len, buf, sizeof(buf)); - log_info("decompress is %s", buf); dname_len = dname_valid(rr, rr_len); return az_insert_rr(z, rr, rr_len, dname_len, duplicate); } @@ -1685,8 +1682,8 @@ xfr_find_soa(struct auth_zone* z, struct auth_xfer* xfr) d = soa->data; xfr->have_zone = 1; xfr->serial = sldns_read_uint32(d->rr_data[0]+(d->rr_len[0]-20)); - xfr->retry = sldns_read_uint32(d->rr_data[0]+(d->rr_len[0]-16)); - xfr->refresh = sldns_read_uint32(d->rr_data[0]+(d->rr_len[0]-12)); + xfr->refresh = sldns_read_uint32(d->rr_data[0]+(d->rr_len[0]-16)); + xfr->retry = sldns_read_uint32(d->rr_data[0]+(d->rr_len[0]-12)); xfr->expiry = sldns_read_uint32(d->rr_data[0]+(d->rr_len[0]-8)); /* soa minimum at d->rr_len[0]-4 */ return 1; @@ -3974,6 +3971,12 @@ xfr_process_chunk_list(struct auth_xfer* xfr, struct module_env* env, /* unlock */ lock_rw_unlock(&z->lock); + if(verbosity >= VERB_QUERY && xfr->have_zone) { + char zname[256]; + dname_str(xfr->name, zname); + verbose(VERB_QUERY, "auth zone %s updated to serial %u", zname, + (unsigned)xfr->serial); + } /* see if we need to write to a zonefile */ xfr_write_after_update(xfr, env); return 1; diff --git a/testcode/fake_event.c b/testcode/fake_event.c index 016d2d8ad..034f3ee56 100644 --- a/testcode/fake_event.c +++ b/testcode/fake_event.c @@ -158,6 +158,7 @@ repevt_string(enum replay_event_type t) case repevt_back_reply: return "REPLY"; case repevt_back_query: return "CHECK_OUT_QUERY"; case repevt_autotrust_check: return "CHECK_AUTOTRUST"; + case repevt_tempfile_check: return "CHECK_TEMPFILE"; case repevt_error: return "ERROR"; case repevt_assign: return "ASSIGN"; case repevt_traffic: return "TRAFFIC"; @@ -611,6 +612,59 @@ autotrust_check(struct replay_runtime* runtime, struct replay_moment* mom) log_info("autotrust %s is OK", mom->autotrust_id); } +/** check tempfile file contents */ +static void +tempfile_check(struct replay_runtime* runtime, struct replay_moment* mom) +{ + char name[1024], line[1024]; + FILE *in; + int lineno = 0, oke=1; + char* expanded; + struct config_strlist* p; + line[sizeof(line)-1] = 0; + log_assert(mom->autotrust_id); + fake_temp_file("_temp_", mom->autotrust_id, name, sizeof(name)); + in = fopen(name, "r"); + if(!in) fatal_exit("could not open %s: %s", name, strerror(errno)); + for(p=mom->file_content; p; p=p->next) { + lineno++; + if(!fgets(line, (int)sizeof(line)-1, in)) { + log_err("tempfile check failed, could not read line"); + log_err("file %s, line %d", name, lineno); + log_err("should be: %s", p->str); + fatal_exit("tempfile_check failed"); + } + if(line[0]) line[strlen(line)-1] = 0; /* remove newline */ + expanded = macro_process(runtime->vars, runtime, p->str); + if(!expanded) + fatal_exit("could not expand macro line %d", lineno); + if(verbosity >= 7 && strcmp(p->str, expanded) != 0) + log_info("expanded '%s' to '%s'", p->str, expanded); + if(strcmp(expanded, line) != 0) { + log_err("mismatch in file %s, line %d", name, lineno); + log_err("file has : %s", line); + log_err("should be: %s", expanded); + free(expanded); + oke = 0; + continue; + } + free(expanded); + fprintf(stderr, "%s:%2d ok : %s\n", name, lineno, line); + } + if(fgets(line, (int)sizeof(line)-1, in)) { + log_err("tempfile check failed, extra lines in %s after %d", + name, lineno); + do { + fprintf(stderr, "file has: %s", line); + } while(fgets(line, (int)sizeof(line)-1, in)); + oke = 0; + } + fclose(in); + if(!oke) + fatal_exit("tempfile_check STEP %d failed", mom->time_step); + log_info("tempfile %s is OK", mom->autotrust_id); +} + /** Store RTT in infra cache */ static void do_infra_rtt(struct replay_runtime* runtime) @@ -720,6 +774,10 @@ do_moment_and_advance(struct replay_runtime* runtime) autotrust_check(runtime, runtime->now); advance_moment(runtime); break; + case repevt_tempfile_check: + tempfile_check(runtime, runtime->now); + advance_moment(runtime); + break; case repevt_assign: moment_assign(runtime, runtime->now); advance_moment(runtime); diff --git a/testcode/replay.c b/testcode/replay.c index 085c31475..08d87470b 100644 --- a/testcode/replay.c +++ b/testcode/replay.c @@ -323,6 +323,15 @@ replay_moment_read(char* remain, FILE* in, const char* name, mom->autotrust_id = strdup(remain); if(!mom->autotrust_id) fatal_exit("out of memory"); read_file_content(in, &pstate->lineno, mom); + } else if(parse_keyword(&remain, "CHECK_TEMPFILE")) { + mom->evt_type = repevt_tempfile_check; + while(isspace((unsigned char)*remain)) + remain++; + if(strlen(remain)>0 && remain[strlen(remain)-1]=='\n') + remain[strlen(remain)-1] = 0; + mom->autotrust_id = strdup(remain); + if(!mom->autotrust_id) fatal_exit("out of memory"); + read_file_content(in, &pstate->lineno, mom); } else if(parse_keyword(&remain, "ERROR")) { mom->evt_type = repevt_error; } else if(parse_keyword(&remain, "TRAFFIC")) { diff --git a/testcode/replay.h b/testcode/replay.h index d77ee0275..81f0a2c27 100644 --- a/testcode/replay.h +++ b/testcode/replay.h @@ -83,6 +83,7 @@ * the step waits for traffic to stop. * o CHECK_AUTOTRUST [id] - followed by FILE_BEGIN [to match] FILE_END. * The file contents is macro expanded before match. + * o CHECK_TEMPFILE [fname] - followed by FILE_BEGIN [to match] FILE_END * o INFRA_RTT [ip] [dp] [rtt] - update infra cache entry with rtt. * o ERROR * ; following entry starts on the next line, ENTRY_BEGIN. @@ -203,6 +204,8 @@ struct replay_moment { repevt_back_query, /** check autotrust key file */ repevt_autotrust_check, + /** check a temp file */ + repevt_tempfile_check, /** an error happens to outbound query */ repevt_error, /** assignment to a variable */ diff --git a/testdata/auth_xfr.rpl b/testdata/auth_xfr.rpl index b1610202c..effa5c5ff 100644 --- a/testdata/auth_xfr.rpl +++ b/testdata/auth_xfr.rpl @@ -203,4 +203,30 @@ ENTRY_END STEP 30 TIME_PASSES ELAPSE 10 STEP 40 TRAFFIC +STEP 50 QUERY +ENTRY_BEGIN +REPLY RD +SECTION QUESTION +www.example.com. IN A +ENTRY_END + +; recursion happens here. +STEP 60 CHECK_ANSWER +ENTRY_BEGIN +MATCH all +REPLY QR AA RD RA NOERROR +SECTION QUESTION +www.example.com. IN A +SECTION ANSWER +www.example.com. IN A 1.2.3.4 +ENTRY_END + +; the zonefile was updated with new contents +STEP 70 CHECK_TEMPFILE example.com +FILE_BEGIN +example.com. 3600 IN SOA ns.example.com. hostmaster.example.com. 1 3600 900 86400 3600 +example.com. 3600 IN NS ns.example.net. +www.example.com. 3600 IN A 1.2.3.4 +FILE_END + SCENARIO_END