Commit c8aa1ee9 authored by Witold Krecicki's avatar Witold Krecicki
Browse files

libdns refactoring: get rid of multiple versions of dns_dt_create,...

libdns refactoring: get rid of multiple versions of dns_dt_create, dns_view_setcache, dns_zt_apply, dns_message_logfmtpacket, dns_message_logpacket, dns_ssutable_checkrules and dns_ttl_totext
parent d54d482a
......@@ -4229,7 +4229,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist,
ISC_LINK_INIT(nsc, link);
ISC_LIST_APPEND(*cachelist, nsc, link);
}
dns_view_setcache2(view, cache, shared_cache);
dns_view_setcache(view, cache, shared_cache);
/*
* cache-file cannot be inherited if views are present, but this
......@@ -9013,7 +9013,7 @@ load_configuration(const char *filename, named_server_t *server,
{
dns_view_setviewrevert(view);
(void)dns_zt_apply(view->zonetable, ISC_FALSE,
removed, view);
NULL, removed, view);
}
dns_view_detach(&view);
}
......@@ -10380,7 +10380,7 @@ add_view_tolist(struct dumpcontext *dctx, dns_view_t *view) {
ISC_LIST_INIT(vle->zonelist);
ISC_LIST_APPEND(dctx->viewlist, vle, link);
if (dctx->dumpzones)
result = dns_zt_apply(view->zonetable, ISC_TRUE,
result = dns_zt_apply(view->zonetable, ISC_TRUE, NULL,
add_zone_tolist, dctx);
return (result);
}
......@@ -11622,7 +11622,7 @@ named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
view != NULL;
view = ISC_LIST_NEXT(view, link)) {
result = dns_zt_apply(view->zonetable, ISC_FALSE,
synczone, &cleanup);
NULL, synczone, &cleanup);
if (result != ISC_R_SUCCESS &&
tresult == ISC_R_SUCCESS)
tresult = result;
......
......@@ -1916,7 +1916,7 @@ generatexml(named_server_t *server, isc_uint32_t flags,
TRY0(xmlTextWriterStartElement(writer,
ISC_XMLCHAR "zones"));
result = dns_zt_apply(view->zonetable, ISC_TRUE,
zone_xmlrender, writer);
NULL, zone_xmlrender, writer);
if (result != ISC_R_SUCCESS)
goto error;
TRY0(xmlTextWriterEndElement(writer)); /* /zones */
......@@ -2609,8 +2609,10 @@ generatejson(named_server_t *server, size_t *msglen,
CHECKMEM(za);
if ((flags & STATS_JSON_ZONES) != 0) {
result = dns_zt_apply(view->zonetable, ISC_TRUE,
zone_jsonrender, za);
result = dns_zt_apply(view->zonetable,
ISC_TRUE,
NULL, zone_jsonrender,
za);
if (result != ISC_R_SUCCESS) {
goto error;
}
......
......@@ -184,7 +184,7 @@ create_view(void) {
dns_rdataclass_in, "", "rbt", 0, NULL,
&cache);
check_result(result, "dns_cache_create");
dns_view_setcache(view, cache);
dns_view_setcache(view, cache, ISC_FALSE);
dns_cache_detach(&cache);
{
......
......@@ -205,7 +205,7 @@ main(int argc, char *argv[]) {
== ISC_R_SUCCESS);
}
dns_view_setcache(view, cache);
dns_view_setcache(view, cache, ISC_FALSE);
dns_view_freeze(view);
dns_cache_detach(&cache);
......
......@@ -322,7 +322,7 @@ main(int argc, char *argv[]) {
== ISC_R_SUCCESS);
}
dns_view_setcache(view, cache);
dns_view_setcache(view, cache, ISC_FALSE);
dns_view_freeze(view);
dns_cache_detach(&cache);
......
......@@ -77,7 +77,7 @@ bdb_putrdata(DB *db, dns_name_t *name, dns_ttl_t ttl, dns_rdata_t *rdata)
isc_buffer_init(&databuf, rdatatext, MAX_RDATATEXT);
dns_ttl_totext(ttl, ISC_FALSE, &databuf);
dns_ttl_totext(ttl, ISC_FALSE, ISC_TRUE, &databuf);
*(char *)isc_buffer_used(&databuf) = ' ';
isc_buffer_add(&databuf, 1);
......
......@@ -185,15 +185,8 @@ unlock:
isc_result_t
dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
struct fstrm_iothr_options **foptp, dns_dtenv_t **envp)
{
return (dns_dt_create2(mctx, mode, path, foptp, NULL, envp));
}
isc_result_t
dns_dt_create2(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
struct fstrm_iothr_options **foptp, isc_task_t *reopen_task,
dns_dtenv_t **envp)
struct fstrm_iothr_options **foptp, isc_task_t *reopen_task,
dns_dtenv_t **envp)
{
isc_result_t result = ISC_R_SUCCESS;
fstrm_res res;
......
......@@ -118,12 +118,8 @@ struct dns_dtdata {
isc_result_t
dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
struct fstrm_iothr_options **foptp, dns_dtenv_t **envp);
isc_result_t
dns_dt_create2(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
struct fstrm_iothr_options **foptp, isc_task_t *reopen_task,
dns_dtenv_t **envp);
struct fstrm_iothr_options **foptp, isc_task_t *reopen_task,
dns_dtenv_t **envp);
/*%<
* Create and initialize the dnstap environment.
*
......
......@@ -1375,25 +1375,17 @@ dns_message_gettimeadjust(dns_message_t *msg);
*/
void
dns_message_logpacket(dns_message_t *message, const char *description,
dns_message_logpacket(dns_message_t *message,
const char *description, const isc_sockaddr_t *address,
isc_logcategory_t *category, isc_logmodule_t *module,
int level, isc_mem_t *mctx);
void
dns_message_logpacket2(dns_message_t *message,
const char *description, const isc_sockaddr_t *address,
isc_logcategory_t *category, isc_logmodule_t *module,
int level, isc_mem_t *mctx);
void
dns_message_logfmtpacket(dns_message_t *message, const char *description,
const isc_sockaddr_t *address,
isc_logcategory_t *category, isc_logmodule_t *module,
const dns_master_style_t *style, int level,
isc_mem_t *mctx);
void
dns_message_logfmtpacket2(dns_message_t *message, const char *description,
const isc_sockaddr_t *address,
isc_logcategory_t *category, isc_logmodule_t *module,
const dns_master_style_t *style, int level,
isc_mem_t *mctx);
/*%<
* Log 'message' at the specified logging parameters.
*
......
......@@ -129,10 +129,6 @@ dns_ssutable_addrule(dns_ssutable_t *table, isc_boolean_t grant,
isc_boolean_t
dns_ssutable_checkrules(dns_ssutable_t *table, const dns_name_t *signer,
const dns_name_t *name, const isc_netaddr_t *addr,
dns_rdatatype_t type, const dst_key_t *key);
isc_boolean_t
dns_ssutable_checkrules2(dns_ssutable_t *table, const dns_name_t *signer,
const dns_name_t *name, const isc_netaddr_t *addr,
isc_boolean_t tcp, const dns_aclenv_t *env,
dns_rdatatype_t type, const dst_key_t *key);
......
......@@ -31,10 +31,7 @@ ISC_LANG_BEGINDECLS
isc_result_t
dns_ttl_totext(isc_uint32_t src, isc_boolean_t verbose,
isc_buffer_t *target);
isc_result_t
dns_ttl_totext2(isc_uint32_t src, isc_boolean_t verbose,
isc_boolean_t upcase, isc_buffer_t *target);
isc_boolean_t upcase, isc_buffer_t *target);
/*%<
* Output a TTL or other time interval in a human-readable form.
* The time interval is given as a count of seconds in 'src'.
......
......@@ -416,9 +416,7 @@ dns_view_createresolver(dns_view_t *view,
*/
void
dns_view_setcache(dns_view_t *view, dns_cache_t *cache);
void
dns_view_setcache2(dns_view_t *view, dns_cache_t *cache, isc_boolean_t shared);
dns_view_setcache(dns_view_t *view, dns_cache_t *cache, isc_boolean_t shared);
/*%<
* Set the view's cache database. If 'shared' is true, this means the cache
* is created by another view and is shared with that view. dns_view_setcache()
......
......@@ -172,12 +172,8 @@ dns_zt_freezezones(dns_zt_t *zt, isc_boolean_t freeze);
*/
isc_result_t
dns_zt_apply(dns_zt_t *zt, isc_boolean_t stop,
dns_zt_apply(dns_zt_t *zt, isc_boolean_t stop, isc_result_t *sub,
isc_result_t (*action)(dns_zone_t *, void *), void *uap);
isc_result_t
dns_zt_apply2(dns_zt_t *zt, isc_boolean_t stop, isc_result_t *sub,
isc_result_t (*action)(dns_zone_t *, void *), void *uap);
/*%<
* Apply a given 'action' to all zone zones in the table.
* If 'stop' is 'ISC_TRUE' then walking the zone tree will stop if
......
......@@ -558,7 +558,7 @@ rdataset_totext(dns_rdataset_t *rdataset,
INDENT_TO(ttl_column);
if ((ctx->style.flags & DNS_STYLEFLAG_TTL_UNITS) != 0) {
length = target->used;
result = dns_ttl_totext2(rdataset->ttl,
result = dns_ttl_totext(rdataset->ttl,
ISC_FALSE, ISC_FALSE,
target);
if (result != ISC_R_SUCCESS)
......@@ -880,7 +880,8 @@ dump_rdataset(isc_mem_t *mctx, const dns_name_t *name,
{
isc_buffer_clear(buffer);
result = dns_ttl_totext(rdataset->ttl,
ISC_TRUE, buffer);
ISC_TRUE, ISC_TRUE,
buffer);
INSIST(result == ISC_R_SUCCESS);
isc_buffer_usedregion(buffer, &r);
fprintf(f, "$TTL %u\t; %.*s\n", rdataset->ttl,
......
......@@ -3604,6 +3604,7 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg,
ADD_STRING(target, buf);
ADD_STRING(target, " (");
result = dns_ttl_totext(secs,
ISC_TRUE,
ISC_TRUE,
target);
if (result != ISC_R_SUCCESS)
......@@ -3855,6 +3856,7 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
ADD_STRING(target, buf);
ADD_STRING(target, " (");
result = dns_ttl_totext(secs,
ISC_TRUE,
ISC_TRUE,
target);
if (result != ISC_R_SUCCESS)
......@@ -4248,19 +4250,10 @@ dns_opcode_totext(dns_opcode_t opcode, isc_buffer_t *target) {
}
void
dns_message_logpacket(dns_message_t *message, const char *description,
dns_message_logpacket(dns_message_t *message,
const char *description, const isc_sockaddr_t *address,
isc_logcategory_t *category, isc_logmodule_t *module,
int level, isc_mem_t *mctx)
{
logfmtpacket(message, description, NULL, category, module,
&dns_master_style_debug, level, mctx);
}
void
dns_message_logpacket2(dns_message_t *message,
const char *description, const isc_sockaddr_t *address,
isc_logcategory_t *category, isc_logmodule_t *module,
int level, isc_mem_t *mctx)
{
REQUIRE(address != NULL);
......@@ -4269,22 +4262,12 @@ dns_message_logpacket2(dns_message_t *message,
}
void
dns_message_logfmtpacket(dns_message_t *message, const char *description,
dns_message_logfmtpacket(dns_message_t *message,
const char *description,
const isc_sockaddr_t *address,
isc_logcategory_t *category, isc_logmodule_t *module,
const dns_master_style_t *style, int level,
isc_mem_t *mctx)
{
logfmtpacket(message, description, NULL, category, module, style,
level, mctx);
}
void
dns_message_logfmtpacket2(dns_message_t *message,
const char *description,
const isc_sockaddr_t *address,
isc_logcategory_t *category, isc_logmodule_t *module,
const dns_master_style_t *style, int level,
isc_mem_t *mctx)
{
REQUIRE(address != NULL);
......
......@@ -138,7 +138,8 @@ totext_soa(ARGS_TOTEXT) {
/* Print times in week/day/hour/minute/second form */
if (i >= 1) {
RETERR(str_totext(" (", target));
RETERR(dns_ttl_totext(num, ISC_TRUE, target));
RETERR(dns_ttl_totext(num, ISC_TRUE,
ISC_TRUE, target));
RETERR(str_totext(")", target));
}
RETERR(str_totext(tctx->linebreak, target));
......
......@@ -2762,13 +2762,13 @@ resquery_send(resquery_t *query) {
/*
* Log the outgoing packet.
*/
dns_message_logfmtpacket2(fctx->qmessage, "sending packet to",
&query->addrinfo->sockaddr,
DNS_LOGCATEGORY_RESOLVER,
DNS_LOGMODULE_PACKETS,
&dns_master_style_comment,
ISC_LOG_DEBUG(11),
fctx->res->mctx);
dns_message_logfmtpacket(fctx->qmessage, "sending packet to",
&query->addrinfo->sockaddr,
DNS_LOGCATEGORY_RESOLVER,
DNS_LOGMODULE_PACKETS,
&dns_master_style_comment,
ISC_LOG_DEBUG(11),
fctx->res->mctx);
/*
* We're now done with the query message.
......@@ -7692,13 +7692,13 @@ rctx_edns(respctx_t *rctx) {
fctx->rmessage->rcode == dns_rcode_yxdomain) &&
bad_edns(fctx, &query->addrinfo->sockaddr))
{
dns_message_logpacket2(fctx->rmessage,
"received packet (bad edns) from",
&query->addrinfo->sockaddr,
DNS_LOGCATEGORY_RESOLVER,
DNS_LOGMODULE_RESOLVER,
ISC_LOG_DEBUG(3),
fctx->res->mctx);
dns_message_logpacket(fctx->rmessage,
"received packet (bad edns) from",
&query->addrinfo->sockaddr,
DNS_LOGCATEGORY_RESOLVER,
DNS_LOGMODULE_RESOLVER,
ISC_LOG_DEBUG(3),
fctx->res->mctx);
dns_adb_changeflags(fctx->adb, query->addrinfo,
DNS_FETCHOPT_NOEDNS0,
DNS_FETCHOPT_NOEDNS0);
......@@ -7720,12 +7720,12 @@ rctx_edns(respctx_t *rctx) {
* should be safe to do for any rcode we limit it to NOERROR
* and NXDOMAIN.
*/
dns_message_logpacket2(fctx->rmessage,
"received packet (no opt) from",
&query->addrinfo->sockaddr,
DNS_LOGCATEGORY_RESOLVER,
DNS_LOGMODULE_RESOLVER,
ISC_LOG_DEBUG(3), fctx->res->mctx);
dns_message_logpacket(fctx->rmessage,
"received packet (no opt) from",
&query->addrinfo->sockaddr,
DNS_LOGCATEGORY_RESOLVER,
DNS_LOGMODULE_RESOLVER,
ISC_LOG_DEBUG(3), fctx->res->mctx);
dns_adb_changeflags(fctx->adb, query->addrinfo,
DNS_FETCHOPT_NOEDNS0,
DNS_FETCHOPT_NOEDNS0);
......@@ -9221,14 +9221,14 @@ rctx_logpacket(respctx_t *rctx) {
isc_buffer_t zb;
#endif /* HAVE_DNSTAP */
dns_message_logfmtpacket2(rctx->fctx->rmessage,
"received packet from",
&rctx->query->addrinfo->sockaddr,
DNS_LOGCATEGORY_RESOLVER,
DNS_LOGMODULE_PACKETS,
&dns_master_style_comment,
ISC_LOG_DEBUG(10),
rctx->fctx->res->mctx);
dns_message_logfmtpacket(rctx->fctx->rmessage,
"received packet from",
&rctx->query->addrinfo->sockaddr,
DNS_LOGCATEGORY_RESOLVER,
DNS_LOGMODULE_PACKETS,
&dns_master_style_comment,
ISC_LOG_DEBUG(10),
rctx->fctx->res->mctx);
#ifdef HAVE_DNSTAP
/*
......
......@@ -343,19 +343,9 @@ stf_from_address(dns_name_t *stfself, const isc_netaddr_t *tcpaddr) {
isc_boolean_t
dns_ssutable_checkrules(dns_ssutable_t *table, const dns_name_t *signer,
const dns_name_t *name, const isc_netaddr_t *tcpaddr,
const dns_name_t *name, const isc_netaddr_t *addr,
isc_boolean_t tcp, const dns_aclenv_t *env,
dns_rdatatype_t type, const dst_key_t *key)
{
return (dns_ssutable_checkrules2
(table, signer, name, tcpaddr,
tcpaddr == NULL ? ISC_FALSE : ISC_TRUE,
NULL, type, key));
}
isc_boolean_t
dns_ssutable_checkrules2(dns_ssutable_t *table, const dns_name_t *signer,
const dns_name_t *name, const isc_netaddr_t *addr,
isc_boolean_t tcp, const dns_aclenv_t *env,
dns_rdatatype_t type, const dst_key_t *key)
{
dns_ssurule_t *rule;
unsigned int i;
......
......@@ -72,7 +72,7 @@ ATF_TC_BODY(create, tc) {
ATF_REQUIRE(fopt != NULL);
fstrm_iothr_options_set_num_input_queues(fopt, 1);
result = dns_dt_create(mctx, dns_dtmode_file, TAPFILE, &fopt, &dtenv);
result = dns_dt_create(mctx, dns_dtmode_file, TAPFILE, &fopt, NULL, &dtenv);
ATF_CHECK_EQ(result, ISC_R_SUCCESS);
if (dtenv != NULL)
dns_dt_detach(&dtenv);
......@@ -85,7 +85,7 @@ ATF_TC_BODY(create, tc) {
ATF_REQUIRE(fopt != NULL);
fstrm_iothr_options_set_num_input_queues(fopt, 1);
result = dns_dt_create(mctx, dns_dtmode_unix, TAPSOCK, &fopt, &dtenv);
result = dns_dt_create(mctx, dns_dtmode_unix, TAPSOCK, &fopt, NULL, &dtenv);
ATF_CHECK_EQ(result, ISC_R_SUCCESS);
if (dtenv != NULL)
dns_dt_detach(&dtenv);
......@@ -99,7 +99,7 @@ ATF_TC_BODY(create, tc) {
ATF_REQUIRE(fopt != NULL);
fstrm_iothr_options_set_num_input_queues(fopt, 1);
result = dns_dt_create(mctx, 33, TAPSOCK, &fopt, &dtenv);
result = dns_dt_create(mctx, 33, TAPSOCK, &fopt, NULL, &dtenv);
ATF_CHECK_EQ(result, ISC_R_FAILURE);
ATF_CHECK_EQ(dtenv, NULL);
if (dtenv != NULL)
......@@ -154,7 +154,7 @@ ATF_TC_BODY(send, tc) {
ATF_REQUIRE(fopt != NULL);
fstrm_iothr_options_set_num_input_queues(fopt, 1);
result = dns_dt_create(mctx, dns_dtmode_file, TAPFILE, &fopt, &dtenv);
result = dns_dt_create(mctx, dns_dtmode_file, TAPFILE, &fopt, NULL, &dtenv);
ATF_REQUIRE(result == ISC_R_SUCCESS);
dns_dt_attach(dtenv, &view->dtenv);
......
......@@ -118,7 +118,8 @@ ATF_TC_BODY(apply, tc) {
ATF_REQUIRE(view->zonetable != NULL);
ATF_CHECK_EQ(0, nzones);
result = dns_zt_apply(view->zonetable, ISC_FALSE, count_zone, &nzones);
result = dns_zt_apply(view->zonetable, ISC_FALSE, NULL, count_zone,
&nzones);
ATF_CHECK_EQ(result, ISC_R_SUCCESS);
ATF_CHECK_EQ(1, nzones);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment