From 368764838469039a4308e1268a1a6d6932fe7936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 13:09:45 +0200 Subject: [PATCH 01/18] libdns refactoring: get rid of two versions of dns_acl_match and dns_aclelement_match --- bin/named/controlconf.c | 3 ++- bin/named/statschannel.c | 2 +- lib/dns/acl.c | 49 +++++++++++-------------------------- lib/dns/dispatch.c | 3 ++- lib/dns/dns64.c | 20 ++++++++------- lib/dns/include/dns/acl.h | 27 +++++--------------- lib/dns/request.c | 2 +- lib/dns/resolver.c | 7 +++--- lib/dns/rrl.c | 5 ++-- lib/dns/ssu.c | 5 ++-- lib/dns/win32/libdns.def.in | 2 -- lib/dns/zone.c | 6 ++--- lib/ns/client.c | 24 +++++++++--------- lib/ns/interfacemgr.c | 9 ++++--- lib/ns/sortlist.c | 10 +++++--- 15 files changed, 75 insertions(+), 99 deletions(-) diff --git a/bin/named/controlconf.c b/bin/named/controlconf.c index fc0a914b17..c859f1ebd5 100644 --- a/bin/named/controlconf.c +++ b/bin/named/controlconf.c @@ -230,7 +230,8 @@ address_ok(isc_sockaddr_t *sockaddr, dns_acl_t *acl) { isc_netaddr_fromsockaddr(&netaddr, sockaddr); - result = dns_acl_match(&netaddr, NULL, acl, env, &match, NULL); + result = dns_acl_match(&netaddr, NULL, NULL, 0, NULL, acl, env, &match, + NULL); if (result != ISC_R_SUCCESS || match <= 0) return (ISC_FALSE); diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index f73eacd32a..3a8a0003a4 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -3177,7 +3177,7 @@ client_ok(const isc_sockaddr_t *fromaddr, void *arg) { isc_netaddr_fromsockaddr(&netaddr, fromaddr); LOCK(&listener->lock); - if (dns_acl_match(&netaddr, NULL, listener->acl, env, + if (dns_acl_match(&netaddr, NULL, NULL, 0, NULL, listener->acl, env, &match, NULL) == ISC_R_SUCCESS && match > 0) { UNLOCK(&listener->lock); diff --git a/lib/dns/acl.c b/lib/dns/acl.c index 371f4bcc77..f2c550c557 100644 --- a/lib/dns/acl.c +++ b/lib/dns/acl.c @@ -178,28 +178,17 @@ dns_acl_isnone(dns_acl_t *acl) * return with a positive value in match; for a match with a negated ACL * element or radix entry, return with a negative value in match. */ + isc_result_t dns_acl_match(const isc_netaddr_t *reqaddr, const dns_name_t *reqsigner, + const isc_netaddr_t *ecs, + isc_uint8_t ecslen, + isc_uint8_t *scope, const dns_acl_t *acl, const dns_aclenv_t *env, int *match, const dns_aclelement_t **matchelt) -{ - return (dns_acl_match2(reqaddr, reqsigner, NULL, 0, NULL, acl, env, - match, matchelt)); -} - -isc_result_t -dns_acl_match2(const isc_netaddr_t *reqaddr, - const dns_name_t *reqsigner, - const isc_netaddr_t *ecs, - isc_uint8_t ecslen, - isc_uint8_t *scope, - const dns_acl_t *acl, - const dns_aclenv_t *env, - int *match, - const dns_aclelement_t **matchelt) { isc_uint16_t bitlen; isc_prefix_t pfx; @@ -290,8 +279,8 @@ dns_acl_match2(const isc_netaddr_t *reqaddr, break; } - if (dns_aclelement_match2(reqaddr, reqsigner, ecs, ecslen, - scope, e, env, matchelt)) + if (dns_aclelement_match(reqaddr, reqsigner, ecs, ecslen, + scope, e, env, matchelt)) { if (match_num == -1 || e->node_num < match_num) { if (e->negative) @@ -424,26 +413,16 @@ dns_acl_merge(dns_acl_t *dest, dns_acl_t *source, isc_boolean_t pos) * a reference to a named ACL or a nested ACL, a matching element * returned through 'matchelt' is not necessarily 'e' itself. */ + isc_boolean_t dns_aclelement_match(const isc_netaddr_t *reqaddr, const dns_name_t *reqsigner, + const isc_netaddr_t *ecs, + isc_uint8_t ecslen, + isc_uint8_t *scope, const dns_aclelement_t *e, const dns_aclenv_t *env, const dns_aclelement_t **matchelt) -{ - return (dns_aclelement_match2(reqaddr, reqsigner, NULL, 0, NULL, - e, env, matchelt)); -} - -isc_boolean_t -dns_aclelement_match2(const isc_netaddr_t *reqaddr, - const dns_name_t *reqsigner, - const isc_netaddr_t *ecs, - isc_uint8_t ecslen, - isc_uint8_t *scope, - const dns_aclelement_t *e, - const dns_aclenv_t *env, - const dns_aclelement_t **matchelt) { dns_acl_t *inner = NULL; int indirectmatch; @@ -493,8 +472,8 @@ dns_aclelement_match2(const isc_netaddr_t *reqaddr, INSIST(0); } - result = dns_acl_match2(reqaddr, reqsigner, ecs, ecslen, scope, - inner, env, &indirectmatch, matchelt); + result = dns_acl_match(reqaddr, reqsigner, ecs, ecslen, scope, + inner, env, &indirectmatch, matchelt); INSIST(result == ISC_R_SUCCESS); /* @@ -687,8 +666,8 @@ dns_acl_allowed(isc_netaddr_t *addr, dns_name_t *signer, if (acl == NULL) return (ISC_TRUE); - result = dns_acl_match2(addr, signer, ecs_addr, ecs_addrlen, - ecs_scope, acl, aclenv, &match, NULL); + result = dns_acl_match(addr, signer, ecs_addr, ecs_addrlen, + ecs_scope, acl, aclenv, &match, NULL); if (result == ISC_R_SUCCESS && match > 0) return (ISC_TRUE); return (ISC_FALSE); diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 33e6ace7bc..68055c0f08 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -1138,7 +1138,8 @@ udp_recv(isc_event_t *ev_in, dns_dispatch_t *disp, dispsocket_t *dispsock) { */ isc_netaddr_fromsockaddr(&netaddr, &ev->address); if (disp->mgr->blackhole != NULL && - dns_acl_match(&netaddr, NULL, disp->mgr->blackhole, + dns_acl_match(&netaddr, NULL, NULL, 0, NULL, + disp->mgr->blackhole, NULL, &match, NULL) == ISC_R_SUCCESS && match > 0) { diff --git a/lib/dns/dns64.c b/lib/dns/dns64.c index 3948049194..cbd8b73be9 100644 --- a/lib/dns/dns64.c +++ b/lib/dns/dns64.c @@ -24,6 +24,7 @@ #include #include #include +#include struct dns_dns64 { unsigned char bits[16]; /* @@ -138,8 +139,8 @@ dns_dns64_aaaafroma(const dns_dns64_t *dns64, const isc_netaddr_t *reqaddr, return (DNS_R_DISALLOWED); if (dns64->clients != NULL) { - result = dns_acl_match(reqaddr, reqsigner, dns64->clients, env, - &match, NULL); + result = dns_acl_match(reqaddr, reqsigner, NULL, 0, NULL, + dns64->clients, env, &match, NULL); if (result != ISC_R_SUCCESS) return (result); if (match <= 0) @@ -152,8 +153,8 @@ dns_dns64_aaaafroma(const dns_dns64_t *dns64, const isc_netaddr_t *reqaddr, memmove(&ina.s_addr, a, 4); isc_netaddr_fromin(&netaddr, &ina); - result = dns_acl_match(&netaddr, NULL, dns64->mapped, env, - &match, NULL); + result = dns_acl_match(&netaddr, NULL, NULL, 0, NULL, + dns64->mapped, env, &match, NULL); if (result != ISC_R_SUCCESS) return (result); if (match <= 0) @@ -227,8 +228,8 @@ dns_dns64_aaaaok(const dns_dns64_t *dns64, const isc_netaddr_t *reqaddr, * Work out if this dns64 structure applies to this client. */ if (dns64->clients != NULL) { - result = dns_acl_match(reqaddr, reqsigner, - dns64->clients, env, + result = dns_acl_match(reqaddr, reqsigner, NULL, 0, + NULL, dns64->clients, env, &match, NULL); if (result != ISC_R_SUCCESS) continue; @@ -266,9 +267,10 @@ dns_dns64_aaaaok(const dns_dns64_t *dns64, const isc_netaddr_t *reqaddr, memmove(&in6.s6_addr, rdata.data, 16); isc_netaddr_fromin6(&netaddr, &in6); - result = dns_acl_match(&netaddr, NULL, - dns64->excluded, - env, &match, NULL); + result = dns_acl_match(&netaddr, NULL, NULL, + 0, NULL, + dns64->excluded, env, + &match, NULL); if (result == ISC_R_SUCCESS && match <= 0) { answer = ISC_TRUE; if (aaaaok == NULL) diff --git a/lib/dns/include/dns/acl.h b/lib/dns/include/dns/acl.h index b6a92e3f70..e5f703e35e 100644 --- a/lib/dns/include/dns/acl.h +++ b/lib/dns/include/dns/acl.h @@ -211,21 +211,13 @@ dns_aclenv_destroy(dns_aclenv_t *env); isc_result_t dns_acl_match(const isc_netaddr_t *reqaddr, const dns_name_t *reqsigner, + const isc_netaddr_t *ecs, + isc_uint8_t ecslen, + isc_uint8_t *scope, const dns_acl_t *acl, const dns_aclenv_t *env, int *match, const dns_aclelement_t **matchelt); - -isc_result_t -dns_acl_match2(const isc_netaddr_t *reqaddr, - const dns_name_t *reqsigner, - const isc_netaddr_t *ecs, - isc_uint8_t ecslen, - isc_uint8_t *scope, - const dns_acl_t *acl, - const dns_aclenv_t *env, - int *match, - const dns_aclelement_t **matchelt); /*%< * General, low-level ACL matching. This is expected to * be useful even for weird stuff like the topology and sortlist statements. @@ -260,19 +252,12 @@ dns_acl_match2(const isc_netaddr_t *reqaddr, isc_boolean_t dns_aclelement_match(const isc_netaddr_t *reqaddr, const dns_name_t *reqsigner, + const isc_netaddr_t *ecs, + isc_uint8_t ecslen, + isc_uint8_t *scope, const dns_aclelement_t *e, const dns_aclenv_t *env, const dns_aclelement_t **matchelt); - -isc_boolean_t -dns_aclelement_match2(const isc_netaddr_t *reqaddr, - const dns_name_t *reqsigner, - const isc_netaddr_t *ecs, - isc_uint8_t ecslen, - isc_uint8_t *scope, - const dns_aclelement_t *e, - const dns_aclenv_t *env, - const dns_aclelement_t **matchelt); /*%< * Like dns_acl_match, but matches against the single ACL element 'e' * rather than a complete ACL, and returns ISC_TRUE iff it matched. diff --git a/lib/dns/request.c b/lib/dns/request.c index 4d9b989135..a5d522d575 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -508,7 +508,7 @@ isblackholed(dns_dispatchmgr_t *dispatchmgr, const isc_sockaddr_t *destaddr) { blackhole = dns_dispatchmgr_getblackhole(dispatchmgr); if (blackhole != NULL) { isc_netaddr_fromsockaddr(&netaddr, destaddr); - if (dns_acl_match(&netaddr, NULL, blackhole, + if (dns_acl_match(&netaddr, NULL, NULL, 0, NULL, blackhole, NULL, &match, NULL) == ISC_R_SUCCESS && match > 0) drop = ISC_TRUE; diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index bdb07df245..86a45a6849 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -3754,7 +3754,7 @@ possibly_mark(fetchctx_t *fctx, dns_adbaddrinfo_t *addr) { if (blackhole != NULL) { int match; - if (dns_acl_match(&ipaddr, NULL, blackhole, + if (dns_acl_match(&ipaddr, NULL, NULL, 0, NULL, blackhole, &res->view->aclenv, &match, NULL) == ISC_R_SUCCESS && match > 0) @@ -6519,8 +6519,9 @@ is_answeraddress_allowed(dns_view_t *view, dns_name_t *name, isc_netaddr_fromin6(&netaddr, &in6a); } - result = dns_acl_match(&netaddr, NULL, view->denyansweracl, - &view->aclenv, &match, NULL); + result = dns_acl_match(&netaddr, NULL, NULL, 0, NULL, + view->denyansweracl, &view->aclenv, + &match, NULL); if (result == ISC_R_SUCCESS && match > 0) { isc_netaddr_format(&netaddr, addrbuf, sizeof(addrbuf)); diff --git a/lib/dns/rrl.c b/lib/dns/rrl.c index a6616c5550..22860ad349 100644 --- a/lib/dns/rrl.c +++ b/lib/dns/rrl.c @@ -1022,8 +1022,9 @@ dns_rrl(dns_view_t *view, rrl = view->rrl; if (rrl->exempt != NULL) { isc_netaddr_fromsockaddr(&netclient, client_addr); - result = dns_acl_match(&netclient, NULL, rrl->exempt, - &view->aclenv, &exempt_match, NULL); + result = dns_acl_match(&netclient, NULL, NULL, 0, NULL, + rrl->exempt, &view->aclenv, + &exempt_match, NULL); if (result == ISC_R_SUCCESS && exempt_match > 0) return (DNS_RRL_RESULT_OK); } diff --git a/lib/dns/ssu.c b/lib/dns/ssu.c index ed67187116..2fc9c61435 100644 --- a/lib/dns/ssu.c +++ b/lib/dns/ssu.c @@ -430,8 +430,9 @@ dns_ssutable_checkrules2(dns_ssutable_t *table, const dns_name_t *signer, if (!dns_name_issubdomain(name, rule->name)) { continue; } - dns_acl_match(addr, NULL, env->localhost, - NULL, &match, NULL); + dns_acl_match(addr, NULL, NULL, 0, NULL, + env->localhost, NULL, &match, + NULL); if (match == 0) { if (signer != NULL) { isc_log_write(dns_lctx, diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index fc7ab3eae0..0a00eb6aa9 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -18,11 +18,9 @@ dns_acl_isany dns_acl_isinsecure dns_acl_isnone dns_acl_match -dns_acl_match2 dns_acl_merge dns_acl_none dns_aclelement_match -dns_aclelement_match2 dns_aclenv_copy dns_aclenv_destroy dns_aclenv_init diff --git a/lib/dns/zone.c b/lib/dns/zone.c index ea19a8fa2c..5e402f95ad 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -13245,9 +13245,9 @@ dns_zone_notifyreceive2(dns_zone_t *zone, isc_sockaddr_t *from, tsigkey = dns_message_gettsigkey(msg); tsig = dns_tsigkey_identity(tsigkey); if (i >= zone->masterscnt && zone->notify_acl != NULL && - dns_acl_match(&netaddr, tsig, zone->notify_acl, - &zone->view->aclenv, - &match, NULL) == ISC_R_SUCCESS && + dns_acl_match(&netaddr, tsig, NULL, 0, NULL, zone->notify_acl, + &zone->view->aclenv, &match, + NULL) == ISC_R_SUCCESS && match > 0) { /* Accept notify. */ diff --git a/lib/ns/client.c b/lib/ns/client.c index fda05b89aa..b69e5e87b7 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -950,7 +950,7 @@ client_sendpkg(ns_client_t *client, isc_buffer_t *buffer) { isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr); if (client->sctx->blackholeacl != NULL && - dns_acl_match(&netaddr, NULL, + dns_acl_match(&netaddr, NULL, NULL, 0, NULL, client->sctx->blackholeacl, env, &match, NULL) == ISC_R_SUCCESS && match > 0) @@ -1756,8 +1756,9 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message, int match; isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr); - result = dns_acl_match(&netaddr, NULL, view->pad_acl, - env, &match, NULL); + result = dns_acl_match(&netaddr, NULL, NULL, 0, NULL, + view->pad_acl, env, &match, + NULL); if (result == ISC_R_SUCCESS && match > 0) { INSIST(count < DNS_EDNSOPTIONS); @@ -2379,8 +2380,9 @@ ns__client_request(isc_task_t *task, isc_event_t *event) { env = ns_interfacemgr_getaclenv(client->interface->mgr); if (!TCP_CLIENT(client)) { if (client->sctx->blackholeacl != NULL && - dns_acl_match(&netaddr, NULL, client->sctx->blackholeacl, - env, &match, NULL) == ISC_R_SUCCESS && + dns_acl_match(&netaddr, NULL, NULL, 0, NULL, + client->sctx->blackholeacl, env, &match, + NULL) == ISC_R_SUCCESS && match > 0) { ns_client_log(client, DNS_LOGCATEGORY_SECURITY, @@ -3199,9 +3201,9 @@ client_newconn(isc_task_t *task, isc_event_t *event) { isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr); if (client->sctx->blackholeacl != NULL && - dns_acl_match(&netaddr, NULL, - client->sctx->blackholeacl, - env, &match, NULL) == ISC_R_SUCCESS && + dns_acl_match(&netaddr, NULL, NULL, 0, NULL, + client->sctx->blackholeacl, + env, &match, NULL) == ISC_R_SUCCESS && match > 0) { ns_client_log(client, DNS_LOGCATEGORY_SECURITY, @@ -3753,9 +3755,9 @@ ns_client_checkaclsilent(ns_client_t *client, isc_netaddr_t *netaddr, ecs_addrlen = client->ecs.source; } - result = dns_acl_match2(netaddr, client->signer, - ecs_addr, ecs_addrlen, NULL, acl, - env, &match, NULL); + result = dns_acl_match(netaddr, client->signer, + ecs_addr, ecs_addrlen, NULL, acl, + env, &match, NULL); if (result != ISC_R_SUCCESS) goto deny; /* Internal error, already logged. */ diff --git a/lib/ns/interfacemgr.c b/lib/ns/interfacemgr.c index ca53ec6650..358caeb2d2 100644 --- a/lib/ns/interfacemgr.c +++ b/lib/ns/interfacemgr.c @@ -1049,8 +1049,9 @@ do_scan(ns_interfacemgr_t *mgr, ns_listenlist_t *ext_listen, * See if the address matches the listen-on statement; * if not, ignore the interface. */ - (void)dns_acl_match(&listen_netaddr, NULL, le->acl, - &mgr->aclenv, &match, NULL); + (void)dns_acl_match(&listen_netaddr, NULL, NULL, 0, + NULL, le->acl, &mgr->aclenv, + &match, NULL); if (match <= 0) continue; @@ -1082,8 +1083,10 @@ do_scan(ns_interfacemgr_t *mgr, ns_listenlist_t *ext_listen, ele != NULL; ele = ISC_LIST_NEXT(ele, link)) { (void)dns_acl_match(&listen_netaddr, + NULL, NULL, 0, NULL, ele->acl, - NULL, &match, NULL); + NULL, &match, + NULL); if (match > 0 && (ele->port == le->port || ele->port == 0)) diff --git a/lib/ns/sortlist.c b/lib/ns/sortlist.c index c3cc2fc9ec..f83689bc57 100644 --- a/lib/ns/sortlist.c +++ b/lib/ns/sortlist.c @@ -64,8 +64,8 @@ ns_sortlist_setup(dns_acl_t *acl, dns_aclenv_t *env, try_elt = e; } - if (dns_aclelement_match(clientaddr, NULL, try_elt, env, - &matched_elt)) + if (dns_aclelement_match(clientaddr, NULL, NULL, 0, NULL, + try_elt, env, &matched_elt)) { if (order_elt != NULL) { if (order_elt->type == @@ -115,7 +115,8 @@ ns_sortlist_addrorder2(const isc_netaddr_t *addr, const void *arg) { const dns_acl_t *sortacl = sla->acl; int match; - (void)dns_acl_match(addr, NULL, sortacl, env, &match, NULL); + (void)dns_acl_match(addr, NULL, NULL, 0, NULL, sortacl, env, &match, + NULL); if (match > 0) return (match); else if (match < 0) @@ -130,7 +131,8 @@ ns_sortlist_addrorder1(const isc_netaddr_t *addr, const void *arg) { const dns_aclenv_t *env = sla->env; const dns_aclelement_t *element = sla->element; - if (dns_aclelement_match(addr, NULL, element, env, NULL)) { + if (dns_aclelement_match(addr, NULL, NULL, 0, NULL, element, env, + NULL)) { return (0); } From f0a07b7546a75eef582891a93128a9ba8f889bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 13:10:03 +0200 Subject: [PATCH 02/18] libdns refactoring: get rid of two versions of dns_adb_createfind and dns_adb_probesize --- bin/tests/optional/adb_test.c | 3 ++- bin/tests/optional/byname_test.c | 2 +- lib/dns/adb.c | 23 +++-------------------- lib/dns/include/dns/adb.h | 16 ++++------------ lib/dns/resolver.c | 20 ++++++++++---------- lib/dns/win32/libdns.def.in | 2 -- lib/dns/zone.c | 2 +- 7 files changed, 21 insertions(+), 47 deletions(-) diff --git a/bin/tests/optional/adb_test.c b/bin/tests/optional/adb_test.c index efec3706d1..97bf3cfaf9 100644 --- a/bin/tests/optional/adb_test.c +++ b/bin/tests/optional/adb_test.c @@ -258,7 +258,8 @@ lookup(const char *target) { options |= DNS_ADBFIND_GLUEOK; result = dns_adb_createfind(adb, t2, lookup_callback, client, &client->name, dns_rootname, 0, options, - now, NULL, view->dstport, &client->find); + now, NULL, view->dstport, 0, NULL, + &client->find); if (result != ISC_R_SUCCESS) printf("DNS_ADB_CREATEFIND -> %s\n", dns_result_totext(result)); dns_adb_dumpfind(client->find, stderr); diff --git a/bin/tests/optional/byname_test.c b/bin/tests/optional/byname_test.c index 0990967043..fb4b2b8413 100644 --- a/bin/tests/optional/byname_test.c +++ b/bin/tests/optional/byname_test.c @@ -120,7 +120,7 @@ do_find(isc_boolean_t want_event) { dns_fixedname_name(&fixed), dns_rootname, 0, options, 0, dns_fixedname_name(&target), 0, - &find); + 0, NULL, &find); if (result == ISC_R_SUCCESS) { if (!ISC_LIST_EMPTY(find->list)) { /* diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 68cffe96e5..c052fa11ba 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -2937,20 +2937,8 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action, void *arg, const dns_name_t *name, const dns_name_t *qname, dns_rdatatype_t qtype, unsigned int options, isc_stdtime_t now, dns_name_t *target, - in_port_t port, dns_adbfind_t **findp) -{ - return (dns_adb_createfind2(adb, task, action, arg, name, - qname, qtype, options, now, - target, port, 0, NULL, findp)); -} - -isc_result_t -dns_adb_createfind2(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action, - void *arg, const dns_name_t *name, const dns_name_t *qname, - dns_rdatatype_t qtype, unsigned int options, - isc_stdtime_t now, dns_name_t *target, - in_port_t port, unsigned int depth, isc_counter_t *qc, - dns_adbfind_t **findp) + in_port_t port, unsigned int depth, isc_counter_t *qc, + dns_adbfind_t **findp) { dns_adbfind_t *find; dns_adbname_t *adbname; @@ -4481,12 +4469,7 @@ dns_adb_getudpsize(dns_adb_t *adb, dns_adbaddrinfo_t *addr) { } unsigned int -dns_adb_probesize(dns_adb_t *adb, dns_adbaddrinfo_t *addr) { - return dns_adb_probesize2(adb, addr, 0); -} - -unsigned int -dns_adb_probesize2(dns_adb_t *adb, dns_adbaddrinfo_t *addr, int lookups) { +dns_adb_probesize(dns_adb_t *adb, dns_adbaddrinfo_t *addr, int lookups) { int bucket; unsigned int size; diff --git a/lib/dns/include/dns/adb.h b/lib/dns/include/dns/adb.h index e04605415c..7331d1c54e 100644 --- a/lib/dns/include/dns/adb.h +++ b/lib/dns/include/dns/adb.h @@ -333,15 +333,9 @@ isc_result_t dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action, void *arg, const dns_name_t *name, const dns_name_t *qname, dns_rdatatype_t qtype, unsigned int options, - isc_stdtime_t now, dns_name_t *target, - in_port_t port, dns_adbfind_t **find); -isc_result_t -dns_adb_createfind2(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action, - void *arg, const dns_name_t *name, const dns_name_t *qname, - dns_rdatatype_t qtype, unsigned int options, - isc_stdtime_t now, dns_name_t *target, in_port_t port, - unsigned int depth, isc_counter_t *qc, - dns_adbfind_t **find); + isc_stdtime_t now, dns_name_t *target, in_port_t port, + unsigned int depth, isc_counter_t *qc, + dns_adbfind_t **find); /*%< * Main interface for clients. The adb will look up the name given in * "name" and will build up a list of found addresses, and perhaps start @@ -611,9 +605,7 @@ dns_adb_getudpsize(dns_adb_t *adb, dns_adbaddrinfo_t *addr); */ unsigned int -dns_adb_probesize(dns_adb_t *adb, dns_adbaddrinfo_t *addr); -unsigned int -dns_adb_probesize2(dns_adb_t *adb, dns_adbaddrinfo_t *addr, int lookups); +dns_adb_probesize (dns_adb_t *adb, dns_adbaddrinfo_t *addr, int lookups); /*% * Return suggested EDNS UDP size based on observed responses / failures. * 'lookups' is the number of times the current lookup has been attempted. diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 86a45a6849..b7b46db2e0 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -2538,9 +2538,9 @@ resquery_send(resquery_t *query) { if ((flags & FCTX_ADDRINFO_EDNSOK) != 0 && (query->options & DNS_FETCHOPT_EDNS512) == 0) { - udpsize = dns_adb_probesize2(fctx->adb, - query->addrinfo, - fctx->timeouts); + udpsize = dns_adb_probesize(fctx->adb, + query->addrinfo, + fctx->timeouts); if (udpsize > res->udpsize) udpsize = res->udpsize; } @@ -3346,13 +3346,13 @@ findname(fetchctx_t *fctx, const dns_name_t *name, in_port_t port, * See what we know about this address. */ find = NULL; - result = dns_adb_createfind2(fctx->adb, - res->buckets[fctx->bucketnum].task, - fctx_finddone, fctx, name, - &fctx->name, fctx->type, - options, now, NULL, - res->view->dstport, - fctx->depth + 1, fctx->qc, &find); + result = dns_adb_createfind(fctx->adb, + res->buckets[fctx->bucketnum].task, + fctx_finddone, fctx, name, + &fctx->name, fctx->type, + options, now, NULL, + res->view->dstport, + fctx->depth + 1, fctx->qc, &find); if (result != ISC_R_SUCCESS) { if (result == DNS_R_ALIAS) { char namebuf[DNS_NAME_FORMATSIZE]; diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 0a00eb6aa9..7b8e883192 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -32,7 +32,6 @@ dns_adb_cancelfind dns_adb_changeflags dns_adb_create dns_adb_createfind -dns_adb_createfind2 dns_adb_destroyfind dns_adb_detach dns_adb_dump @@ -50,7 +49,6 @@ dns_adb_marklame dns_adb_noedns dns_adb_plainresponse dns_adb_probesize -dns_adb_probesize2 dns_adb_setadbsize dns_adb_setcookie dns_adb_setquota diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 5e402f95ad..707d5c9fc7 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -10858,7 +10858,7 @@ notify_find_address(dns_notify_t *notify) { ¬ify->ns, dns_rootname, 0, options, 0, NULL, notify->zone->view->dstport, - ¬ify->find); + 0, NULL, ¬ify->find); /* Something failed? */ if (result != ISC_R_SUCCESS) From d76ed0da1c969a4be5da146817953b9e421207c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 13:10:07 +0200 Subject: [PATCH 03/18] libdns refactoring: get rid of two versions of dns_byaddr_createptrname --- bin/delv/delv.c | 2 +- bin/dig/dighost.c | 2 +- bin/tests/system/dyndb/driver/syncptr.c | 2 +- bin/tools/mdig.c | 2 +- lib/dns/byaddr.c | 19 +++---------------- lib/dns/include/dns/byaddr.h | 6 +----- lib/dns/win32/libdns.def.in | 1 - lib/irs/getnameinfo.c | 2 +- 8 files changed, 9 insertions(+), 27 deletions(-) diff --git a/bin/delv/delv.c b/bin/delv/delv.c index c97ad69a09..100f03c6d9 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -1540,7 +1540,7 @@ get_reverse(char *reverse, size_t len, char *value, isc_boolean_t strict) { dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); - result = dns_byaddr_createptrname2(&addr, options, name); + result = dns_byaddr_createptrname(&addr, options, name); if (result != ISC_R_SUCCESS) return (result); dns_name_format(name, reverse, (unsigned int)len); diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 7654451c50..8d865327f8 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -355,7 +355,7 @@ get_reverse(char *reverse, size_t len, char *value, isc_boolean_t ip6_int, options |= DNS_BYADDROPT_IPV6INT; dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); - result = dns_byaddr_createptrname2(&addr, options, name); + result = dns_byaddr_createptrname(&addr, options, name); if (result != ISC_R_SUCCESS) return (result); dns_name_format(name, reverse, (unsigned int)len); diff --git a/bin/tests/system/dyndb/driver/syncptr.c b/bin/tests/system/dyndb/driver/syncptr.c index 7ca2d3f279..17a6130061 100644 --- a/bin/tests/system/dyndb/driver/syncptr.c +++ b/bin/tests/system/dyndb/driver/syncptr.c @@ -119,7 +119,7 @@ syncptr_find_zone(sample_instance_t *inst, dns_rdata_t *rdata, * @example * 192.168.0.1 -> 1.0.168.192.in-addr.arpa */ - CHECK(dns_byaddr_createptrname2(&isc_ip, 0, name)); + CHECK(dns_byaddr_createptrname(&isc_ip, 0, name)); /* Find a zone containing owner name of the PTR record. */ result = dns_zt_find(inst->view->zonetable, name, 0, NULL, zone); diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index e590e3aa6e..cc21f74089 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -1004,7 +1004,7 @@ get_reverse(char *reverse, size_t len, const char *value, options |= DNS_BYADDROPT_IPV6INT; dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); - result = dns_byaddr_createptrname2(&addr, options, name); + result = dns_byaddr_createptrname(&addr, options, name); CHECK("dns_byaddr_createptrname2", result); dns_name_format(name, reverse, (unsigned int)len); return; diff --git a/lib/dns/byaddr.c b/lib/dns/byaddr.c index c1fb585931..bdfa8cdb4f 100644 --- a/lib/dns/byaddr.c +++ b/lib/dns/byaddr.c @@ -43,21 +43,8 @@ static char hex_digits[] = { }; isc_result_t -dns_byaddr_createptrname(const isc_netaddr_t *address, isc_boolean_t nibble, +dns_byaddr_createptrname(const isc_netaddr_t *address, unsigned int options, dns_name_t *name) -{ - /* - * We dropped bitstring labels, so all lookups will use nibbles. - */ - UNUSED(nibble); - - return (dns_byaddr_createptrname2(address, - DNS_BYADDROPT_IPV6INT, name)); -} - -isc_result_t -dns_byaddr_createptrname2(const isc_netaddr_t *address, unsigned int options, - dns_name_t *name) { char textname[128]; const unsigned char *bytes; @@ -245,8 +232,8 @@ dns_byaddr_create(isc_mem_t *mctx, const isc_netaddr_t *address, dns_fixedname_init(&byaddr->name); - result = dns_byaddr_createptrname2(address, options, - dns_fixedname_name(&byaddr->name)); + result = dns_byaddr_createptrname(address, options, + dns_fixedname_name(&byaddr->name)); if (result != ISC_R_SUCCESS) goto cleanup_lock; diff --git a/lib/dns/include/dns/byaddr.h b/lib/dns/include/dns/byaddr.h index 296093ce10..1cf49c8190 100644 --- a/lib/dns/include/dns/byaddr.h +++ b/lib/dns/include/dns/byaddr.h @@ -141,12 +141,8 @@ dns_byaddr_destroy(dns_byaddr_t **byaddrp); */ isc_result_t -dns_byaddr_createptrname(const isc_netaddr_t *address, isc_boolean_t nibble, +dns_byaddr_createptrname(const isc_netaddr_t *address, unsigned int options, dns_name_t *name); - -isc_result_t -dns_byaddr_createptrname2(const isc_netaddr_t *address, unsigned int options, - dns_name_t *name); /*%< * Creates a name that would be used in a PTR query for this address. The * nibble flag indicates that the 'nibble' format is to be used if an IPv6 diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 7b8e883192..8b4f811b7a 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -68,7 +68,6 @@ dns_badcache_print dns_byaddr_cancel dns_byaddr_create dns_byaddr_createptrname -dns_byaddr_createptrname2 dns_byaddr_destroy dns_cache_attach dns_cache_attachdb diff --git a/lib/irs/getnameinfo.c b/lib/irs/getnameinfo.c index f81f93f319..e3340af926 100644 --- a/lib/irs/getnameinfo.c +++ b/lib/irs/getnameinfo.c @@ -292,7 +292,7 @@ getnameinfo(const struct sockaddr *sa, IRS_GETNAMEINFO_SOCKLEN_T salen, isc_netaddr_fromsockaddr(&netaddr, (const isc_sockaddr_t *)sa); dns_fixedname_init(&ptrfname); ptrname = dns_fixedname_name(&ptrfname); - iresult = dns_byaddr_createptrname2(&netaddr, 0, ptrname); + iresult = dns_byaddr_createptrname(&netaddr, 0, ptrname); if (iresult != ISC_R_SUCCESS) ERR(EAI_FAIL); From d39b3209fbd07245441da61bf2188f5eac824820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 13:10:15 +0200 Subject: [PATCH 04/18] libdns refactoring: get rid of 3 versions of dns_cache_create --- bin/named/server.c | 8 ++++---- bin/tests/optional/adb_test.c | 5 +++-- bin/tests/optional/byaddr_test.c | 4 ++-- bin/tests/optional/byname_test.c | 4 ++-- lib/dns/cache.c | 27 +++------------------------ lib/dns/include/dns/cache.h | 17 +++-------------- lib/dns/win32/libdns.def.in | 2 -- lib/ns/tests/nstest.c | 4 ++-- 8 files changed, 19 insertions(+), 52 deletions(-) diff --git a/bin/named/server.c b/bin/named/server.c index 99f11bc92c..7240d5f8c0 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -4208,10 +4208,10 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, isc_mem_setname(cmctx, "cache", NULL); CHECK(isc_mem_create(0, 0, &hmctx)); isc_mem_setname(hmctx, "cache_heap", NULL); - CHECK(dns_cache_create3(cmctx, hmctx, named_g_taskmgr, - named_g_timermgr, view->rdclass, - cachename, "rbt", 0, NULL, - &cache)); + CHECK(dns_cache_create(cmctx, hmctx, named_g_taskmgr, + named_g_timermgr, view->rdclass, + cachename, "rbt", 0, NULL, + &cache)); isc_mem_detach(&cmctx); isc_mem_detach(&hmctx); } diff --git a/bin/tests/optional/adb_test.c b/bin/tests/optional/adb_test.c index 97bf3cfaf9..0d6995d9c3 100644 --- a/bin/tests/optional/adb_test.c +++ b/bin/tests/optional/adb_test.c @@ -180,8 +180,9 @@ create_view(void) { * Cache. */ cache = NULL; - result = dns_cache_create(mctx, taskmgr, timermgr, dns_rdataclass_in, - "rbt", 0, NULL, &cache); + result = dns_cache_create(mctx, mctx, taskmgr, timermgr, + dns_rdataclass_in, "", "rbt", 0, NULL, + &cache); check_result(result, "dns_cache_create"); dns_view_setcache(view, cache); dns_cache_detach(&cache); diff --git a/bin/tests/optional/byaddr_test.c b/bin/tests/optional/byaddr_test.c index 39b8b253e9..7d95c05bb5 100644 --- a/bin/tests/optional/byaddr_test.c +++ b/bin/tests/optional/byaddr_test.c @@ -132,8 +132,8 @@ main(int argc, char *argv[]) { RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS); cache = NULL; - RUNTIME_CHECK(dns_cache_create(mctx, taskmgr, timermgr, - dns_rdataclass_in, "rbt", 0, NULL, + RUNTIME_CHECK(dns_cache_create(mctx, mctx, taskmgr, timermgr, + dns_rdataclass_in, "", "rbt", 0, NULL, &cache) == ISC_R_SUCCESS); view = NULL; diff --git a/bin/tests/optional/byname_test.c b/bin/tests/optional/byname_test.c index fb4b2b8413..89c9a263dd 100644 --- a/bin/tests/optional/byname_test.c +++ b/bin/tests/optional/byname_test.c @@ -250,8 +250,8 @@ main(int argc, char *argv[]) { RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS); cache = NULL; - RUNTIME_CHECK(dns_cache_create(mctx, taskmgr, timermgr, - dns_rdataclass_in, "rbt", 0, NULL, + RUNTIME_CHECK(dns_cache_create(mctx, mctx, taskmgr, timermgr, + dns_rdataclass_in, "", "rbt", 0, NULL, &cache) == ISC_R_SUCCESS); view = NULL; diff --git a/lib/dns/cache.c b/lib/dns/cache.c index ce40969889..d37a018d09 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -176,31 +176,10 @@ cache_create_db(dns_cache_t *cache, dns_db_t **db) { } isc_result_t -dns_cache_create(isc_mem_t *cmctx, isc_taskmgr_t *taskmgr, +dns_cache_create(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr, isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, - const char *db_type, unsigned int db_argc, char **db_argv, - dns_cache_t **cachep) -{ - return (dns_cache_create3(cmctx, cmctx, taskmgr, timermgr, rdclass, "", - db_type, db_argc, db_argv, cachep)); -} - -isc_result_t -dns_cache_create2(isc_mem_t *cmctx, isc_taskmgr_t *taskmgr, - isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, - const char *cachename, const char *db_type, - unsigned int db_argc, char **db_argv, dns_cache_t **cachep) -{ - return (dns_cache_create3(cmctx, cmctx, taskmgr, timermgr, rdclass, - cachename, db_type, db_argc, db_argv, - cachep)); -} - -isc_result_t -dns_cache_create3(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr, - isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, - const char *cachename, const char *db_type, - unsigned int db_argc, char **db_argv, dns_cache_t **cachep) + const char *cachename, const char *db_type, + unsigned int db_argc, char **db_argv, dns_cache_t **cachep) { isc_result_t result; dns_cache_t *cache; diff --git a/lib/dns/include/dns/cache.h b/lib/dns/include/dns/cache.h index 290a4e801b..74b3b32f08 100644 --- a/lib/dns/include/dns/cache.h +++ b/lib/dns/include/dns/cache.h @@ -55,22 +55,11 @@ ISC_LANG_BEGINDECLS /*** *** Functions ***/ - isc_result_t -dns_cache_create(isc_mem_t *cmctx, isc_taskmgr_t *taskmgr, +dns_cache_create(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr, isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, - const char *db_type, unsigned int db_argc, char **db_argv, - dns_cache_t **cachep); -isc_result_t -dns_cache_create2(isc_mem_t *cmctx, isc_taskmgr_t *taskmgr, - isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, - const char *cachename, const char *db_type, - unsigned int db_argc, char **db_argv, dns_cache_t **cachep); -isc_result_t -dns_cache_create3(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr, - isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, - const char *cachename, const char *db_type, - unsigned int db_argc, char **db_argv, dns_cache_t **cachep); + const char *cachename, const char *db_type, + unsigned int db_argc, char **db_argv, dns_cache_t **cachep); /*%< * Create a new DNS cache. * diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 8b4f811b7a..440af9b98a 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -73,8 +73,6 @@ dns_cache_attach dns_cache_attachdb dns_cache_clean dns_cache_create -dns_cache_create2 -dns_cache_create3 dns_cache_detach dns_cache_dump dns_cache_dumpstats diff --git a/lib/ns/tests/nstest.c b/lib/ns/tests/nstest.c index 620636d8f5..696ddd2b82 100644 --- a/lib/ns/tests/nstest.c +++ b/lib/ns/tests/nstest.c @@ -321,8 +321,8 @@ ns_test_makeview(const char *name, isc_boolean_t with_cache, CHECK(dns_view_create(mctx, dns_rdataclass_in, name, &view)); if (with_cache) { - CHECK(dns_cache_create(mctx, taskmgr, timermgr, - dns_rdataclass_in, "rbt", 0, NULL, + CHECK(dns_cache_create(mctx, mctx, taskmgr, timermgr, + dns_rdataclass_in, "", "rbt", 0, NULL, &cache)); dns_view_setcache(view, cache); /* From 76e17b54ea23c6618cdf4605cd7e893d741e1d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 13:15:16 +0200 Subject: [PATCH 05/18] libdns refactoring: get rid of two versions of dns_client_createx --- bin/delv/delv.c | 4 ++-- lib/dns/client.c | 23 ++++++----------------- lib/dns/include/dns/client.h | 15 +++++---------- lib/dns/win32/libdns.def.in | 1 - lib/irs/context.c | 2 +- lib/samples/nsprobe.c | 2 +- lib/samples/resolve.c | 2 +- lib/samples/sample-async.c | 2 +- 8 files changed, 17 insertions(+), 34 deletions(-) diff --git a/bin/delv/delv.c b/bin/delv/delv.c index 100f03c6d9..af9fa4b77e 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -1624,8 +1624,8 @@ main(int argc, char *argv[]) { /* Create client */ clopt = DNS_CLIENTCREATEOPT_USECACHE; - result = dns_client_createx2(mctx, actx, taskmgr, socketmgr, timermgr, - clopt, &client, srcaddr4, srcaddr6); + result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr, + clopt, &client, srcaddr4, srcaddr6); if (result != ISC_R_SUCCESS) { delv_log(ISC_LOG_ERROR, "dns_client_create: %s", isc_result_totext(result)); diff --git a/lib/dns/client.c b/lib/dns/client.c index 70659fbf8f..0d1cf47cbd 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -399,7 +399,7 @@ dns_client_create(dns_client_t **clientp, unsigned int options) { isc_log_setdebuglevel(lctx, logdebuglevel); #endif result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr, - options, clientp); + options, clientp, NULL, NULL); if (result != ISC_R_SUCCESS) goto cleanup; @@ -425,22 +425,11 @@ dns_client_create(dns_client_t **clientp, unsigned int options) { } isc_result_t -dns_client_createx(isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr, - isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr, - unsigned int options, dns_client_t **clientp) -{ - isc_result_t result; - result = dns_client_createx2(mctx, actx, taskmgr, socketmgr, timermgr, - options, clientp, NULL, NULL); - return (result); -} - -isc_result_t -dns_client_createx2(isc_mem_t *mctx, isc_appctx_t *actx, - isc_taskmgr_t *taskmgr, isc_socketmgr_t *socketmgr, - isc_timermgr_t *timermgr, unsigned int options, - dns_client_t **clientp, const isc_sockaddr_t *localaddr4, - const isc_sockaddr_t *localaddr6) +dns_client_createx(isc_mem_t *mctx, isc_appctx_t *actx, + isc_taskmgr_t *taskmgr, isc_socketmgr_t *socketmgr, + isc_timermgr_t *timermgr, unsigned int options, + dns_client_t **clientp, const isc_sockaddr_t *localaddr4, + const isc_sockaddr_t *localaddr6) { dns_client_t *client; isc_result_t result; diff --git a/lib/dns/include/dns/client.h b/lib/dns/include/dns/client.h index d9e6cc2015..d1a57792ab 100644 --- a/lib/dns/include/dns/client.h +++ b/lib/dns/include/dns/client.h @@ -162,16 +162,11 @@ isc_result_t dns_client_create(dns_client_t **clientp, unsigned int options); isc_result_t -dns_client_createx(isc_mem_t *mctx, isc_appctx_t *actx, isc_taskmgr_t *taskmgr, - isc_socketmgr_t *socketmgr, isc_timermgr_t *timermgr, - unsigned int options, dns_client_t **clientp); - -isc_result_t -dns_client_createx2(isc_mem_t *mctx, isc_appctx_t *actx, - isc_taskmgr_t *taskmgr, isc_socketmgr_t *socketmgr, - isc_timermgr_t *timermgr, unsigned int options, - dns_client_t **clientp, const isc_sockaddr_t *localaddr4, - const isc_sockaddr_t *localaddr6); +dns_client_createx(isc_mem_t *mctx, isc_appctx_t *actx, + isc_taskmgr_t *taskmgr, isc_socketmgr_t *socketmgr, + isc_timermgr_t *timermgr, unsigned int options, + dns_client_t **clientp, const isc_sockaddr_t *localaddr4, + const isc_sockaddr_t *localaddr6); /*%< * Create a DNS client. These functions create a new client object with * minimal internal resources such as the default 'view' for the IN class and diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 440af9b98a..45b2af1da0 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -138,7 +138,6 @@ dns_client_cancelupdate dns_client_clearservers dns_client_create dns_client_createx -dns_client_createx2 dns_client_destroy dns_client_destroyreqtrans dns_client_destroyrestrans diff --git a/lib/irs/context.c b/lib/irs/context.c index c7077f18f7..f53b42d651 100644 --- a/lib/irs/context.c +++ b/lib/irs/context.c @@ -254,7 +254,7 @@ irs_context_create(irs_context_t **contextp) { /* Create a DNS client object */ result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr, - 0, &client); + 0, &client, NULL, NULL); if (result != ISC_R_SUCCESS) goto fail; context->dnsclient = client; diff --git a/lib/samples/nsprobe.c b/lib/samples/nsprobe.c index 5cdcee52ea..ec3c9dc2ae 100644 --- a/lib/samples/nsprobe.c +++ b/lib/samples/nsprobe.c @@ -1077,7 +1077,7 @@ main(int argc, char *argv[]) { isc_app_ctxstart(actx); result = dns_client_createx(mctx, actx, taskmgr, socketmgr, - timermgr, 0, &client); + timermgr, 0, &client, NULL, NULL); if (result != ISC_R_SUCCESS) { fprintf(stderr, "dns_client_createx failed: %u\n", result); exit(1); diff --git a/lib/samples/resolve.c b/lib/samples/resolve.c index ff0946386e..0c6849c72e 100644 --- a/lib/samples/resolve.c +++ b/lib/samples/resolve.c @@ -393,7 +393,7 @@ main(int argc, char *argv[]) { goto cleanup; clientopt = 0; - result = dns_client_createx2(mctx, actx, taskmgr, socketmgr, timermgr, + result = dns_client_createx(mctx, actx, taskmgr, socketmgr, timermgr, clientopt, &client, addr4, addr6); if (result != ISC_R_SUCCESS) { fprintf(stderr, "dns_client_create failed: %u, %s\n", result, diff --git a/lib/samples/sample-async.c b/lib/samples/sample-async.c index 0db3344c1f..f24e15ad91 100644 --- a/lib/samples/sample-async.c +++ b/lib/samples/sample-async.c @@ -340,7 +340,7 @@ main(int argc, char *argv[]) { isc_app_ctxstart(query_actx); result = dns_client_createx(mctx, query_actx, taskmgr, socketmgr, - timermgr, 0, &client); + timermgr, 0, &client, NULL, NULL); if (result != ISC_R_SUCCESS) { fprintf(stderr, "dns_client_createx failed: %u\n", result); exit(1); From 275a6a3bec50e5174290925fe68912ad2dc5c782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 13:22:09 +0200 Subject: [PATCH 06/18] libdns refactoring: get rid of unnecessary dns_db_dump2 and 3 versions of dns_db_load --- bin/dnssec/dnssec-cds.c | 4 ++-- bin/dnssec/dnssec-dsfromkey.c | 2 +- bin/dnssec/dnssec-importkey.c | 4 ++-- bin/dnssec/dnssec-signzone.c | 4 ++-- bin/dnssec/dnssec-verify.c | 2 +- bin/tests/makejournal.c | 2 +- bin/tests/optional/db_test.c | 2 +- bin/tests/optional/nsecify.c | 2 +- contrib/sdb/bdb/zone2bdb.c | 3 ++- contrib/sdb/ldap/zone2ldap.c | 2 +- contrib/sdb/pgsql/zonetodb.c | 2 +- contrib/sdb/sqlite/zone2sqlite.c | 2 +- lib/dns/cache.c | 3 ++- lib/dns/db.c | 28 ++-------------------------- lib/dns/include/dns/db.h | 14 ++------------ lib/dns/tests/db_test.c | 9 ++++++--- lib/dns/tests/dnstest.c | 2 +- lib/dns/tests/master_test.c | 3 ++- lib/dns/win32/libdns.def.in | 3 --- lib/ns/tests/nstest.c | 2 +- 20 files changed, 32 insertions(+), 63 deletions(-) diff --git a/bin/dnssec/dnssec-cds.c b/bin/dnssec/dnssec-cds.c index 4758c476d6..6249a1b178 100644 --- a/bin/dnssec/dnssec-cds.c +++ b/bin/dnssec/dnssec-cds.c @@ -254,8 +254,8 @@ load_db(const char *filename, dns_db_t **dbp, dns_dbnode_t **nodep) { rdclass, 0, NULL, dbp); check_result(result, "dns_db_create()"); - result = dns_db_load3(*dbp, filename, - dns_masterformat_text, DNS_MASTER_HINT); + result = dns_db_load(*dbp, filename, + dns_masterformat_text, DNS_MASTER_HINT); if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) { fatal("can't load %s: %s", filename, isc_result_totext(result)); diff --git a/bin/dnssec/dnssec-dsfromkey.c b/bin/dnssec/dnssec-dsfromkey.c index 44968404b7..383bee36be 100644 --- a/bin/dnssec/dnssec-dsfromkey.c +++ b/bin/dnssec/dnssec-dsfromkey.c @@ -114,7 +114,7 @@ loadset(const char *filename, dns_rdataset_t *rdataset) { db_load_from_stream(db, stdin); filename = "input"; } else { - result = dns_db_load(db, filename); + result = dns_db_load(db, filename, dns_masterformat_text, 0); if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) fatal("can't load %s: %s", filename, isc_result_totext(result)); diff --git a/bin/dnssec/dnssec-importkey.c b/bin/dnssec/dnssec-importkey.c index 76c384eff5..fa8788e236 100644 --- a/bin/dnssec/dnssec-importkey.c +++ b/bin/dnssec/dnssec-importkey.c @@ -119,8 +119,8 @@ loadset(const char *filename, dns_rdataset_t *rdataset) { db_load_from_stream(db, stdin); filename = "input"; } else { - result = dns_db_load3(db, filename, dns_masterformat_text, - DNS_MASTER_NOTTL); + result = dns_db_load(db, filename, dns_masterformat_text, + DNS_MASTER_NOTTL); if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) fatal("can't load %s: %s", filename, isc_result_totext(result)); diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 894752ae33..1f15017516 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -905,7 +905,7 @@ opendb(const char *prefix, dns_name_t *name, dns_rdataclass_t rdclass, rdclass, 0, NULL, dbp); check_result(result, "dns_db_create()"); - result = dns_db_load3(*dbp, filename, inputformat, DNS_MASTER_HINT); + result = dns_db_load(*dbp, filename, inputformat, DNS_MASTER_HINT); if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) dns_db_detach(dbp); } @@ -2470,7 +2470,7 @@ loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) { rdclass, 0, NULL, db); check_result(result, "dns_db_create()"); - result = dns_db_load2(*db, file, inputformat); + result = dns_db_load(*db, file, inputformat, 0); if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) fatal("failed loading zone from '%s': %s", file, isc_result_totext(result)); diff --git a/bin/dnssec/dnssec-verify.c b/bin/dnssec/dnssec-verify.c index 8e6dda2acf..54acb7a57f 100644 --- a/bin/dnssec/dnssec-verify.c +++ b/bin/dnssec/dnssec-verify.c @@ -108,7 +108,7 @@ loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) { rdclass, 0, NULL, db); check_result(result, "dns_db_create()"); - result = dns_db_load2(*db, file, inputformat); + result = dns_db_load(*db, file, inputformat, 0); switch (result) { case DNS_R_SEENINCLUDE: case ISC_R_SUCCESS: diff --git a/bin/tests/makejournal.c b/bin/tests/makejournal.c index 37c70a78a7..03481b9ce2 100644 --- a/bin/tests/makejournal.c +++ b/bin/tests/makejournal.c @@ -75,7 +75,7 @@ loadzone(dns_db_t **db, const char *origin, const char *filename) { if (result != ISC_R_SUCCESS) return (result); - result = dns_db_load(*db, filename); + result = dns_db_load(*db, filename, dns_masterformat_text, 0); return (result); } diff --git a/bin/tests/optional/db_test.c b/bin/tests/optional/db_test.c index bc5d08f9e1..b3903cca75 100644 --- a/bin/tests/optional/db_test.c +++ b/bin/tests/optional/db_test.c @@ -274,7 +274,7 @@ load(const char *filename, const char *origintext, isc_boolean_t cache) { } printf("loading %s (%s)\n", filename, origintext); - result = dns_db_load(dbi->db, filename); + result = dns_db_load(dbi->db, filename, dns_masterformat_text, 0); if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) { dns_db_detach(&dbi->db); isc_mem_put(mctx, dbi, sizeof(*dbi)); diff --git a/bin/tests/optional/nsecify.c b/bin/tests/optional/nsecify.c index 5371bc4d44..3413399ec3 100644 --- a/bin/tests/optional/nsecify.c +++ b/bin/tests/optional/nsecify.c @@ -138,7 +138,7 @@ nsecify(char *filename) { result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone, dns_rdataclass_in, 0, NULL, &db); check_result(result, "dns_db_create()"); - result = dns_db_load(db, filename); + result = dns_db_load(db, filename, dns_masterformat_text, 0); if (result == DNS_R_SEENINCLUDE) result = ISC_R_SUCCESS; check_result(result, "dns_db_load()"); diff --git a/contrib/sdb/bdb/zone2bdb.c b/contrib/sdb/bdb/zone2bdb.c index e711853175..1d92804b65 100644 --- a/contrib/sdb/bdb/zone2bdb.c +++ b/contrib/sdb/bdb/zone2bdb.c @@ -142,7 +142,8 @@ main(int argc, char *argv[]) dns_dbtype_zone, dns_rdataclass_in, 0, NULL, &db) == ISC_R_SUCCESS); - REQUIRE(dns_db_load(db, argv[2]) == ISC_R_SUCCESS); + REQUIRE(dns_db_load(db, argv[2], dns_masterformat_text, 0) + == ISC_R_SUCCESS); REQUIRE(dns_db_createiterator(db, 0, &dbiter) == ISC_R_SUCCESS); diff --git a/contrib/sdb/ldap/zone2ldap.c b/contrib/sdb/ldap/zone2ldap.c index 3f5030307d..61ef42c0ca 100644 --- a/contrib/sdb/ldap/zone2ldap.c +++ b/contrib/sdb/ldap/zone2ldap.c @@ -228,7 +228,7 @@ main (int argc, char **argv) dns_rdataclass_in, 0, NULL, &db); isc_result_check (result, "dns_db_create"); - result = dns_db_load (db, zonefile); + result = dns_db_load(db, zonefile, dns_masterformat_text, 0); isc_result_check (result, "Check Zone Syntax: dns_db_load"); result = dns_db_createiterator (db, 0, &dbit); diff --git a/contrib/sdb/pgsql/zonetodb.c b/contrib/sdb/pgsql/zonetodb.c index dc63c5b540..6a1562c8d7 100644 --- a/contrib/sdb/pgsql/zonetodb.c +++ b/contrib/sdb/pgsql/zonetodb.c @@ -173,7 +173,7 @@ main(int argc, char **argv) { dns_rdataclass_in, 0, NULL, &db); check_result(result, "dns_db_create"); - result = dns_db_load(db, zonefile); + result = dns_db_load(db, zonefile, dns_masterformat_text, 0); if (result == DNS_R_SEENINCLUDE) result = ISC_R_SUCCESS; check_result(result, "dns_db_load"); diff --git a/contrib/sdb/sqlite/zone2sqlite.c b/contrib/sdb/sqlite/zone2sqlite.c index 88a2d01469..4137c7d2c7 100644 --- a/contrib/sdb/sqlite/zone2sqlite.c +++ b/contrib/sdb/sqlite/zone2sqlite.c @@ -182,7 +182,7 @@ main(int argc, char *argv[]) dns_rdataclass_in, 0, NULL, &db); check_result(result, "dns_db_create"); - result = dns_db_load(db, zonefile); + result = dns_db_load(db, zonefile, dns_masterformat_text, 0); if (result == DNS_R_SEENINCLUDE) result = ISC_R_SUCCESS; check_result(result, "dns_db_load"); diff --git a/lib/dns/cache.c b/lib/dns/cache.c index d37a018d09..952fd997d4 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -500,7 +500,8 @@ dns_cache_load(dns_cache_t *cache) { return (ISC_R_SUCCESS); LOCK(&cache->filelock); - result = dns_db_load(cache->db, cache->filename); + result = dns_db_load(cache->db, cache->filename, + dns_masterformat_text, 0); UNLOCK(&cache->filelock); return (result); diff --git a/lib/dns/db.c b/lib/dns/db.c index 6006db0591..6a2ca110ab 100644 --- a/lib/dns/db.c +++ b/lib/dns/db.c @@ -310,18 +310,8 @@ dns_db_endload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) { } isc_result_t -dns_db_load(dns_db_t *db, const char *filename) { - return (dns_db_load3(db, filename, dns_masterformat_text, 0)); -} - -isc_result_t -dns_db_load2(dns_db_t *db, const char *filename, dns_masterformat_t format) { - return (dns_db_load3(db, filename, format, 0)); -} - -isc_result_t -dns_db_load3(dns_db_t *db, const char *filename, dns_masterformat_t format, - unsigned int options) +dns_db_load(dns_db_t *db, const char *filename, dns_masterformat_t format, + unsigned int options) { isc_result_t result, eresult; dns_rdatacallbacks_t callbacks; @@ -369,20 +359,6 @@ dns_db_dump(dns_db_t *db, dns_dbversion_t *version, const char *filename) { dns_masterformat_text)); } -isc_result_t -dns_db_dump2(dns_db_t *db, dns_dbversion_t *version, const char *filename, - dns_masterformat_t masterformat) { - /* - * Dump 'db' into master file 'filename' in the 'masterformat' format. - * XXXJT: is it okay to modify the interface to the existing "dump" - * method? - */ - - REQUIRE(DNS_DB_VALID(db)); - - return ((db->methods->dump)(db, version, filename, masterformat)); -} - /*** *** Version Methods ***/ diff --git a/lib/dns/include/dns/db.h b/lib/dns/include/dns/db.h index 6b7a252858..121c62a703 100644 --- a/lib/dns/include/dns/db.h +++ b/lib/dns/include/dns/db.h @@ -518,14 +518,8 @@ dns_db_endload(dns_db_t *db, dns_rdatacallbacks_t *callbacks); */ isc_result_t -dns_db_load(dns_db_t *db, const char *filename); - -isc_result_t -dns_db_load2(dns_db_t *db, const char *filename, dns_masterformat_t format); - -isc_result_t -dns_db_load3(dns_db_t *db, const char *filename, dns_masterformat_t format, - unsigned int options); +dns_db_load(dns_db_t *db, const char *filename, dns_masterformat_t format, + unsigned int options); /*%< * Load master file 'filename' into 'db'. * @@ -575,10 +569,6 @@ dns_db_serialize(dns_db_t *db, dns_dbversion_t *version, FILE *rbtfile); isc_result_t dns_db_dump(dns_db_t *db, dns_dbversion_t *version, const char *filename); - -isc_result_t -dns_db_dump2(dns_db_t *db, dns_dbversion_t *version, const char *filename, - dns_masterformat_t masterformat); /*%< * Dump version 'version' of 'db' to master file 'filename'. * diff --git a/lib/dns/tests/db_test.c b/lib/dns/tests/db_test.c index f002a13962..1319682b08 100644 --- a/lib/dns/tests/db_test.c +++ b/lib/dns/tests/db_test.c @@ -280,7 +280,8 @@ ATF_TC_BODY(class, tc) { dns_rdataclass_in, 0, NULL, &db); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - result = dns_db_load(db, "testdata/db/data.db"); + result = dns_db_load(db, "testdata/db/data.db", + dns_masterformat_text, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); ATF_CHECK_EQ(dns_db_class(db), dns_rdataclass_in); @@ -303,7 +304,8 @@ ATF_TC_BODY(dbtype, tc) { result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone, dns_rdataclass_in, 0, NULL, &db); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - result = dns_db_load(db, "testdata/db/data.db"); + result = dns_db_load(db, "testdata/db/data.db", + dns_masterformat_text, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); ATF_CHECK(dns_db_iszone(db)); ATF_CHECK(!dns_db_iscache(db)); @@ -313,7 +315,8 @@ ATF_TC_BODY(dbtype, tc) { result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_cache, dns_rdataclass_in, 0, NULL, &db); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - result = dns_db_load(db, "testdata/db/data.db"); + result = dns_db_load(db, "testdata/db/data.db", + dns_masterformat_text, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); ATF_CHECK(dns_db_iscache(db)); ATF_CHECK(!dns_db_iszone(db)); diff --git a/lib/dns/tests/dnstest.c b/lib/dns/tests/dnstest.c index 1a546fa802..ef6d1844c0 100644 --- a/lib/dns/tests/dnstest.c +++ b/lib/dns/tests/dnstest.c @@ -335,7 +335,7 @@ dns_test_loaddb(dns_db_t **db, dns_dbtype_t dbtype, const char *origin, if (result != ISC_R_SUCCESS) return (result); - result = dns_db_load(*db, testfile); + result = dns_db_load(*db, testfile, dns_masterformat_text, 0); return (result); } diff --git a/lib/dns/tests/master_test.c b/lib/dns/tests/master_test.c index 3abb6782fa..7e7865debc 100644 --- a/lib/dns/tests/master_test.c +++ b/lib/dns/tests/master_test.c @@ -574,7 +574,8 @@ ATF_TC_BODY(dumpraw, tc) { dns_rdataclass_in, 0, NULL, &db); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - result = dns_db_load(db, "testdata/master/master1.data"); + result = dns_db_load(db, "testdata/master/master1.data", + dns_masterformat_text, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); dns_db_currentversion(db, &version); diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 45b2af1da0..025808d128 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -186,7 +186,6 @@ dns_db_detachnode dns_db_diff dns_db_diffx dns_db_dump -dns_db_dump2 dns_db_endload dns_db_expirenode dns_db_find @@ -211,8 +210,6 @@ dns_db_issecure dns_db_isstub dns_db_iszone dns_db_load -dns_db_load2 -dns_db_load3 dns_db_newversion dns_db_nodecount dns_db_nodefullname diff --git a/lib/ns/tests/nstest.c b/lib/ns/tests/nstest.c index 696ddd2b82..966477610c 100644 --- a/lib/ns/tests/nstest.c +++ b/lib/ns/tests/nstest.c @@ -853,7 +853,7 @@ ns_test_loaddb(dns_db_t **db, dns_dbtype_t dbtype, const char *origin, if (result != ISC_R_SUCCESS) return (result); - result = dns_db_load(*db, testfile); + result = dns_db_load(*db, testfile, dns_masterformat_text, 0); return (result); } From e20b70241856644df55925701933923bd02cd967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 14:35:07 +0200 Subject: [PATCH 07/18] libdns refactoring: get rid of multiple versions of dns_dispatch_createtcp and dns_dispatch_addresponse, unify dns_dispatch_gettcp and dns_dispatch_gettcp2 --- lib/dns/dispatch.c | 118 +++++---------------------------- lib/dns/include/dns/dispatch.h | 36 +++------- lib/dns/request.c | 34 +++++----- lib/dns/resolver.c | 27 ++++---- lib/dns/tests/dispatch_test.c | 4 +- lib/dns/win32/libdns.def.in | 4 -- 6 files changed, 58 insertions(+), 165 deletions(-) diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 68055c0f08..f66533154d 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -2496,28 +2496,12 @@ dispatch_free(dns_dispatch_t **dispp) { isc_result_t dns_dispatch_createtcp(dns_dispatchmgr_t *mgr, isc_socket_t *sock, - isc_taskmgr_t *taskmgr, unsigned int buffersize, + isc_taskmgr_t *taskmgr, const isc_sockaddr_t *localaddr, + const isc_sockaddr_t *destaddr, unsigned int buffersize, unsigned int maxbuffers, unsigned int maxrequests, unsigned int buckets, unsigned int increment, unsigned int attributes, dns_dispatch_t **dispp) { - - attributes |= DNS_DISPATCHATTR_PRIVATE; /* XXXMLG */ - - return (dns_dispatch_createtcp2(mgr, sock, taskmgr, NULL, NULL, - buffersize, maxbuffers, maxrequests, - buckets, increment, attributes, - dispp)); -} - -isc_result_t -dns_dispatch_createtcp2(dns_dispatchmgr_t *mgr, isc_socket_t *sock, - isc_taskmgr_t *taskmgr, const isc_sockaddr_t *localaddr, - const isc_sockaddr_t *destaddr, unsigned int buffersize, - unsigned int maxbuffers, unsigned int maxrequests, - unsigned int buckets, unsigned int increment, - unsigned int attributes, dns_dispatch_t **dispp) -{ isc_result_t result; dns_dispatch_t *disp; @@ -2623,7 +2607,8 @@ dns_dispatch_createtcp2(dns_dispatchmgr_t *mgr, isc_socket_t *sock, isc_result_t dns_dispatch_gettcp(dns_dispatchmgr_t *mgr, const isc_sockaddr_t *destaddr, - const isc_sockaddr_t *localaddr, dns_dispatch_t **dispp) + const isc_sockaddr_t *localaddr, isc_boolean_t *connected, + dns_dispatch_t **dispp) { dns_dispatch_t *disp; isc_result_t result; @@ -2636,6 +2621,7 @@ dns_dispatch_gettcp(dns_dispatchmgr_t *mgr, const isc_sockaddr_t *destaddr, REQUIRE(destaddr != NULL); REQUIRE(dispp != NULL && *dispp == NULL); + /* First pass */ attributes = DNS_DISPATCHATTR_TCP | DNS_DISPATCHATTR_CONNECTED; mask = DNS_DISPATCHATTR_TCP | DNS_DISPATCHATTR_PRIVATE | DNS_DISPATCHATTR_EXCLUSIVE | DNS_DISPATCHATTR_CONNECTED; @@ -2661,70 +2647,20 @@ dns_dispatch_gettcp(dns_dispatchmgr_t *mgr, const isc_sockaddr_t *destaddr, disp->refcount++; *dispp = disp; match = ISC_TRUE; + if (connected != NULL) { + *connected = ISC_TRUE; + } } } UNLOCK(&disp->lock); disp = ISC_LIST_NEXT(disp, link); } - UNLOCK(&mgr->lock); - return (match ? ISC_R_SUCCESS : ISC_R_NOTFOUND); -} - -isc_result_t -dns_dispatch_gettcp2(dns_dispatchmgr_t *mgr, const isc_sockaddr_t *destaddr, - const isc_sockaddr_t *localaddr, isc_boolean_t *connected, - dns_dispatch_t **dispp) -{ - dns_dispatch_t *disp; - isc_result_t result; - isc_sockaddr_t peeraddr; - isc_sockaddr_t sockname; - unsigned int attributes, mask; - isc_boolean_t match = ISC_FALSE; - - REQUIRE(VALID_DISPATCHMGR(mgr)); - REQUIRE(destaddr != NULL); - REQUIRE(dispp != NULL && *dispp == NULL); - REQUIRE(connected != NULL); - - /* First pass (same as dns_dispatch_gettcp()) */ - attributes = DNS_DISPATCHATTR_TCP | DNS_DISPATCHATTR_CONNECTED; - mask = DNS_DISPATCHATTR_TCP | DNS_DISPATCHATTR_PRIVATE | - DNS_DISPATCHATTR_EXCLUSIVE | DNS_DISPATCHATTR_CONNECTED; - - LOCK(&mgr->lock); - disp = ISC_LIST_HEAD(mgr->list); - while (disp != NULL && !match) { - LOCK(&disp->lock); - if ((disp->shutting_down == 0) && - ATTRMATCH(disp->attributes, attributes, mask) && - (localaddr == NULL || - isc_sockaddr_eqaddr(localaddr, &disp->local))) { - result = isc_socket_getsockname(disp->socket, - &sockname); - if (result == ISC_R_SUCCESS) - result = isc_socket_getpeername(disp->socket, - &peeraddr); - if (result == ISC_R_SUCCESS && - isc_sockaddr_equal(destaddr, &peeraddr) && - (localaddr == NULL || - isc_sockaddr_eqaddr(localaddr, &sockname))) { - /* attach */ - disp->refcount++; - *dispp = disp; - match = ISC_TRUE; - *connected = ISC_TRUE; - } - } - UNLOCK(&disp->lock); - disp = ISC_LIST_NEXT(disp, link); - } - if (match) { + if (match || connected == NULL) { UNLOCK(&mgr->lock); - return (ISC_R_SUCCESS); + return (match ? ISC_R_SUCCESS : ISC_R_NOTFOUND); } - /* Second pass */ + /* Second pass, only if connected != NULL */ attributes = DNS_DISPATCHATTR_TCP; disp = ISC_LIST_HEAD(mgr->list); @@ -3175,21 +3111,11 @@ dns_dispatch_detach(dns_dispatch_t **dispp) { } isc_result_t -dns_dispatch_addresponse2(dns_dispatch_t *disp, const isc_sockaddr_t *dest, - isc_task_t *task, isc_taskaction_t action, void *arg, - dns_messageid_t *idp, dns_dispentry_t **resp, - isc_socketmgr_t *sockmgr) -{ - return (dns_dispatch_addresponse3(disp, 0, dest, task, action, arg, - idp, resp, sockmgr)); -} - -isc_result_t -dns_dispatch_addresponse3(dns_dispatch_t *disp, unsigned int options, - const isc_sockaddr_t *dest, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_messageid_t *idp, dns_dispentry_t **resp, - isc_socketmgr_t *sockmgr) +dns_dispatch_addresponse(dns_dispatch_t *disp, unsigned int options, + const isc_sockaddr_t *dest, isc_task_t *task, + isc_taskaction_t action, void *arg, + dns_messageid_t *idp, dns_dispentry_t **resp, + isc_socketmgr_t *sockmgr) { dns_dispentry_t *res; unsigned int bucket; @@ -3383,18 +3309,6 @@ dns_dispatch_addresponse3(dns_dispatch_t *disp, unsigned int options, return (ISC_R_SUCCESS); } -isc_result_t -dns_dispatch_addresponse(dns_dispatch_t *disp, const isc_sockaddr_t *dest, - isc_task_t *task, isc_taskaction_t action, void *arg, - dns_messageid_t *idp, dns_dispentry_t **resp) -{ - REQUIRE(VALID_DISPATCH(disp)); - REQUIRE((disp->attributes & DNS_DISPATCHATTR_EXCLUSIVE) == 0); - - return (dns_dispatch_addresponse3(disp, 0, dest, task, action, arg, - idp, resp, NULL)); -} - void dns_dispatch_starttcp(dns_dispatch_t *disp) { diff --git a/lib/dns/include/dns/dispatch.h b/lib/dns/include/dns/dispatch.h index d3caf9cfac..44ade7e905 100644 --- a/lib/dns/include/dns/dispatch.h +++ b/lib/dns/include/dns/dispatch.h @@ -290,17 +290,11 @@ dns_dispatch_getudp_dup(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr, isc_result_t dns_dispatch_createtcp(dns_dispatchmgr_t *mgr, isc_socket_t *sock, - isc_taskmgr_t *taskmgr, unsigned int buffersize, + isc_taskmgr_t *taskmgr, const isc_sockaddr_t *localaddr, + const isc_sockaddr_t *destaddr, unsigned int buffersize, unsigned int maxbuffers, unsigned int maxrequests, unsigned int buckets, unsigned int increment, unsigned int attributes, dns_dispatch_t **dispp); -isc_result_t -dns_dispatch_createtcp2(dns_dispatchmgr_t *mgr, isc_socket_t *sock, - isc_taskmgr_t *taskmgr, const isc_sockaddr_t *localaddr, - const isc_sockaddr_t *destaddr, unsigned int buffersize, - unsigned int maxbuffers, unsigned int maxrequests, - unsigned int buckets, unsigned int increment, - unsigned int attributes, dns_dispatch_t **dispp); /*%< * Create a new dns_dispatch and attach it to the provided isc_socket_t. * @@ -374,34 +368,20 @@ dns_dispatch_starttcp(dns_dispatch_t *disp); isc_result_t dns_dispatch_gettcp(dns_dispatchmgr_t *mgr, const isc_sockaddr_t *destaddr, - const isc_sockaddr_t *localaddr, dns_dispatch_t **dispp); -isc_result_t -dns_dispatch_gettcp2(dns_dispatchmgr_t *mgr, const isc_sockaddr_t *destaddr, const isc_sockaddr_t *localaddr, isc_boolean_t *connected, dns_dispatch_t **dispp); /* * Attempt to connect to a existing TCP connection (connection completed - * for dns_dispatch_gettcp()). + * if connected == NULL). */ isc_result_t -dns_dispatch_addresponse3(dns_dispatch_t *disp, unsigned int options, - const isc_sockaddr_t *dest, isc_task_t *task, - isc_taskaction_t action, void *arg, - isc_uint16_t *idp, dns_dispentry_t **resp, - isc_socketmgr_t *sockmgr); - -isc_result_t -dns_dispatch_addresponse2(dns_dispatch_t *disp, const isc_sockaddr_t *dest, - isc_task_t *task, isc_taskaction_t action, void *arg, - isc_uint16_t *idp, dns_dispentry_t **resp, - isc_socketmgr_t *sockmgr); - -isc_result_t -dns_dispatch_addresponse(dns_dispatch_t *disp, const isc_sockaddr_t *dest, - isc_task_t *task, isc_taskaction_t action, void *arg, - isc_uint16_t *idp, dns_dispentry_t **resp); +dns_dispatch_addresponse(dns_dispatch_t *disp, unsigned int options, + const isc_sockaddr_t *dest, isc_task_t *task, + isc_taskaction_t action, void *arg, + isc_uint16_t *idp, dns_dispentry_t **resp, + isc_socketmgr_t *sockmgr); /*%< * Add a response entry for this dispatch. * diff --git a/lib/dns/request.c b/lib/dns/request.c index a5d522d575..cfc20eb68a 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -534,9 +534,9 @@ create_tcp_dispatch(isc_boolean_t newtcp, isc_boolean_t share, isc_sockaddr_t bind_any; if (!newtcp && share) { - result = dns_dispatch_gettcp2(requestmgr->dispatchmgr, - destaddr, srcaddr, - connected, dispatchp); + result = dns_dispatch_gettcp(requestmgr->dispatchmgr, + destaddr, srcaddr, + connected, dispatchp); if (result == ISC_R_SUCCESS) { char peer[ISC_SOCKADDR_FORMATSIZE]; @@ -548,7 +548,7 @@ create_tcp_dispatch(isc_boolean_t newtcp, isc_boolean_t share, } } else if (!newtcp) { result = dns_dispatch_gettcp(requestmgr->dispatchmgr, destaddr, - srcaddr, dispatchp); + srcaddr, NULL, dispatchp); if (result == ISC_R_SUCCESS) { char peer[ISC_SOCKADDR_FORMATSIZE]; @@ -588,11 +588,11 @@ create_tcp_dispatch(isc_boolean_t newtcp, isc_boolean_t share, attrs |= DNS_DISPATCHATTR_MAKEQUERY; isc_socket_dscp(sock, dscp); - result = dns_dispatch_createtcp2(requestmgr->dispatchmgr, - sock, requestmgr->taskmgr, - srcaddr, destaddr, - 4096, 32768, 32768, 16411, 16433, - attrs, dispatchp); + result = dns_dispatch_createtcp(requestmgr->dispatchmgr, + sock, requestmgr->taskmgr, + srcaddr, destaddr, + 4096, 32768, 32768, 16411, 16433, + attrs, dispatchp); cleanup: isc_socket_detach(&sock); return (result); @@ -832,10 +832,10 @@ dns_request_createraw4(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf, dispopt |= DNS_DISPATCHOPT_FIXEDID; } - result = dns_dispatch_addresponse3(request->dispatch, dispopt, - destaddr, task, req_response, - request, &id, &request->dispentry, - requestmgr->socketmgr); + result = dns_dispatch_addresponse(request->dispatch, dispopt, + destaddr, task, req_response, + request, &id, &request->dispentry, + requestmgr->socketmgr); if (result != ISC_R_SUCCESS) { if ((options & DNS_REQUESTOPT_FIXEDID) != 0 && !newtcp) { newtcp = ISC_TRUE; @@ -1060,10 +1060,10 @@ dns_request_createvia4(dns_requestmgr_t *requestmgr, dns_message_t *message, if (result != ISC_R_SUCCESS) goto cleanup; - result = dns_dispatch_addresponse2(request->dispatch, destaddr, task, - req_response, request, &id, - &request->dispentry, - requestmgr->socketmgr); + result = dns_dispatch_addresponse(request->dispatch, 0, destaddr, + task, req_response, request, &id, + &request->dispentry, + requestmgr->socketmgr); if (result != ISC_R_SUCCESS) goto cleanup; sock = req_getsocket(request); diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index b7b46db2e0..e6352458f1 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -2387,14 +2387,15 @@ resquery_send(resquery_t *query) { /* * Get a query id from the dispatch. */ - result = dns_dispatch_addresponse2(query->dispatch, - &query->addrinfo->sockaddr, - task, - resquery_response, - query, - &query->id, - &query->dispentry, - res->socketmgr); + result = dns_dispatch_addresponse(query->dispatch, + 0, + &query->addrinfo->sockaddr, + task, + resquery_response, + query, + &query->id, + &query->dispentry, + res->socketmgr); if (result != ISC_R_SUCCESS) goto cleanup_temps; @@ -2932,10 +2933,12 @@ resquery_connected(isc_task_t *task, isc_event_t *event) { attrs |= DNS_DISPATCHATTR_MAKEQUERY; result = dns_dispatch_createtcp(query->dispatchmgr, - query->tcpsocket, - query->fctx->res->taskmgr, - 4096, 2, 1, 1, 3, attrs, - &query->dispatch); + query->tcpsocket, + query->fctx->res->taskmgr, + NULL, NULL, + 4096, 2, 1, 1, 3, + attrs, + &query->dispatch); /* * Regardless of whether dns_dispatch_create() diff --git a/lib/dns/tests/dispatch_test.c b/lib/dns/tests/dispatch_test.c index d344c78d36..815241d2d6 100644 --- a/lib/dns/tests/dispatch_test.c +++ b/lib/dns/tests/dispatch_test.c @@ -294,8 +294,8 @@ ATF_TC_BODY(dispatch_getnext, tc) { result = isc_socket_recv(sock, ®ion, 1, task, nameserver, sock); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - result = dns_dispatch_addresponse(dispatch, &local, task, response, - NULL, &id, &dispentry); + result = dns_dispatch_addresponse(dispatch, 0, &local, task, response, + NULL, &id, &dispentry, NULL); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); memset(message, 0, sizeof(message)); diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 025808d128..7dc0e2b699 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -269,13 +269,10 @@ dns_difftuple_copy dns_difftuple_create dns_difftuple_free dns_dispatch_addresponse -dns_dispatch_addresponse2 -dns_dispatch_addresponse3 dns_dispatch_attach dns_dispatch_cancel dns_dispatch_changeattributes dns_dispatch_createtcp -dns_dispatch_createtcp2 dns_dispatch_detach dns_dispatch_getattributes dns_dispatch_getdscp @@ -284,7 +281,6 @@ dns_dispatch_getlocaladdress dns_dispatch_getnext dns_dispatch_getsocket dns_dispatch_gettcp -dns_dispatch_gettcp2 dns_dispatch_getudp dns_dispatch_getudp_dup dns_dispatch_importrecv From e2a06db7f3f8ccc4f6df4c8ecca47fac8cc34363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 13:09:55 +0200 Subject: [PATCH 08/18] libdns refactoring: get rid of multiple versions of dns_master_loadfile, dns_master_loadfileinc, dns_master_dump, dns_master_dumpinc, dns_master_dumptostream, dns_master_stylecreate --- bin/delv/delv.c | 18 ++--- bin/dig/dig.c | 18 ++--- bin/dnssec/dnssec-cds.c | 6 +- bin/dnssec/dnssec-signzone.c | 13 +-- bin/tests/optional/master_test.c | 5 +- bin/tools/mdig.c | 18 ++--- lib/dns/cache.c | 3 +- lib/dns/db.c | 6 +- lib/dns/include/dns/master.h | 112 +++----------------------- lib/dns/include/dns/masterdump.h | 60 +++----------- lib/dns/master.c | 132 +++---------------------------- lib/dns/masterdump.c | 89 ++------------------- lib/dns/rbtdb.c | 6 +- lib/dns/rootns.c | 5 +- lib/dns/sdlz.c | 3 +- lib/dns/tests/master_test.c | 28 +++---- lib/dns/view.c | 3 +- lib/dns/win32/libdns.def.in | 15 ---- lib/dns/zone.c | 57 ++++++------- 19 files changed, 137 insertions(+), 460 deletions(-) diff --git a/bin/delv/delv.c b/bin/delv/delv.c index af9fa4b77e..b2dfe2a810 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -521,17 +521,17 @@ setup_style(dns_master_style_t **stylep) { } if (multiline || (nottl && noclass)) - result = dns_master_stylecreate2(&style, styleflags, - 24, 24, 24, 32, 80, 8, - splitwidth, mctx); + result = dns_master_stylecreate(&style, styleflags, + 24, 24, 24, 32, 80, 8, + splitwidth, mctx); else if (nottl || noclass) - result = dns_master_stylecreate2(&style, styleflags, - 24, 24, 32, 40, 80, 8, - splitwidth, mctx); + result = dns_master_stylecreate(&style, styleflags, + 24, 24, 32, 40, 80, 8, + splitwidth, mctx); else - result = dns_master_stylecreate2(&style, styleflags, - 24, 32, 40, 48, 80, 8, - splitwidth, mctx); + result = dns_master_stylecreate(&style, styleflags, + 24, 32, 40, 48, 80, 8, + splitwidth, mctx); if (result == ISC_R_SUCCESS) *stylep = style; diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 482809ccf0..71a00939ac 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -480,17 +480,17 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) { } if (query->lookup->multiline || (query->lookup->nottl && query->lookup->noclass)) - result = dns_master_stylecreate2(&style, styleflags, - 24, 24, 24, 32, 80, 8, - splitwidth, mctx); + result = dns_master_stylecreate(&style, styleflags, + 24, 24, 24, 32, 80, 8, + splitwidth, mctx); else if (query->lookup->nottl || query->lookup->noclass) - result = dns_master_stylecreate2(&style, styleflags, - 24, 24, 32, 40, 80, 8, - splitwidth, mctx); + result = dns_master_stylecreate(&style, styleflags, + 24, 24, 32, 40, 80, 8, + splitwidth, mctx); else - result = dns_master_stylecreate2(&style, styleflags, - 24, 32, 40, 48, 80, 8, - splitwidth, mctx); + result = dns_master_stylecreate(&style, styleflags, + 24, 32, 40, 48, 80, 8, + splitwidth, mctx); check_result(result, "dns_master_stylecreate"); if (query->lookup->cmdline[0] != 0) { diff --git a/bin/dnssec/dnssec-cds.c b/bin/dnssec/dnssec-cds.c index 6249a1b178..b9e44be02c 100644 --- a/bin/dnssec/dnssec-cds.c +++ b/bin/dnssec/dnssec-cds.c @@ -379,9 +379,9 @@ formatset(dns_rdataset_t *rdataset) { * which just separates fields with spaces. The huge tab stop width * eliminates any tab characters. */ - result = dns_master_stylecreate2(&style, styleflags, - 0, 0, 0, 0, 0, 1000000, 0, - mctx); + result = dns_master_stylecreate(&style, styleflags, + 0, 0, 0, 0, 0, 1000000, 0, + mctx); check_result(result, "dns_master_stylecreate2 failed"); result = isc_buffer_allocate(mctx, &buf, MAX_CDS_RDATA_TEXT_SIZE); diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 1f15017516..ee0be4f9f2 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -2985,7 +2985,8 @@ writeset(const char *prefix, dns_rdatatype_t type) { check_result(result, "dns_diff_apply"); dns_diff_clear(&diff); - result = dns_master_dump(mctx, db, dbversion, style, filename); + result = dns_master_dump(mctx, db, dbversion, style, filename, + dns_masterformat_text, NULL); check_result(result, "dns_master_dump"); isc_mem_put(mctx, filename, filenamelen); @@ -3633,8 +3634,8 @@ main(int argc, char *argv[]) { if (output_dnssec_only && set_maxttl) fatal("option -D cannot be used with -M"); - result = dns_master_stylecreate(&dsstyle, DNS_STYLEFLAG_NO_TTL, - 0, 24, 0, 0, 0, 8, mctx); + result = dns_master_stylecreate(&dsstyle, DNS_STYLEFLAG_NO_TTL, + 0, 24, 0, 0, 0, 8, 0xffffffff, mctx); check_result(result, "dns_master_stylecreate"); gdb = NULL; @@ -3878,9 +3879,9 @@ main(int argc, char *argv[]) { header.flags = DNS_MASTERRAW_SOURCESERIALSET; header.sourceserial = serialnum; } - result = dns_master_dumptostream3(mctx, gdb, gversion, - masterstyle, outputformat, - &header, outfp); + result = dns_master_dumptostream(mctx, gdb, gversion, + masterstyle, outputformat, + &header, outfp); check_result(result, "dns_master_dumptostream3"); } diff --git a/bin/tests/optional/master_test.c b/bin/tests/optional/master_test.c index 8d021842ae..ede633ae54 100644 --- a/bin/tests/optional/master_test.c +++ b/bin/tests/optional/master_test.c @@ -79,8 +79,9 @@ main(int argc, char *argv[]) { callbacks.add = print_dataset; result = dns_master_loadfile(argv[1], &origin, &origin, - dns_rdataclass_in, 0, - &callbacks, mctx); + dns_rdataclass_in, 0, 0, + &callbacks, NULL, NULL, mctx, + dns_masterformat_text, 0); fprintf(stdout, "dns_master_loadfile: %s\n", dns_result_totext(result)); } diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index cc21f74089..492d0a844e 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -268,17 +268,17 @@ recvresponse(isc_task_t *task, isc_event_t *event) { styleflags |= DNS_STYLEFLAG_RRCOMMENT; } if (display_multiline || (!display_ttl && !display_class)) - result = dns_master_stylecreate2(&style, styleflags, - 24, 24, 24, 32, 80, 8, - display_splitwidth, mctx); + result = dns_master_stylecreate(&style, styleflags, + 24, 24, 24, 32, 80, 8, + display_splitwidth, mctx); else if (!display_ttl || !display_class) - result = dns_master_stylecreate2(&style, styleflags, - 24, 24, 32, 40, 80, 8, - display_splitwidth, mctx); + result = dns_master_stylecreate(&style, styleflags, + 24, 24, 32, 40, 80, 8, + display_splitwidth, mctx); else - result = dns_master_stylecreate2(&style, styleflags, - 24, 32, 40, 48, 80, 8, - display_splitwidth, mctx); + result = dns_master_stylecreate(&style, styleflags, + 24, 32, 40, 48, 80, 8, + display_splitwidth, mctx); CHECK("dns_master_stylecreate2", result); flags = 0; diff --git a/lib/dns/cache.c b/lib/dns/cache.c index 952fd997d4..fc640ae616 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -518,7 +518,8 @@ dns_cache_dump(dns_cache_t *cache) { LOCK(&cache->filelock); result = dns_master_dump(cache->mctx, cache->db, NULL, - &dns_master_style_cache, cache->filename); + &dns_master_style_cache, cache->filename, + dns_masterformat_text, NULL); UNLOCK(&cache->filelock); return (result); diff --git a/lib/dns/db.c b/lib/dns/db.c index 6a2ca110ab..ce9c424f89 100644 --- a/lib/dns/db.c +++ b/lib/dns/db.c @@ -329,9 +329,9 @@ dns_db_load(dns_db_t *db, const char *filename, dns_masterformat_t format, result = dns_db_beginload(db, &callbacks); if (result != ISC_R_SUCCESS) return (result); - result = dns_master_loadfile2(filename, &db->origin, &db->origin, - db->rdclass, options, - &callbacks, db->mctx, format); + result = dns_master_loadfile(filename, &db->origin, &db->origin, + db->rdclass, options, 0, &callbacks, + NULL, NULL, db->mctx, format, 0); eresult = dns_db_endload(db, &callbacks); /* * We always call dns_db_endload(), but we only want to return its diff --git a/lib/dns/include/dns/master.h b/lib/dns/include/dns/master.h index a0075fddcd..2c257e7983 100644 --- a/lib/dns/include/dns/master.h +++ b/lib/dns/include/dns/master.h @@ -118,54 +118,12 @@ dns_master_loadfile(const char *master_file, dns_name_t *origin, dns_rdataclass_t zclass, unsigned int options, + isc_uint32_t resign, dns_rdatacallbacks_t *callbacks, - isc_mem_t *mctx); - -isc_result_t -dns_master_loadfile2(const char *master_file, - dns_name_t *top, - dns_name_t *origin, - dns_rdataclass_t zclass, - unsigned int options, - dns_rdatacallbacks_t *callbacks, - isc_mem_t *mctx, - dns_masterformat_t format); - -isc_result_t -dns_master_loadfile3(const char *master_file, - dns_name_t *top, - dns_name_t *origin, - dns_rdataclass_t zclass, - unsigned int options, - isc_uint32_t resign, - dns_rdatacallbacks_t *callbacks, - isc_mem_t *mctx, - dns_masterformat_t format); - -isc_result_t -dns_master_loadfile4(const char *master_file, - dns_name_t *top, - dns_name_t *origin, - dns_rdataclass_t zclass, - unsigned int options, - isc_uint32_t resign, - dns_rdatacallbacks_t *callbacks, - dns_masterincludecb_t include_cb, - void *include_arg, isc_mem_t *mctx, - dns_masterformat_t format); - -isc_result_t -dns_master_loadfile5(const char *master_file, - dns_name_t *top, - dns_name_t *origin, - dns_rdataclass_t zclass, - unsigned int options, - isc_uint32_t resign, - dns_rdatacallbacks_t *callbacks, - dns_masterincludecb_t include_cb, - void *include_arg, isc_mem_t *mctx, - dns_masterformat_t format, - dns_ttl_t maxttl); + dns_masterincludecb_t include_cb, + void *include_arg, isc_mem_t *mctx, + dns_masterformat_t format, + dns_ttl_t maxttl); isc_result_t dns_master_loadstream(FILE *stream, @@ -200,64 +158,14 @@ dns_master_loadfileinc(const char *master_file, dns_name_t *origin, dns_rdataclass_t zclass, unsigned int options, + isc_uint32_t resign, dns_rdatacallbacks_t *callbacks, isc_task_t *task, dns_loaddonefunc_t done, void *done_arg, - dns_loadctx_t **ctxp, isc_mem_t *mctx); - -isc_result_t -dns_master_loadfileinc2(const char *master_file, - dns_name_t *top, - dns_name_t *origin, - dns_rdataclass_t zclass, - unsigned int options, - dns_rdatacallbacks_t *callbacks, - isc_task_t *task, - dns_loaddonefunc_t done, void *done_arg, - dns_loadctx_t **ctxp, isc_mem_t *mctx, - dns_masterformat_t format); - -isc_result_t -dns_master_loadfileinc3(const char *master_file, - dns_name_t *top, - dns_name_t *origin, - dns_rdataclass_t zclass, - unsigned int options, - isc_uint32_t resign, - dns_rdatacallbacks_t *callbacks, - isc_task_t *task, - dns_loaddonefunc_t done, void *done_arg, - dns_loadctx_t **ctxp, isc_mem_t *mctx, - dns_masterformat_t format); - -isc_result_t -dns_master_loadfileinc4(const char *master_file, - dns_name_t *top, - dns_name_t *origin, - dns_rdataclass_t zclass, - unsigned int options, - isc_uint32_t resign, - dns_rdatacallbacks_t *callbacks, - isc_task_t *task, - dns_loaddonefunc_t done, void *done_arg, - dns_loadctx_t **ctxp, - dns_masterincludecb_t include_cb, void *include_arg, - isc_mem_t *mctx, dns_masterformat_t format); - -isc_result_t -dns_master_loadfileinc5(const char *master_file, - dns_name_t *top, - dns_name_t *origin, - dns_rdataclass_t zclass, - unsigned int options, - isc_uint32_t resign, - dns_rdatacallbacks_t *callbacks, - isc_task_t *task, - dns_loaddonefunc_t done, void *done_arg, - dns_loadctx_t **ctxp, - dns_masterincludecb_t include_cb, void *include_arg, - isc_mem_t *mctx, dns_masterformat_t format, - isc_uint32_t maxttl); + dns_loadctx_t **ctxp, + dns_masterincludecb_t include_cb, void *include_arg, + isc_mem_t *mctx, dns_masterformat_t format, + isc_uint32_t maxttl); isc_result_t dns_master_loadstreaminc(FILE *stream, diff --git a/lib/dns/include/dns/masterdump.h b/lib/dns/include/dns/masterdump.h index 6a3fe6ca21..f3acd11399 100644 --- a/lib/dns/include/dns/masterdump.h +++ b/lib/dns/include/dns/masterdump.h @@ -267,20 +267,9 @@ dns_master_dumptostreaminc(isc_mem_t *mctx, dns_db_t *db, isc_result_t dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, - const dns_master_style_t *style, FILE *f); - -isc_result_t -dns_master_dumptostream2(isc_mem_t *mctx, dns_db_t *db, - dns_dbversion_t *version, - const dns_master_style_t *style, - dns_masterformat_t format, FILE *f); - -isc_result_t -dns_master_dumptostream3(isc_mem_t *mctx, dns_db_t *db, - dns_dbversion_t *version, - const dns_master_style_t *style, - dns_masterformat_t format, - dns_masterrawheader_t *header, FILE *f); + const dns_master_style_t *style, + dns_masterformat_t format, + dns_masterrawheader_t *header, FILE *f); /*%< * Dump the database 'db' to the steam 'f' in the specified format by * 'format'. If the format is dns_masterformat_text (the RFC1035 format), @@ -311,40 +300,19 @@ dns_master_dumptostream3(isc_mem_t *mctx, dns_db_t *db, /*@}*/ /*@{*/ + isc_result_t dns_master_dumpinc(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, const dns_master_style_t *style, const char *filename, - isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg, - dns_dumpctx_t **dctxp); - -isc_result_t -dns_master_dumpinc2(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, - const dns_master_style_t *style, const char *filename, - isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg, dns_dumpctx_t **dctxp, dns_masterformat_t format); - -isc_result_t -dns_master_dumpinc3(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, - const dns_master_style_t *style, const char *filename, - isc_task_t *task, dns_dumpdonefunc_t done, void - *done_arg, dns_dumpctx_t **dctxp, - dns_masterformat_t format, dns_masterrawheader_t *header); + isc_task_t *task, dns_dumpdonefunc_t done, void + *done_arg, dns_dumpctx_t **dctxp, + dns_masterformat_t format, dns_masterrawheader_t *header); isc_result_t dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, - const dns_master_style_t *style, const char *filename); - -isc_result_t -dns_master_dump2(isc_mem_t *mctx, dns_db_t *db, - dns_dbversion_t *version, - const dns_master_style_t *style, const char *filename, - dns_masterformat_t format); - -isc_result_t -dns_master_dump3(isc_mem_t *mctx, dns_db_t *db, - dns_dbversion_t *version, - const dns_master_style_t *style, const char *filename, - dns_masterformat_t format, dns_masterrawheader_t *header); + const dns_master_style_t *style, const char *filename, + dns_masterformat_t format, dns_masterrawheader_t *header); /*%< * Dump the database 'db' to the file 'filename' in the specified format by @@ -414,15 +382,7 @@ dns_master_stylecreate(dns_master_style_t **style, unsigned int ttl_column, unsigned int class_column, unsigned int type_column, unsigned int rdata_column, unsigned int line_length, unsigned int tab_width, - isc_mem_t *mctx); - -isc_result_t -dns_master_stylecreate2(dns_master_style_t **style, - dns_masterstyle_flags_t flags, - unsigned int ttl_column, unsigned int class_column, - unsigned int type_column, unsigned int rdata_column, - unsigned int line_length, unsigned int tab_width, - unsigned int split_width, isc_mem_t *mctx); + unsigned int split_width, isc_mem_t *mctx); void dns_master_styledestroy(dns_master_style_t **style, isc_mem_t *mctx); diff --git a/lib/dns/master.c b/lib/dns/master.c index e2a1f70b61..a49fa26c8e 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -2588,61 +2588,12 @@ load_raw(dns_loadctx_t *lctx) { isc_result_t dns_master_loadfile(const char *master_file, dns_name_t *top, - dns_name_t *origin, - dns_rdataclass_t zclass, unsigned int options, - dns_rdatacallbacks_t *callbacks, isc_mem_t *mctx) -{ - return (dns_master_loadfile5(master_file, top, origin, zclass, - options, 0, callbacks, NULL, NULL, - mctx, dns_masterformat_text, 0)); -} - -isc_result_t -dns_master_loadfile2(const char *master_file, dns_name_t *top, - dns_name_t *origin, - dns_rdataclass_t zclass, unsigned int options, - dns_rdatacallbacks_t *callbacks, isc_mem_t *mctx, - dns_masterformat_t format) -{ - return (dns_master_loadfile5(master_file, top, origin, zclass, - options, 0, callbacks, NULL, NULL, - mctx, format, 0)); -} - -isc_result_t -dns_master_loadfile3(const char *master_file, dns_name_t *top, - dns_name_t *origin, dns_rdataclass_t zclass, - unsigned int options, isc_uint32_t resign, - dns_rdatacallbacks_t *callbacks, isc_mem_t *mctx, - dns_masterformat_t format) -{ - return (dns_master_loadfile5(master_file, top, origin, zclass, - options, resign, callbacks, NULL, NULL, - mctx, format, 0)); -} - -isc_result_t -dns_master_loadfile4(const char *master_file, dns_name_t *top, - dns_name_t *origin, dns_rdataclass_t zclass, - unsigned int options, isc_uint32_t resign, - dns_rdatacallbacks_t *callbacks, - dns_masterincludecb_t include_cb, void *include_arg, - isc_mem_t *mctx, dns_masterformat_t format) -{ - return (dns_master_loadfile5(master_file, top, origin, zclass, - options, resign, callbacks, - include_cb, include_arg, - mctx, format, 0)); -} - -isc_result_t -dns_master_loadfile5(const char *master_file, dns_name_t *top, - dns_name_t *origin, dns_rdataclass_t zclass, - unsigned int options, isc_uint32_t resign, - dns_rdatacallbacks_t *callbacks, - dns_masterincludecb_t include_cb, void *include_arg, - isc_mem_t *mctx, dns_masterformat_t format, - dns_ttl_t maxttl) + dns_name_t *origin, dns_rdataclass_t zclass, + unsigned int options, isc_uint32_t resign, + dns_rdatacallbacks_t *callbacks, + dns_masterincludecb_t include_cb, void *include_arg, + isc_mem_t *mctx, dns_masterformat_t format, + dns_ttl_t maxttl) { dns_loadctx_t *lctx = NULL; isc_result_t result; @@ -2670,72 +2621,13 @@ dns_master_loadfile5(const char *master_file, dns_name_t *top, isc_result_t dns_master_loadfileinc(const char *master_file, dns_name_t *top, dns_name_t *origin, dns_rdataclass_t zclass, - unsigned int options, dns_rdatacallbacks_t *callbacks, + unsigned int options, isc_uint32_t resign, + dns_rdatacallbacks_t *callbacks, isc_task_t *task, dns_loaddonefunc_t done, - void *done_arg, dns_loadctx_t **lctxp, isc_mem_t *mctx) -{ - return (dns_master_loadfileinc4(master_file, top, origin, zclass, - options, 0, callbacks, task, done, - done_arg, lctxp, NULL, NULL, mctx, - dns_masterformat_text)); -} - -isc_result_t -dns_master_loadfileinc2(const char *master_file, dns_name_t *top, - dns_name_t *origin, dns_rdataclass_t zclass, - unsigned int options, dns_rdatacallbacks_t *callbacks, - isc_task_t *task, dns_loaddonefunc_t done, - void *done_arg, dns_loadctx_t **lctxp, isc_mem_t *mctx, - dns_masterformat_t format) -{ - return (dns_master_loadfileinc4(master_file, top, origin, zclass, - options, 0, callbacks, task, done, - done_arg, lctxp, NULL, NULL, mctx, - format)); -} - -isc_result_t -dns_master_loadfileinc3(const char *master_file, dns_name_t *top, - dns_name_t *origin, dns_rdataclass_t zclass, - unsigned int options, isc_uint32_t resign, - dns_rdatacallbacks_t *callbacks, isc_task_t *task, - dns_loaddonefunc_t done, void *done_arg, - dns_loadctx_t **lctxp, isc_mem_t *mctx, - dns_masterformat_t format) -{ - return (dns_master_loadfileinc4(master_file, top, origin, zclass, - options, resign, callbacks, task, - done, done_arg, lctxp, NULL, NULL, - mctx, format)); -} - -isc_result_t -dns_master_loadfileinc4(const char *master_file, dns_name_t *top, - dns_name_t *origin, dns_rdataclass_t zclass, - unsigned int options, isc_uint32_t resign, - dns_rdatacallbacks_t *callbacks, - isc_task_t *task, dns_loaddonefunc_t done, - void *done_arg, dns_loadctx_t **lctxp, - dns_masterincludecb_t include_cb, void *include_arg, - isc_mem_t *mctx, dns_masterformat_t format) -{ - options &= ~DNS_MASTER_CHECKTTL; - return (dns_master_loadfileinc5(master_file, top, origin, zclass, - options, resign, callbacks, task, - done, done_arg, lctxp, include_cb, - include_arg, mctx, format, 0)); -} - -isc_result_t -dns_master_loadfileinc5(const char *master_file, dns_name_t *top, - dns_name_t *origin, dns_rdataclass_t zclass, - unsigned int options, isc_uint32_t resign, - dns_rdatacallbacks_t *callbacks, - isc_task_t *task, dns_loaddonefunc_t done, - void *done_arg, dns_loadctx_t **lctxp, - dns_masterincludecb_t include_cb, void *include_arg, - isc_mem_t *mctx, dns_masterformat_t format, - isc_uint32_t maxttl) + void *done_arg, dns_loadctx_t **lctxp, + dns_masterincludecb_t include_cb, void *include_arg, + isc_mem_t *mctx, dns_masterformat_t format, + isc_uint32_t maxttl) { dns_loadctx_t *lctx = NULL; isc_result_t result; diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 0c17907a3d..6fd0d29a40 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -1793,35 +1793,12 @@ dns_master_dumptostreaminc(isc_mem_t *mctx, dns_db_t *db, return (result); } -/* - * Dump an entire database into a master file. - */ isc_result_t dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, const dns_master_style_t *style, - FILE *f) -{ - return (dns_master_dumptostream3(mctx, db, version, style, - dns_masterformat_text, NULL, f)); -} - -isc_result_t -dns_master_dumptostream2(isc_mem_t *mctx, dns_db_t *db, - dns_dbversion_t *version, - const dns_master_style_t *style, - dns_masterformat_t format, FILE *f) -{ - return (dns_master_dumptostream3(mctx, db, version, style, - format, NULL, f)); -} - -isc_result_t -dns_master_dumptostream3(isc_mem_t *mctx, dns_db_t *db, - dns_dbversion_t *version, - const dns_master_style_t *style, - dns_masterformat_t format, - dns_masterrawheader_t *header, FILE *f) + dns_masterformat_t format, + dns_masterrawheader_t *header, FILE *f) { dns_dumpctx_t *dctx = NULL; isc_result_t result; @@ -1880,29 +1857,8 @@ isc_result_t dns_master_dumpinc(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, const dns_master_style_t *style, const char *filename, isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg, - dns_dumpctx_t **dctxp) -{ - return (dns_master_dumpinc3(mctx, db, version, style, filename, task, - done, done_arg, dctxp, - dns_masterformat_text, NULL)); -} - -isc_result_t -dns_master_dumpinc2(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, - const dns_master_style_t *style, const char *filename, - isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg, - dns_dumpctx_t **dctxp, dns_masterformat_t format) -{ - return (dns_master_dumpinc3(mctx, db, version, style, filename, task, - done, done_arg, dctxp, format, NULL)); -} - -isc_result_t -dns_master_dumpinc3(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, - const dns_master_style_t *style, const char *filename, - isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg, - dns_dumpctx_t **dctxp, dns_masterformat_t format, - dns_masterrawheader_t *header) + dns_dumpctx_t **dctxp, dns_masterformat_t format, + dns_masterrawheader_t *header) { FILE *f = NULL; isc_result_t result; @@ -1953,25 +1909,8 @@ dns_master_dumpinc3(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, isc_result_t dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, - const dns_master_style_t *style, const char *filename) -{ - return (dns_master_dump3(mctx, db, version, style, filename, - dns_masterformat_text, NULL)); -} - -isc_result_t -dns_master_dump2(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, - const dns_master_style_t *style, const char *filename, - dns_masterformat_t format) -{ - return (dns_master_dump3(mctx, db, version, style, filename, - format, NULL)); -} - -isc_result_t -dns_master_dump3(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, - const dns_master_style_t *style, const char *filename, - dns_masterformat_t format, dns_masterrawheader_t *header) + const dns_master_style_t *style, const char *filename, + dns_masterformat_t format, dns_masterrawheader_t *header) { FILE *f = NULL; isc_result_t result; @@ -2098,21 +2037,7 @@ dns_master_stylecreate(dns_master_style_t **stylep, unsigned int ttl_column, unsigned int class_column, unsigned int type_column, unsigned int rdata_column, unsigned int line_length, unsigned int tab_width, - isc_mem_t *mctx) -{ - return (dns_master_stylecreate2(stylep, flags, ttl_column, - class_column, type_column, - rdata_column, line_length, - tab_width, 0xffffffff, mctx)); -} - -isc_result_t -dns_master_stylecreate2(dns_master_style_t **stylep, - dns_masterstyle_flags_t flags, - unsigned int ttl_column, unsigned int class_column, - unsigned int type_column, unsigned int rdata_column, - unsigned int line_length, unsigned int tab_width, - unsigned int split_width, isc_mem_t *mctx) + unsigned int split_width, isc_mem_t *mctx) { dns_master_style_t *style; diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 62ec8ca502..7aa5e43c1a 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -7931,9 +7931,9 @@ dump(dns_db_t *db, dns_dbversion_t *version, const char *filename, REQUIRE(VALID_RBTDB(rbtdb)); INSIST(rbtversion == NULL || rbtversion->rbtdb == rbtdb); - return (dns_master_dump2(rbtdb->common.mctx, db, version, - &dns_master_style_default, - filename, masterformat)); + return (dns_master_dump(rbtdb->common.mctx, db, version, + &dns_master_style_default, + filename, masterformat, NULL)); } static void diff --git a/lib/dns/rootns.c b/lib/dns/rootns.c index 4427d050b5..15139938b2 100644 --- a/lib/dns/rootns.c +++ b/lib/dns/rootns.c @@ -224,8 +224,9 @@ dns_rootns_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, */ result = dns_master_loadfile(filename, &db->origin, &db->origin, db->rdclass, - DNS_MASTER_HINT, - &callbacks, db->mctx); + DNS_MASTER_HINT, 0, &callbacks, + NULL, NULL, db->mctx, + dns_masterformat_text, 0); } else if (rdclass == dns_rdataclass_in) { /* * Default to using the Internet root servers. diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index fe94108661..f333c04996 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -1126,7 +1126,8 @@ modrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, if (result != ISC_R_SUCCESS) return (result); - result = dns_master_stylecreate(&style, 0, 0, 0, 0, 0, 0, 1, mctx); + result = dns_master_stylecreate(&style, 0, 0, 0, 0, 0, 0, 1, + 0xffffffff, mctx); if (result != ISC_R_SUCCESS) goto cleanup; diff --git a/lib/dns/tests/master_test.c b/lib/dns/tests/master_test.c index 7e7865debc..9beda1aaf2 100644 --- a/lib/dns/tests/master_test.c +++ b/lib/dns/tests/master_test.c @@ -123,9 +123,9 @@ test_master(const char *testfile, dns_masterformat_t format, if (result != ISC_R_SUCCESS) return(result); - result = dns_master_loadfile2(testfile, &dns_origin, &dns_origin, - dns_rdataclass_in, ISC_TRUE, - &callbacks, mctx, format); + result = dns_master_loadfile(testfile, &dns_origin, &dns_origin, + dns_rdataclass_in, ISC_TRUE, 0, + &callbacks, NULL, NULL, mctx, format, 0); return (result); } @@ -378,11 +378,11 @@ ATF_TC_BODY(master_includelist, tc) { result = setup_master(NULL, NULL); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - result = dns_master_loadfile4("testdata/master/master8.data", - &dns_origin, &dns_origin, - dns_rdataclass_in, 0, ISC_TRUE, - &callbacks, include_callback, - &filename, mctx, dns_masterformat_text); + result = dns_master_loadfile("testdata/master/master8.data", + &dns_origin, &dns_origin, + dns_rdataclass_in, 0, ISC_TRUE, + &callbacks, include_callback, + &filename, mctx, dns_masterformat_text, 0); ATF_CHECK_EQ(result, DNS_R_SEENINCLUDE); ATF_CHECK(filename != NULL); if (filename != NULL) { @@ -580,9 +580,9 @@ ATF_TC_BODY(dumpraw, tc) { dns_db_currentversion(db, &version); - result = dns_master_dump2(mctx, db, version, - &dns_master_style_default, "test.dump", - dns_masterformat_raw); + result = dns_master_dump(mctx, db, version, + &dns_master_style_default, "test.dump", + dns_masterformat_raw, NULL); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = test_master("test.dump", dns_masterformat_raw, NULL, NULL); @@ -595,9 +595,9 @@ ATF_TC_BODY(dumpraw, tc) { header.flags |= DNS_MASTERRAW_SOURCESERIALSET; unlink("test.dump"); - result = dns_master_dump3(mctx, db, version, - &dns_master_style_default, "test.dump", - dns_masterformat_raw, &header); + result = dns_master_dump(mctx, db, version, + &dns_master_style_default, "test.dump", + dns_masterformat_raw, &header); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = test_master("test.dump", dns_masterformat_raw, NULL, NULL); diff --git a/lib/dns/view.c b/lib/dns/view.c index 96ea911fb8..7a569bb26a 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -1610,7 +1610,8 @@ dns_view_dumpdbtostream(dns_view_t *view, FILE *fp) { (void)fprintf(fp, ";\n; Cache dump of view '%s'\n;\n", view->name); result = dns_master_dumptostream(view->mctx, view->cachedb, NULL, - &dns_master_style_cache, fp); + &dns_master_style_cache, + dns_masterformat_text, NULL, fp); if (result != ISC_R_SUCCESS) return (result); dns_adb_dump(view->adb, fp); diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 7dc0e2b699..cb5c7c5202 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -458,30 +458,16 @@ dns_lookup_cancel dns_lookup_create dns_lookup_destroy dns_master_dump -dns_master_dump2 -dns_master_dump3 dns_master_dumpinc -dns_master_dumpinc2 -dns_master_dumpinc3 dns_master_dumpnode dns_master_dumpnodetostream dns_master_dumptostream -dns_master_dumptostream2 -dns_master_dumptostream3 dns_master_dumptostreaminc dns_master_initrawheader dns_master_loadbuffer dns_master_loadbufferinc dns_master_loadfile -dns_master_loadfile2 -dns_master_loadfile3 -dns_master_loadfile4 -dns_master_loadfile5 dns_master_loadfileinc -dns_master_loadfileinc2 -dns_master_loadfileinc3 -dns_master_loadfileinc4 -dns_master_loadfileinc5 dns_master_loadlexer dns_master_loadlexerinc dns_master_loadstream @@ -489,7 +475,6 @@ dns_master_loadstreaminc dns_master_questiontotext dns_master_rdatasettotext dns_master_stylecreate -dns_master_stylecreate2 dns_master_styledestroy dns_master_styleflags dns_message_addname diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 707d5c9fc7..6fe852f3c8 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -2353,17 +2353,17 @@ zone_gotreadhandle(isc_task_t *task, isc_event_t *event) { options = get_master_options(load->zone); - result = dns_master_loadfileinc5(load->zone->masterfile, - dns_db_origin(load->db), - dns_db_origin(load->db), - load->zone->rdclass, options, 0, - &load->callbacks, task, - zone_loaddone, load, - &load->zone->lctx, - zone_registerinclude, - load->zone, load->zone->mctx, - load->zone->masterformat, - load->zone->maxttl); + result = dns_master_loadfileinc(load->zone->masterfile, + dns_db_origin(load->db), + dns_db_origin(load->db), + load->zone->rdclass, options, 0, + &load->callbacks, task, + zone_loaddone, load, + &load->zone->lctx, + zone_registerinclude, + load->zone, load->zone->mctx, + load->zone->masterformat, + load->zone->maxttl); if (result != ISC_R_SUCCESS && result != DNS_R_CONTINUE && result != DNS_R_SEENINCLUDE) goto fail; @@ -2424,10 +2424,11 @@ zone_gotwritehandle(isc_task_t *task, isc_event_t *event) { output_style = zone->masterstyle; else output_style = &dns_master_style_default; - result = dns_master_dumpinc3(zone->mctx, zone->db, version, - output_style, zone->masterfile, - zone->task, dump_done, zone, &zone->dctx, zone->masterformat, - &rawdata); + result = dns_master_dumpinc(zone->mctx, zone->db, version, + output_style, zone->masterfile, + zone->task, dump_done, zone, + &zone->dctx, zone->masterformat, + &rawdata); dns_db_closeversion(zone->db, &version, ISC_FALSE); } else result = ISC_R_CANCELED; @@ -2522,14 +2523,14 @@ zone_startload(dns_db_t *db, dns_zone_t *zone, isc_time_t loadtime) { zone_idetach(&callbacks.zone); return (result); } - result = dns_master_loadfile5(zone->masterfile, - &zone->origin, &zone->origin, - zone->rdclass, options, 0, - &callbacks, - zone_registerinclude, - zone, zone->mctx, - zone->masterformat, - zone->maxttl); + result = dns_master_loadfile(zone->masterfile, + &zone->origin, &zone->origin, + zone->rdclass, options, 0, + &callbacks, + zone_registerinclude, + zone, zone->mctx, + zone->masterformat, + zone->maxttl); tresult = dns_db_endload(db, &callbacks); if (result == ISC_R_SUCCESS) result = tresult; @@ -10446,9 +10447,9 @@ zone_dump(dns_zone_t *zone, isc_boolean_t compact) { output_style = &dns_master_style_keyzone; else output_style = &dns_master_style_default; - result = dns_master_dump3(zone->mctx, db, version, - output_style, masterfile, - masterformat, &rawdata); + result = dns_master_dump(zone->mctx, db, version, + output_style, masterfile, + masterformat, &rawdata); dns_db_closeversion(db, &version, ISC_FALSE); } fail: @@ -10513,8 +10514,8 @@ dumptostream(dns_zone_t *zone, FILE *fd, const dns_master_style_t *style, rawdata.flags = DNS_MASTERRAW_SOURCESERIALSET; rawdata.sourceserial = zone->sourceserial; } - result = dns_master_dumptostream3(zone->mctx, db, version, style, - format, &rawdata, fd); + result = dns_master_dumptostream(zone->mctx, db, version, style, + format, &rawdata, fd); dns_db_closeversion(db, &version, ISC_FALSE); dns_db_detach(&db); return (result); From 8c12e488f754c5d6a97a905a41b04213bde95e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 15:12:27 +0200 Subject: [PATCH 09/18] libdns refactoring: get rid of multiple versions of dns_request_createraw and dns_request_createvia --- bin/nsupdate/nsupdate.c | 44 ++++----- bin/tests/system/pipelined/pipequeries.c | 6 +- bin/tools/mdig.c | 12 +-- lib/dns/client.c | 104 ++++++++++---------- lib/dns/include/dns/request.h | 73 ++------------ lib/dns/request.c | 119 +++-------------------- lib/dns/win32/libdns.def.in | 6 -- lib/dns/zone.c | 44 ++++----- 8 files changed, 125 insertions(+), 283 deletions(-) diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 8d1176f6f1..5baf409313 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -2493,11 +2493,11 @@ send_update(dns_name_t *zone, isc_sockaddr_t *master) { if (updatemsg->tsigname) updatemsg->tsigname->attributes |= DNS_NAMEATTR_NOCOMPRESS; - result = dns_request_createvia3(requestmgr, updatemsg, srcaddr, - master, options, tsigkey, timeout, - udp_timeout, udp_retries, global_task, - update_completed, NULL, &request); - check_result(result, "dns_request_createvia3"); + result = dns_request_createvia(requestmgr, updatemsg, srcaddr, + master, -1, options, tsigkey, timeout, + udp_timeout, udp_retries, global_task, + update_completed, NULL, &request); + check_result(result, "dns_request_createvia"); if (debugging) show_message(stdout, updatemsg, "Outgoing update query:"); @@ -2602,13 +2602,13 @@ recvsoa(isc_task_t *task, isc_event_t *event) { else srcaddr = localaddr4; - result = dns_request_createvia3(requestmgr, soaquery, srcaddr, - addr, 0, NULL, - FIND_TIMEOUT * 20, - FIND_TIMEOUT, 3, - global_task, recvsoa, reqinfo, - &request); - check_result(result, "dns_request_createvia3"); + result = dns_request_createvia(requestmgr, soaquery, srcaddr, + addr, -1, 0, NULL, + FIND_TIMEOUT * 20, + FIND_TIMEOUT, 3, + global_task, recvsoa, reqinfo, + &request); + check_result(result, "dns_request_createvia"); requests++; return; } @@ -2805,11 +2805,11 @@ sendrequest(isc_sockaddr_t *destaddr, dns_message_t *msg, else srcaddr = localaddr4; - result = dns_request_createvia3(requestmgr, msg, srcaddr, destaddr, 0, - default_servers ? NULL : tsigkey, - FIND_TIMEOUT * 20, FIND_TIMEOUT, 3, - global_task, recvsoa, reqinfo, request); - check_result(result, "dns_request_createvia3"); + result = dns_request_createvia(requestmgr, msg, srcaddr, destaddr, -1, + 0, default_servers ? NULL : tsigkey, + FIND_TIMEOUT * 20, FIND_TIMEOUT, 3, + global_task, recvsoa, reqinfo, request); + check_result(result, "dns_request_createvia"); requests++; } @@ -3003,11 +3003,11 @@ send_gssrequest(isc_sockaddr_t *destaddr, dns_message_t *msg, else srcaddr = localaddr4; - result = dns_request_createvia3(requestmgr, msg, srcaddr, destaddr, - options, tsigkey, FIND_TIMEOUT * 20, - FIND_TIMEOUT, 3, global_task, recvgss, - reqinfo, request); - check_result(result, "dns_request_createvia3"); + result = dns_request_createvia(requestmgr, msg, srcaddr, destaddr, + -1, options, tsigkey, FIND_TIMEOUT * 20, + FIND_TIMEOUT, 3, global_task, recvgss, + reqinfo, request); + check_result(result, "dns_request_createvia"); if (debugging) show_message(stdout, msg, "Outgoing update query:"); requests++; diff --git a/bin/tests/system/pipelined/pipequeries.c b/bin/tests/system/pipelined/pipequeries.c index 93455861ef..c6801d32be 100644 --- a/bin/tests/system/pipelined/pipequeries.c +++ b/bin/tests/system/pipelined/pipequeries.c @@ -177,8 +177,10 @@ sendquery(isc_task_t *task) { request = NULL; result = dns_request_createvia(requestmgr, message, have_src ? &srcaddr : NULL, &dstaddr, - DNS_REQUESTOPT_TCP|DNS_REQUESTOPT_SHARE, - NULL, TIMEOUT, task, recvresponse, + -1, + DNS_REQUESTOPT_TCP | + DNS_REQUESTOPT_SHARE, + NULL, TIMEOUT, 0, 0, task, recvresponse, message, &request); CHECK("dns_request_create", result); diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index 492d0a844e..e615243ca9 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -684,12 +684,12 @@ sendquery(struct query *query, isc_task_t *task) if (tcp_mode) options |= DNS_REQUESTOPT_TCP | DNS_REQUESTOPT_SHARE; request = NULL; - result = dns_request_createvia4(requestmgr, message, - have_src ? &srcaddr : NULL, &dstaddr, - dscp, options, NULL, - query->timeout, query->udptimeout, - query->udpretries, task, - recvresponse, message, &request); + result = dns_request_createvia(requestmgr, message, + have_src ? &srcaddr : NULL, &dstaddr, + dscp, options, NULL, + query->timeout, query->udptimeout, + query->udpretries, task, + recvresponse, message, &request); CHECK("dns_request_createvia4", result); return ISC_R_SUCCESS; diff --git a/lib/dns/client.c b/lib/dns/client.c index 0d1cf47cbd..2d701e48f3 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -1785,11 +1785,11 @@ dns_client_startrequest(dns_client_t *client, dns_message_t *qmessage, UNLOCK(&client->lock); ctx->request = NULL; - result = dns_request_createvia3(view->requestmgr, qmessage, NULL, - server, reqoptions, ctx->tsigkey, - timeout, udptimeout, udpretries, - client->task, request_done, ctx, - &ctx->request); + result = dns_request_createvia(view->requestmgr, qmessage, NULL, + server, -1, reqoptions, ctx->tsigkey, + timeout, udptimeout, udpretries, + client->task, request_done, ctx, + &ctx->request); if (result == ISC_R_SUCCESS) { dns_view_detach(&view); *transp = (dns_clientreqtrans_t *)ctx; @@ -1992,18 +1992,19 @@ update_done(isc_task_t *task, isc_event_t *event) { reqoptions = 0; if (uctx->want_tcp) reqoptions |= DNS_REQUESTOPT_TCP; - result = dns_request_createvia3(uctx->view->requestmgr, - uctx->updatemsg, - NULL, - uctx->currentserver, - reqoptions, - uctx->tsigkey, - timeout, - client->update_udptimeout, - client->update_udpretries, - client->task, - update_done, uctx, - &uctx->updatereq); + result = dns_request_createvia(uctx->view->requestmgr, + uctx->updatemsg, + NULL, + uctx->currentserver, + -1, + reqoptions, + uctx->tsigkey, + timeout, + client->update_udptimeout, + client->update_udpretries, + client->task, + update_done, uctx, + &uctx->updatereq); UNLOCK(&uctx->lock); if (result == ISC_R_SUCCESS) { @@ -2053,14 +2054,14 @@ send_update(updatectx_t *uctx) { reqoptions = 0; if (uctx->want_tcp) reqoptions |= DNS_REQUESTOPT_TCP; - result = dns_request_createvia3(uctx->view->requestmgr, - uctx->updatemsg, - NULL, uctx->currentserver, - reqoptions, uctx->tsigkey, timeout, - client->update_udptimeout, - client->update_udpretries, - client->task, update_done, uctx, - &uctx->updatereq); + result = dns_request_createvia(uctx->view->requestmgr, + uctx->updatemsg, + NULL, uctx->currentserver, + -1, reqoptions, uctx->tsigkey, timeout, + client->update_udptimeout, + client->update_udpretries, + client->task, update_done, uctx, + &uctx->updatereq); if (result == ISC_R_SUCCESS && uctx->state == dns_clientupdatestate_prepare) { uctx->state = dns_clientupdatestate_sent; @@ -2311,14 +2312,14 @@ receive_soa(isc_task_t *task, isc_event_t *event) { reqoptions = 0; if (uctx->want_tcp) reqoptions |= DNS_REQUESTOPT_TCP; - result = dns_request_createvia3(uctx->view->requestmgr, - uctx->soaquery, NULL, addr, - reqoptions, NULL, - client->find_timeout * 20, - client->find_timeout, 3, - uctx->client->task, - receive_soa, uctx, - &newrequest); + result = dns_request_createvia(uctx->view->requestmgr, + uctx->soaquery, NULL, addr, -1, + reqoptions, NULL, + client->find_timeout * 20, + client->find_timeout, 3, + uctx->client->task, + receive_soa, uctx, + &newrequest); if (result == ISC_R_SUCCESS) { LOCK(&uctx->lock); dns_request_destroy(&uctx->soareq); @@ -2414,17 +2415,18 @@ receive_soa(isc_task_t *task, isc_event_t *event) { reqoptions = 0; if (uctx->want_tcp) reqoptions |= DNS_REQUESTOPT_TCP; - result = dns_request_createvia3(uctx->view->requestmgr, - soaquery, NULL, - uctx->currentserver, - reqoptions, - uctx->tsigkey, - client->find_timeout * - 20, - client->find_timeout, - 3, client->task, - receive_soa, uctx, - &uctx->soareq); + result = dns_request_createvia(uctx->view->requestmgr, + soaquery, NULL, + uctx->currentserver, + -1, + reqoptions, + uctx->tsigkey, + client->find_timeout * + 20, + client->find_timeout, + 3, client->task, + receive_soa, uctx, + &uctx->soareq); } } @@ -2474,13 +2476,13 @@ request_soa(updatectx_t *uctx) { if (uctx->want_tcp) reqoptions |= DNS_REQUESTOPT_TCP; - result = dns_request_createvia3(uctx->view->requestmgr, - soaquery, NULL, uctx->currentserver, - reqoptions, uctx->tsigkey, - uctx->client->find_timeout * 20, - uctx->client->find_timeout, 3, - uctx->client->task, receive_soa, uctx, - &uctx->soareq); + result = dns_request_createvia(uctx->view->requestmgr, + soaquery, NULL, uctx->currentserver, + -1, reqoptions, uctx->tsigkey, + uctx->client->find_timeout * 20, + uctx->client->find_timeout, 3, + uctx->client->task, receive_soa, uctx, + &uctx->soareq); if (result == ISC_R_SUCCESS) { uctx->soaquery = soaquery; return (ISC_R_SUCCESS); diff --git a/lib/dns/include/dns/request.h b/lib/dns/include/dns/request.h index da7c7a0bac..4dbebca75d 100644 --- a/lib/dns/include/dns/request.h +++ b/lib/dns/include/dns/request.h @@ -193,45 +193,15 @@ dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message, *\li requestp != NULL && *requestp == NULL */ -/*% See dns_request_createvia4() */ isc_result_t dns_request_createvia(dns_requestmgr_t *requestmgr, dns_message_t *message, const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, unsigned int options, + const isc_sockaddr_t *destaddr, + isc_dscp_t dscp, unsigned int options, dns_tsigkey_t *key, unsigned int timeout, + unsigned int udptimeout, unsigned int udpretries, isc_task_t *task, isc_taskaction_t action, void *arg, dns_request_t **requestp); - -/*% See dns_request_createvia4() */ -isc_result_t -dns_request_createvia2(dns_requestmgr_t *requestmgr, dns_message_t *message, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, - unsigned int options, dns_tsigkey_t *key, - unsigned int timeout, unsigned int udptimeout, - isc_task_t *task, isc_taskaction_t action, void *arg, - dns_request_t **requestp); - -/*% See dns_request_createvia4() */ -isc_result_t -dns_request_createvia3(dns_requestmgr_t *requestmgr, dns_message_t *message, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, - unsigned int options, dns_tsigkey_t *key, - unsigned int timeout, unsigned int udptimeout, - unsigned int udpretries, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_request_t **requestp); - -isc_result_t -dns_request_createvia4(dns_requestmgr_t *requestmgr, dns_message_t *message, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, - isc_dscp_t dscp, unsigned int options, - dns_tsigkey_t *key, unsigned int timeout, - unsigned int udptimeout, unsigned int udpretries, - isc_task_t *task, isc_taskaction_t action, void *arg, - dns_request_t **requestp); /*%< * Create and send a request. * @@ -267,44 +237,15 @@ dns_request_createvia4(dns_requestmgr_t *requestmgr, dns_message_t *message, *\li requestp != NULL && *requestp == NULL */ -/*% See dns_request_createraw4() */ isc_result_t dns_request_createraw(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf, const isc_sockaddr_t *srcaddr, const isc_sockaddr_t *destaddr, - unsigned int options, unsigned int timeout, - isc_task_t *task, isc_taskaction_t action, void *arg, + isc_dscp_t dscp, unsigned int options, + unsigned int timeout, unsigned int udptimeout, + unsigned int udpretries, isc_task_t *task, + isc_taskaction_t action, void *arg, dns_request_t **requestp); - -/*% See dns_request_createraw4() */ -isc_result_t -dns_request_createraw2(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, - unsigned int options, unsigned int timeout, - unsigned int udptimeout, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_request_t **requestp); - -/*% See dns_request_createraw4() */ -isc_result_t -dns_request_createraw3(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, - unsigned int options, unsigned int timeout, - unsigned int udptimeout, unsigned int udpretries, - isc_task_t *task, isc_taskaction_t action, void *arg, - dns_request_t **requestp); - -isc_result_t -dns_request_createraw4(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, - isc_dscp_t dscp, unsigned int options, - unsigned int timeout, unsigned int udptimeout, - unsigned int udpretries, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_request_t **requestp); /*!< * \brief Create and send a request. * diff --git a/lib/dns/request.c b/lib/dns/request.c index cfc20eb68a..82e5a80da2 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -692,59 +692,11 @@ isc_result_t dns_request_createraw(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf, const isc_sockaddr_t *srcaddr, const isc_sockaddr_t *destaddr, - unsigned int options, unsigned int timeout, - isc_task_t *task, isc_taskaction_t action, void *arg, + isc_dscp_t dscp, unsigned int options, + unsigned int timeout, unsigned int udptimeout, + unsigned int udpretries, isc_task_t *task, + isc_taskaction_t action, void *arg, dns_request_t **requestp) -{ - return(dns_request_createraw4(requestmgr, msgbuf, srcaddr, destaddr, - -1, options, timeout, 0, 0, task, action, - arg, requestp)); -} - -isc_result_t -dns_request_createraw2(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, - unsigned int options, unsigned int timeout, - unsigned int udptimeout, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_request_t **requestp) -{ - unsigned int udpretries = 0; - - if (udptimeout != 0) - udpretries = timeout / udptimeout; - - return (dns_request_createraw4(requestmgr, msgbuf, srcaddr, destaddr, - -1, options, timeout, udptimeout, - udpretries, task, action, arg, - requestp)); -} - -isc_result_t -dns_request_createraw3(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, - unsigned int options, unsigned int timeout, - unsigned int udptimeout, unsigned int udpretries, - isc_task_t *task, isc_taskaction_t action, void *arg, - dns_request_t **requestp) -{ - return (dns_request_createraw4(requestmgr, msgbuf, srcaddr, destaddr, - -1, options, timeout, udptimeout, - udpretries, task, action, arg, - requestp)); -} - -isc_result_t -dns_request_createraw4(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, - isc_dscp_t dscp, unsigned int options, - unsigned int timeout, unsigned int udptimeout, - unsigned int udpretries, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_request_t **requestp) { dns_request_t *request = NULL; isc_task_t *tclone = NULL; @@ -921,69 +873,20 @@ dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message, isc_taskaction_t action, void *arg, dns_request_t **requestp) { - return (dns_request_createvia4(requestmgr, message, NULL, address, - -1, options, key, timeout, 0, 0, task, - action, arg, requestp)); + return (dns_request_createvia(requestmgr, message, NULL, address, + -1, options, key, timeout, 0, 0, task, + action, arg, requestp)); } isc_result_t dns_request_createvia(dns_requestmgr_t *requestmgr, dns_message_t *message, const isc_sockaddr_t *srcaddr, const isc_sockaddr_t *destaddr, - unsigned int options, dns_tsigkey_t *key, - unsigned int timeout, isc_task_t *task, - isc_taskaction_t action, void *arg, + isc_dscp_t dscp, unsigned int options, + dns_tsigkey_t *key, unsigned int timeout, + unsigned int udptimeout, unsigned int udpretries, + isc_task_t *task, isc_taskaction_t action, void *arg, dns_request_t **requestp) -{ - return(dns_request_createvia4(requestmgr, message, srcaddr, destaddr, - -1, options, key, timeout, 0, 0, task, - action, arg, requestp)); -} - -isc_result_t -dns_request_createvia2(dns_requestmgr_t *requestmgr, dns_message_t *message, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, - unsigned int options, dns_tsigkey_t *key, - unsigned int timeout, unsigned int udptimeout, - isc_task_t *task, isc_taskaction_t action, void *arg, - dns_request_t **requestp) -{ - unsigned int udpretries = 0; - - if (udptimeout != 0) - udpretries = timeout / udptimeout; - return (dns_request_createvia4(requestmgr, message, srcaddr, destaddr, - -1, options, key, timeout, udptimeout, - udpretries, task, action, arg, - requestp)); -} - -isc_result_t -dns_request_createvia3(dns_requestmgr_t *requestmgr, dns_message_t *message, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, - unsigned int options, dns_tsigkey_t *key, - unsigned int timeout, unsigned int udptimeout, - unsigned int udpretries, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_request_t **requestp) -{ - return (dns_request_createvia4(requestmgr, message, srcaddr, destaddr, - -1, options, key, timeout, udptimeout, - udpretries, task, action, arg, - requestp)); -} - -isc_result_t -dns_request_createvia4(dns_requestmgr_t *requestmgr, dns_message_t *message, - const isc_sockaddr_t *srcaddr, - const isc_sockaddr_t *destaddr, - isc_dscp_t dscp, unsigned int options, - dns_tsigkey_t *key, unsigned int timeout, - unsigned int udptimeout, unsigned int udpretries, - isc_task_t *task, isc_taskaction_t action, void *arg, - dns_request_t **requestp) { dns_request_t *request = NULL; isc_task_t *tclone = NULL; diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index cb5c7c5202..c8d0037f7a 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -851,13 +851,7 @@ dns_rdatatypestats_increment dns_request_cancel dns_request_create dns_request_createraw -dns_request_createraw2 -dns_request_createraw3 -dns_request_createraw4 dns_request_createvia -dns_request_createvia2 -dns_request_createvia3 -dns_request_createvia4 dns_request_destroy dns_request_getresponse dns_request_usedtcp diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 6fe852f3c8..ddd63ff4a8 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -11015,11 +11015,11 @@ notify_send_toaddr(isc_task_t *task, isc_event_t *event) { timeout = 15; if (DNS_ZONE_FLAG(notify->zone, DNS_ZONEFLG_DIALNOTIFY)) timeout = 30; - result = dns_request_createvia4(notify->zone->view->requestmgr, - message, &src, ¬ify->dst, dscp, - options, key, timeout * 3, timeout, - 0, notify->zone->task, notify_done, - notify, ¬ify->request); + result = dns_request_createvia(notify->zone->view->requestmgr, + message, &src, ¬ify->dst, dscp, + options, key, timeout * 3, timeout, + 0, notify->zone->task, notify_done, + notify, ¬ify->request); if (result == ISC_R_SUCCESS) { if (isc_sockaddr_pf(¬ify->dst) == AF_INET) { inc_stats(notify->zone, @@ -12422,11 +12422,11 @@ soa_query(isc_task_t *task, isc_event_t *event) { timeout = 15; if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DIALREFRESH)) timeout = 30; - result = dns_request_createvia4(zone->view->requestmgr, message, - &zone->sourceaddr, &zone->masteraddr, - dscp, options, key, timeout * 3, - timeout, 0, zone->task, - refresh_callback, zone, &zone->request); + result = dns_request_createvia(zone->view->requestmgr, message, + &zone->sourceaddr, &zone->masteraddr, + dscp, options, key, timeout * 3, + timeout, 0, zone->task, + refresh_callback, zone, &zone->request); if (result != ISC_R_SUCCESS) { zone_idetach(&dummy); zone_debuglog(zone, me, 1, @@ -12668,11 +12668,11 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) { timeout = 15; if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DIALREFRESH)) timeout = 30; - result = dns_request_createvia4(zone->view->requestmgr, message, - &zone->sourceaddr, &zone->masteraddr, - dscp, DNS_REQUESTOPT_TCP, key, - timeout * 3, timeout, 0, zone->task, - stub_callback, stub, &zone->request); + result = dns_request_createvia(zone->view->requestmgr, message, + &zone->sourceaddr, &zone->masteraddr, + dscp, DNS_REQUESTOPT_TCP, key, + timeout * 3, timeout, 0, zone->task, + stub_callback, stub, &zone->request); if (result != ISC_R_SUCCESS) { zone_debuglog(zone, me, 1, "dns_request_createvia() failed: %s", @@ -15708,13 +15708,13 @@ sendtomaster(dns_forward_t *forward) { result = ISC_R_NOTIMPLEMENTED; goto unlock; } - result = dns_request_createraw4(forward->zone->view->requestmgr, - forward->msgbuf, - &src, &forward->addr, dscp, - forward->options, 15 /* XXX */, - 0, 0, forward->zone->task, - forward_callback, forward, - &forward->request); + result = dns_request_createraw(forward->zone->view->requestmgr, + forward->msgbuf, + &src, &forward->addr, dscp, + forward->options, 15 /* XXX */, + 0, 0, forward->zone->task, + forward_callback, forward, + &forward->request); if (result == ISC_R_SUCCESS) { if (!ISC_LINK_LINKED(forward, link)) ISC_LIST_APPEND(forward->zone->forwards, forward, link); From 25cd3168a7aa82829e96ea710b57403d7257bfb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 15:24:33 +0200 Subject: [PATCH 10/18] libdns refactoring: get rid of multiple versions of dns_dnssec_findmatchingkeys and dns_dnssec_findzonekeys --- bin/dnssec/dnssec-cds.c | 7 ++- bin/dnssec/dnssec-signzone.c | 11 +++-- bin/dnssec/dnssectool.c | 9 ++-- lib/dns/dnssec.c | 89 ++++++------------------------------ lib/dns/include/dns/dnssec.h | 45 ++++-------------- lib/dns/update.c | 7 ++- lib/dns/validator.c | 14 +++--- lib/dns/win32/libdns.def.in | 5 -- lib/dns/zone.c | 32 +++++++------ lib/ns/query.c | 6 +-- 10 files changed, 73 insertions(+), 152 deletions(-) diff --git a/bin/dnssec/dnssec-cds.c b/bin/dnssec/dnssec-cds.c index b9e44be02c..c7ab16ace0 100644 --- a/bin/dnssec/dnssec-cds.c +++ b/bin/dnssec/dnssec-cds.c @@ -671,8 +671,11 @@ matching_sigs(keyinfo_t *keytbl, dns_rdataset_t *rdataset, } result = dns_dnssec_verify(name, rdataset, ki->dst, - ISC_FALSE, mctx, &sigrdata); - if (result != ISC_R_SUCCESS) { + ISC_FALSE, 0, mctx, + &sigrdata, NULL); + + if (result != ISC_R_SUCCESS && + result != DNS_R_FROMWILDCARD) { vbprintf(1, "skip RRSIG by key %d:" " verification failed: %s\n", sig.keyid, isc_result_totext(result)); diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index ee0be4f9f2..7e504c2bcd 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -295,8 +295,8 @@ signwithkey(dns_name_t *name, dns_rdataset_t *rdataset, dst_key_t *key, if (tryverify) { result = dns_dnssec_verify(name, rdataset, key, - ISC_TRUE, mctx, &trdata); - if (result == ISC_R_SUCCESS) { + ISC_TRUE, 0, mctx, &trdata, NULL); + if (result == ISC_R_SUCCESS || result == DNS_R_FROMWILDCARD) { vbprintf(3, "\tsignature verified\n"); INCSTAT(nverified); } else { @@ -456,8 +456,9 @@ setverifies(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, dns_rdata_t *rrsig) { isc_result_t result; - result = dns_dnssec_verify(name, set, key, ISC_FALSE, mctx, rrsig); - if (result == ISC_R_SUCCESS) { + result = dns_dnssec_verify(name, set, key, ISC_FALSE, 0, mctx, rrsig, + NULL); + if (result == ISC_R_SUCCESS || result == DNS_R_FROMWILDCARD) { INCSTAT(nverified); return (ISC_TRUE); } else { @@ -2636,7 +2637,7 @@ build_final_keylist(void) { * Find keys that match this zone in the key repository. */ result = dns_dnssec_findmatchingkeys(gorigin, directory, - mctx, &matchkeys); + now, mctx, &matchkeys); if (result == ISC_R_NOTFOUND) { result = ISC_R_SUCCESS; } diff --git a/bin/dnssec/dnssectool.c b/bin/dnssec/dnssectool.c index d7c3ccabb0..2a7f0d00c7 100644 --- a/bin/dnssec/dnssectool.c +++ b/bin/dnssec/dnssectool.c @@ -506,6 +506,7 @@ key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir, dns_secalg_t alg; char filename[ISC_DIR_NAMEMAX]; isc_buffer_t fileb; + isc_stdtime_t now; if (exact != NULL) *exact = ISC_FALSE; @@ -529,7 +530,8 @@ key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir, } ISC_LIST_INIT(matchkeys); - result = dns_dnssec_findmatchingkeys(name, dir, mctx, &matchkeys); + isc_stdtime_get(&now); + result = dns_dnssec_findmatchingkeys(name, dir, now, mctx, &matchkeys); if (result == ISC_R_NOTFOUND) return (ISC_FALSE); @@ -624,10 +626,11 @@ goodsig(dns_name_t *origin, dns_rdata_t *sigrdata, dns_name_t *name, continue; } result = dns_dnssec_verify(name, rdataset, dstkey, ISC_FALSE, - mctx, sigrdata); + 0, mctx, sigrdata, NULL); dst_key_free(&dstkey); - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS || result == DNS_R_FROMWILDCARD) { return(ISC_TRUE); + } } return (ISC_FALSE); } diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index d07057031e..dd1e75bdef 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -363,18 +363,9 @@ cleanup_signature: } isc_result_t -dns_dnssec_verify2(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, - isc_boolean_t ignoretime, isc_mem_t *mctx, - dns_rdata_t *sigrdata, dns_name_t *wild) -{ - return (dns_dnssec_verify3(name, set, key, ignoretime, 0, mctx, - sigrdata, wild)); -} - -isc_result_t -dns_dnssec_verify3(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, - isc_boolean_t ignoretime, unsigned int maxbits, - isc_mem_t *mctx, dns_rdata_t *sigrdata, dns_name_t *wild) +dns_dnssec_verify(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, + isc_boolean_t ignoretime, unsigned int maxbits, + isc_mem_t *mctx, dns_rdata_t *sigrdata, dns_name_t *wild) { dns_rdata_rrsig_t sig; dns_fixedname_t fnewname; @@ -590,20 +581,6 @@ cleanup_struct: return (ret); } -isc_result_t -dns_dnssec_verify(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, - isc_boolean_t ignoretime, isc_mem_t *mctx, - dns_rdata_t *sigrdata) -{ - isc_result_t result; - - result = dns_dnssec_verify2(name, set, key, ignoretime, mctx, - sigrdata, NULL); - if (result == DNS_R_FROMWILDCARD) - result = ISC_R_SUCCESS; - return (result); -} - isc_boolean_t dns_dnssec_keyactive(dst_key_t *key, isc_stdtime_t now) { isc_result_t result; @@ -730,11 +707,11 @@ syncdelete(dst_key_t *key, isc_stdtime_t now) { == DNS_KEYOWNER_ZONE) isc_result_t -dns_dnssec_findzonekeys3(dns_db_t *db, dns_dbversion_t *ver, - dns_dbnode_t *node, const dns_name_t *name, - const char *directory, isc_stdtime_t now, - isc_mem_t *mctx, unsigned int maxkeys, - dst_key_t **keys, unsigned int *nkeys) +dns_dnssec_findzonekeys(dns_db_t *db, dns_dbversion_t *ver, + dns_dbnode_t *node, const dns_name_t *name, + const char *directory, isc_stdtime_t now, + isc_mem_t *mctx, unsigned int maxkeys, + dst_key_t **keys, unsigned int *nkeys) { dns_rdataset_t rdataset; dns_rdata_t rdata = DNS_RDATA_INIT; @@ -890,33 +867,6 @@ dns_dnssec_findzonekeys3(dns_db_t *db, dns_dbversion_t *ver, return (result); } -isc_result_t -dns_dnssec_findzonekeys2(dns_db_t *db, dns_dbversion_t *ver, - dns_dbnode_t *node, const dns_name_t *name, - const char *directory, isc_mem_t *mctx, - unsigned int maxkeys, dst_key_t **keys, - unsigned int *nkeys) -{ - isc_stdtime_t now; - - isc_stdtime_get(&now); - return (dns_dnssec_findzonekeys3(db, ver, node, name, directory, now, - mctx, maxkeys, keys, nkeys)); -} - -isc_result_t -dns_dnssec_findzonekeys(dns_db_t *db, dns_dbversion_t *ver, - dns_dbnode_t *node, const dns_name_t *name, - isc_mem_t *mctx, unsigned int maxkeys, - dst_key_t **keys, unsigned int *nkeys) -{ - isc_stdtime_t now; - - isc_stdtime_get(&now); - return (dns_dnssec_findzonekeys3(db, ver, node, name, NULL, now, - mctx, maxkeys, keys, nkeys)); -} - isc_result_t dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) { dns_rdata_sig_t sig; /* SIG(0) */ @@ -1243,9 +1193,9 @@ dns_dnssec_signs(dns_rdata_t *rdata, const dns_name_t *name, if (sig.algorithm == key.algorithm && sig.keyid == keytag) { - result = dns_dnssec_verify2(name, rdataset, dstkey, - ignoretime, mctx, - &sigrdata, NULL); + result = dns_dnssec_verify(name, rdataset, dstkey, + ignoretime, 0, mctx, + &sigrdata, NULL); if (result == ISC_R_SUCCESS) { dst_key_free(&dstkey); return (ISC_TRUE); @@ -1406,9 +1356,9 @@ get_hints(dns_dnsseckey_t *key, isc_stdtime_t now) { * Get a list of DNSSEC keys from the key repository */ isc_result_t -dns_dnssec_findmatchingkeys2(const dns_name_t *origin, const char *directory, - isc_stdtime_t now, isc_mem_t *mctx, - dns_dnsseckeylist_t *keylist) +dns_dnssec_findmatchingkeys(const dns_name_t *origin, const char *directory, + isc_stdtime_t now, isc_mem_t *mctx, + dns_dnsseckeylist_t *keylist) { isc_result_t result = ISC_R_SUCCESS; isc_boolean_t dir_open = ISC_FALSE; @@ -1536,17 +1486,6 @@ dns_dnssec_findmatchingkeys2(const dns_name_t *origin, const char *directory, return (result); } -isc_result_t -dns_dnssec_findmatchingkeys(const dns_name_t *origin, const char *directory, - isc_mem_t *mctx, dns_dnsseckeylist_t *keylist) -{ - isc_stdtime_t now; - - isc_stdtime_get(&now); - return (dns_dnssec_findmatchingkeys2(origin, directory, now, mctx, - keylist)); -} - /*% * Add 'newkey' to 'keylist' if it's not already there. * diff --git a/lib/dns/include/dns/dnssec.h b/lib/dns/include/dns/dnssec.h index b3c59c384e..a6f54c9b61 100644 --- a/lib/dns/include/dns/dnssec.h +++ b/lib/dns/include/dns/dnssec.h @@ -119,18 +119,8 @@ dns_dnssec_sign(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, isc_result_t dns_dnssec_verify(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, - isc_boolean_t ignoretime, isc_mem_t *mctx, - dns_rdata_t *sigrdata); - -isc_result_t -dns_dnssec_verify2(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, - isc_boolean_t ignoretime, isc_mem_t *mctx, - dns_rdata_t *sigrdata, dns_name_t *wild); - -isc_result_t -dns_dnssec_verify3(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, - isc_boolean_t ignoretime, unsigned int maxbits, - isc_mem_t *mctx, dns_rdata_t *sigrdata, dns_name_t *wild); + isc_boolean_t ignoretime, unsigned int maxbits, + isc_mem_t *mctx, dns_rdata_t *sigrdata, dns_name_t *wild); /*%< * Verifies the RRSIG record covering this rdataset signed by a specific * key. This does not determine if the key's owner is authorized to sign @@ -164,24 +154,11 @@ dns_dnssec_verify3(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, /*@{*/ isc_result_t -dns_dnssec_findzonekeys(dns_db_t *db, dns_dbversion_t *ver, dns_dbnode_t *node, - const dns_name_t *name, isc_mem_t *mctx, - unsigned int maxkeys, dst_key_t **keys, - unsigned int *nkeys); - -isc_result_t -dns_dnssec_findzonekeys2(dns_db_t *db, dns_dbversion_t *ver, - dns_dbnode_t *node, const dns_name_t *name, - const char *directory, isc_mem_t *mctx, - unsigned int maxkeys, dst_key_t **keys, - unsigned int *nkeys); - -isc_result_t -dns_dnssec_findzonekeys3(dns_db_t *db, dns_dbversion_t *ver, - dns_dbnode_t *node, const dns_name_t *name, - const char *directory, isc_stdtime_t now, - isc_mem_t *mctx, unsigned int maxkeys, - dst_key_t **keys, unsigned int *nkeys); +dns_dnssec_findzonekeys(dns_db_t *db, dns_dbversion_t *ver, + dns_dbnode_t *node, const dns_name_t *name, + const char *directory, isc_stdtime_t now, + isc_mem_t *mctx, unsigned int maxkeys, + dst_key_t **keys, unsigned int *nkeys); /*%< * Finds a set of zone keys. @@ -291,12 +268,8 @@ dns_dnsseckey_destroy(isc_mem_t *mctx, dns_dnsseckey_t **dkp); isc_result_t dns_dnssec_findmatchingkeys(const dns_name_t *origin, const char *directory, - isc_mem_t *mctx, dns_dnsseckeylist_t *keylist); - -isc_result_t -dns_dnssec_findmatchingkeys2(const dns_name_t *origin, const char *directory, - isc_stdtime_t now, isc_mem_t *mctx, - dns_dnsseckeylist_t *keylist); + isc_stdtime_t now, isc_mem_t *mctx, + dns_dnsseckeylist_t *keylist); /*%< * Search 'directory' for K* key files matching the name in 'origin'. * Append all such keys, along with use hints gleaned from their diff --git a/lib/dns/update.c b/lib/dns/update.c index c7e7be0db8..5cfa0434e6 100644 --- a/lib/dns/update.c +++ b/lib/dns/update.c @@ -1051,11 +1051,14 @@ find_zone_keys(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, dst_key_t **keys, unsigned int *nkeys) { isc_result_t result; + isc_stdtime_t now; dns_dbnode_t *node = NULL; const char *directory = dns_zone_getkeydirectory(zone); CHECK(dns_db_findnode(db, dns_db_origin(db), ISC_FALSE, &node)); - CHECK(dns_dnssec_findzonekeys2(db, ver, node, dns_db_origin(db), - directory, mctx, maxkeys, keys, nkeys)); + isc_stdtime_get(&now); + CHECK(dns_dnssec_findzonekeys(db, ver, node, dns_db_origin(db), + directory, now, mctx, maxkeys, keys, + nkeys)); failure: if (node != NULL) dns_db_detachnode(db, &node); diff --git a/lib/dns/validator.c b/lib/dns/validator.c index e898576d38..c6c0e20adc 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -1470,10 +1470,10 @@ isselfsigned(dns_validator_t *val) { if (result != ISC_R_SUCCESS) continue; - result = dns_dnssec_verify3(name, rdataset, dstkey, - ISC_TRUE, - val->view->maxbits, - mctx, &sigrdata, NULL); + result = dns_dnssec_verify(name, rdataset, dstkey, + ISC_TRUE, + val->view->maxbits, + mctx, &sigrdata, NULL); dst_key_free(&dstkey); if (result != ISC_R_SUCCESS) continue; @@ -1509,9 +1509,9 @@ verify(dns_validator_t *val, dst_key_t *key, dns_rdata_t *rdata, dns_fixedname_init(&fixed); wild = dns_fixedname_name(&fixed); again: - result = dns_dnssec_verify3(val->event->name, val->event->rdataset, - key, ignore, val->view->maxbits, - val->view->mctx, rdata, wild); + result = dns_dnssec_verify(val->event->name, val->event->rdataset, + key, ignore, val->view->maxbits, + val->view->mctx, rdata, wild); if ((result == DNS_R_SIGEXPIRED || result == DNS_R_SIGFUTURE) && val->view->acceptexpired) { diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index c8d0037f7a..1e4aa54b71 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -316,10 +316,7 @@ dns_dns64_destroy dns_dns64_next dns_dns64_unlink dns_dnssec_findmatchingkeys -dns_dnssec_findmatchingkeys2 dns_dnssec_findzonekeys -dns_dnssec_findzonekeys2 -dns_dnssec_findzonekeys3 dns_dnssec_keyactive dns_dnssec_keyfromrdata dns_dnssec_keylistfromrdataset @@ -331,8 +328,6 @@ dns_dnssec_syncupdate dns_dnssec_syncupdate dns_dnssec_updatekeys dns_dnssec_verify -dns_dnssec_verify2 -dns_dnssec_verify3 dns_dnssec_verifymessage dns_dnsseckey_create dns_dnsseckey_destroy diff --git a/lib/dns/zone.c b/lib/dns/zone.c index ddd63ff4a8..0642c932ba 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -6043,9 +6043,9 @@ find_zone_keys(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, CHECK(dns_db_findnode(db, dns_db_origin(db), ISC_FALSE, &node)); memset(keys, 0, sizeof(*keys) * maxkeys); - result = dns_dnssec_findzonekeys3(db, ver, node, dns_db_origin(db), - directory, now, mctx, maxkeys, keys, - nkeys); + result = dns_dnssec_findzonekeys(db, ver, node, dns_db_origin(db), + directory, now, mctx, maxkeys, keys, + nkeys); if (result == ISC_R_NOTFOUND) result = ISC_R_SUCCESS; failure: @@ -9036,10 +9036,11 @@ revocable(dns_keyfetch_t *kfetch, dns_rdata_keydata_t *keydata) { if (dst_key_alg(dstkey) == sig.algorithm && dst_key_rid(dstkey) == sig.keyid) { - result = dns_dnssec_verify2(keyname, - &kfetch->dnskeyset, - dstkey, ISC_FALSE, mctx, &sigrr, - dns_fixedname_name(&fixed)); + result = dns_dnssec_verify(keyname, + &kfetch->dnskeyset, + dstkey, ISC_FALSE, 0, mctx, + &sigrr, + dns_fixedname_name(&fixed)); dns_zone_log(kfetch->zone, ISC_LOG_DEBUG(3), "Confirm revoked DNSKEY is self-signed: " @@ -9186,11 +9187,14 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { if (dst_key_alg(dstkey) == sig.algorithm && dst_key_id(dstkey) == sig.keyid) { - result = dns_dnssec_verify2(keyname, - &kfetch->dnskeyset, - dstkey, ISC_FALSE, - zone->view->mctx, &sigrr, - dns_fixedname_name(&fixed)); + result = dns_dnssec_verify(keyname, + &kfetch->dnskeyset, + dstkey, ISC_FALSE, + 0, + zone->view->mctx, + &sigrr, + dns_fixedname_name( + &fixed)); dns_zone_log(zone, ISC_LOG_DEBUG(3), "Verifying DNSKEY set for zone " @@ -17860,8 +17864,8 @@ zone_rekey(dns_zone_t *zone) { */ fullsign = ISC_TF(DNS_ZONEKEY_OPTION(zone, DNS_ZONEKEY_FULLSIGN) != 0); - result = dns_dnssec_findmatchingkeys2(&zone->origin, dir, now, mctx, - &keys); + result = dns_dnssec_findmatchingkeys(&zone->origin, dir, now, mctx, + &keys); if (result == ISC_R_SUCCESS) { isc_boolean_t check_ksk; check_ksk = DNS_ZONE_OPTION(zone, DNS_ZONEOPT_UPDATECHECKKSK); diff --git a/lib/ns/query.c b/lib/ns/query.c index 7cea53515d..990323aeea 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -2280,9 +2280,9 @@ verify(dst_key_t *key, dns_name_t *name, dns_rdataset_t *rdataset, dns_fixedname_init(&fixed); again: - result = dns_dnssec_verify3(name, rdataset, key, ignore, - client->view->maxbits, client->mctx, - rdata, NULL); + result = dns_dnssec_verify(name, rdataset, key, ignore, + client->view->maxbits, client->mctx, + rdata, NULL); if (result == DNS_R_SIGEXPIRED && client->view->acceptexpired) { ignore = ISC_TRUE; goto again; From 42ee8c853ac5690a23cd968c257eaf165086f10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 16:05:11 +0200 Subject: [PATCH 11/18] libdns refactoring: get rid of 3 versions of dns_resolver_createfetch --- bin/named/server.c | 6 ++-- lib/dns/adb.c | 12 ++++---- lib/dns/client.c | 3 +- lib/dns/include/dns/resolver.h | 28 ++---------------- lib/dns/lookup.c | 3 +- lib/dns/nta.c | 4 +-- lib/dns/resolver.c | 52 ++++++---------------------------- lib/dns/validator.c | 4 +-- lib/dns/win32/libdns.def.in | 2 -- lib/dns/zone.c | 8 +++--- lib/ns/query.c | 40 +++++++++++++------------- 11 files changed, 53 insertions(+), 109 deletions(-) diff --git a/bin/named/server.c b/bin/named/server.c index 7240d5f8c0..7b7286ce95 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -6565,9 +6565,9 @@ dotat(dns_keytable_t *keytable, dns_keynode_t *keynode, void *arg) { result = dns_resolver_createfetch(view->resolver, tatname, dns_rdatatype_null, NULL, NULL, - NULL, 0, tat->task, tat_done, tat, - &tat->rdataset, &tat->sigrdataset, - &tat->fetch); + NULL, NULL, 0, 0, 0, NULL, tat->task, + tat_done, tat, &tat->rdataset, + &tat->sigrdataset, &tat->fetch); if (result != ISC_R_SUCCESS) { isc_task_detach(&tat->task); diff --git a/lib/dns/adb.c b/lib/dns/adb.c index c052fa11ba..3c38d97a65 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -4043,12 +4043,12 @@ fetch_name(dns_adbname_t *adbname, isc_boolean_t start_at_zone, } fetch->depth = depth; - result = dns_resolver_createfetch3(adb->view->resolver, &adbname->name, - type, name, nameservers, NULL, - NULL, 0, options, depth, qc, - adb->task, fetch_callback, adbname, - &fetch->rdataset, NULL, - &fetch->fetch); + result = dns_resolver_createfetch(adb->view->resolver, &adbname->name, + type, name, nameservers, NULL, + NULL, 0, options, depth, qc, + adb->task, fetch_callback, adbname, + &fetch->rdataset, NULL, + &fetch->fetch); if (result != ISC_R_SUCCESS) goto cleanup; diff --git a/lib/dns/client.c b/lib/dns/client.c index 2d701e48f3..1535562ee6 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -773,7 +773,8 @@ start_fetch(resctx_t *rctx) { result = dns_resolver_createfetch(rctx->view->resolver, dns_fixedname_name(&rctx->name), rctx->type, - NULL, NULL, NULL, fopts, + NULL, NULL, NULL, NULL, 0, + fopts, 0, NULL, rctx->task, fetch_done, rctx, rctx->rdataset, rctx->sigrdataset, diff --git a/lib/dns/include/dns/resolver.h b/lib/dns/include/dns/resolver.h index d553021560..17418424ec 100644 --- a/lib/dns/include/dns/resolver.h +++ b/lib/dns/include/dns/resolver.h @@ -267,35 +267,13 @@ dns_resolver_createfetch(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type, const dns_name_t *domain, dns_rdataset_t *nameservers, dns_forwarders_t *forwarders, - unsigned int options, isc_task_t *task, + const isc_sockaddr_t *client, isc_uint16_t id, + unsigned int options, unsigned int depth, + isc_counter_t *qc, isc_task_t *task, isc_taskaction_t action, void *arg, dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset, dns_fetch_t **fetchp); - -isc_result_t -dns_resolver_createfetch2(dns_resolver_t *res, const dns_name_t *name, - dns_rdatatype_t type, - const dns_name_t *domain, dns_rdataset_t *nameservers, - dns_forwarders_t *forwarders, - const isc_sockaddr_t *client, isc_uint16_t id, - unsigned int options, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_rdataset_t *rdataset, - dns_rdataset_t *sigrdataset, - dns_fetch_t **fetchp); -isc_result_t -dns_resolver_createfetch3(dns_resolver_t *res, const dns_name_t *name, - dns_rdatatype_t type, - const dns_name_t *domain, dns_rdataset_t *nameservers, - dns_forwarders_t *forwarders, - const isc_sockaddr_t *client, isc_uint16_t id, - unsigned int options, unsigned int depth, - isc_counter_t *qc, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_rdataset_t *rdataset, - dns_rdataset_t *sigrdataset, - dns_fetch_t **fetchp); /*%< * Recurse to answer a question. * diff --git a/lib/dns/lookup.c b/lib/dns/lookup.c index 889c802eec..152ece260b 100644 --- a/lib/dns/lookup.c +++ b/lib/dns/lookup.c @@ -85,7 +85,8 @@ start_fetch(dns_lookup_t *lookup) { result = dns_resolver_createfetch(lookup->view->resolver, dns_fixedname_name(&lookup->name), lookup->type, - NULL, NULL, NULL, 0, + NULL, NULL, NULL, NULL, 0, 0, 0, + NULL, lookup->task, fetch_done, lookup, &lookup->rdataset, &lookup->sigrdataset, diff --git a/lib/dns/nta.c b/lib/dns/nta.c index 7f2acfeaf4..383dc04c5e 100644 --- a/lib/dns/nta.c +++ b/lib/dns/nta.c @@ -268,8 +268,8 @@ checkbogus(isc_task_t *task, isc_event_t *event) { nta_ref(nta); result = dns_resolver_createfetch(view->resolver, nta->name, dns_rdatatype_nsec, - NULL, NULL, NULL, - DNS_FETCHOPT_NONTA, + NULL, NULL, NULL, NULL, 0, + DNS_FETCHOPT_NONTA, 0, NULL, task, fetch_done, nta, &nta->rdataset, &nta->sigrdataset, diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index e6352458f1..b38cff76ef 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -6855,8 +6855,8 @@ resume_dslookup(isc_task_t *task, isc_event_t *event) { result = dns_resolver_createfetch(fctx->res, &fctx->nsname, dns_rdatatype_ns, domain, - nsrdataset, NULL, - fctx->options, task, + nsrdataset, NULL, NULL, 0, + fctx->options, 0, NULL, task, resume_dslookup, fctx, &fctx->nsrrset, NULL, &fctx->nsfetch); @@ -9117,8 +9117,8 @@ rctx_chaseds(respctx_t *rctx, dns_adbaddrinfo_t *addrinfo, isc_result_t result) result = dns_resolver_createfetch(fctx->res, &fctx->nsname, dns_rdatatype_ns, - NULL, NULL, NULL, - fctx->options, rctx->task, + NULL, NULL, NULL, NULL, 0, + fctx->options, 0, NULL, rctx->task, resume_dslookup, fctx, &fctx->nsrrset, NULL, &fctx->nsfetch); @@ -9982,7 +9982,8 @@ dns_resolver_prime(dns_resolver_t *res) { LOCK(&res->primelock); result = dns_resolver_createfetch(res, dns_rootname, dns_rdatatype_ns, - NULL, NULL, NULL, 0, + NULL, NULL, NULL, NULL, 0, 0, + 0, NULL, res->buckets[0].task, prime_done, res, rdataset, NULL, @@ -10176,48 +10177,13 @@ dns_resolver_createfetch(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type, const dns_name_t *domain, dns_rdataset_t *nameservers, dns_forwarders_t *forwarders, - unsigned int options, isc_task_t *task, + const isc_sockaddr_t *client, dns_messageid_t id, + unsigned int options, unsigned int depth, + isc_counter_t *qc, isc_task_t *task, isc_taskaction_t action, void *arg, dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset, dns_fetch_t **fetchp) -{ - return (dns_resolver_createfetch3(res, name, type, domain, - nameservers, forwarders, NULL, 0, - options, 0, NULL, task, action, arg, - rdataset, sigrdataset, fetchp)); -} - -isc_result_t -dns_resolver_createfetch2(dns_resolver_t *res, const dns_name_t *name, - dns_rdatatype_t type, - const dns_name_t *domain, dns_rdataset_t *nameservers, - dns_forwarders_t *forwarders, - const isc_sockaddr_t *client, dns_messageid_t id, - unsigned int options, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_rdataset_t *rdataset, - dns_rdataset_t *sigrdataset, - dns_fetch_t **fetchp) -{ - return (dns_resolver_createfetch3(res, name, type, domain, - nameservers, forwarders, client, id, - options, 0, NULL, task, action, arg, - rdataset, sigrdataset, fetchp)); -} - -isc_result_t -dns_resolver_createfetch3(dns_resolver_t *res, const dns_name_t *name, - dns_rdatatype_t type, - const dns_name_t *domain, dns_rdataset_t *nameservers, - dns_forwarders_t *forwarders, - const isc_sockaddr_t *client, dns_messageid_t id, - unsigned int options, unsigned int depth, - isc_counter_t *qc, isc_task_t *task, - isc_taskaction_t action, void *arg, - dns_rdataset_t *rdataset, - dns_rdataset_t *sigrdataset, - dns_fetch_t **fetchp) { dns_fetch_t *fetch; fetchctx_t *fctx = NULL; diff --git a/lib/dns/validator.c b/lib/dns/validator.c index c6c0e20adc..f551a11c6b 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -1153,8 +1153,8 @@ create_fetch(dns_validator_t *val, dns_name_t *name, dns_rdatatype_t type, validator_logcreate(val, name, type, caller, "fetch"); return (dns_resolver_createfetch(val->view->resolver, name, type, - NULL, NULL, NULL, fopts, - val->event->ev_sender, + NULL, NULL, NULL, NULL, 0, fopts, + 0, NULL, val->event->ev_sender, callback, val, &val->frdataset, &val->fsigrdataset, diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 1e4aa54b71..e31a8ce549 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -862,8 +862,6 @@ dns_resolver_attach dns_resolver_cancelfetch dns_resolver_create dns_resolver_createfetch -dns_resolver_createfetch2 -dns_resolver_createfetch3 dns_resolver_destroyfetch dns_resolver_detach dns_resolver_disable_algorithm diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 0642c932ba..da9b2a70fc 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -9790,11 +9790,11 @@ zone_refreshkeys(dns_zone_t *zone) { */ result = dns_resolver_createfetch(zone->view->resolver, kname, dns_rdatatype_dnskey, - NULL, NULL, NULL, - DNS_FETCHOPT_NOVALIDATE| - DNS_FETCHOPT_UNSHARED| + NULL, NULL, NULL, NULL, 0, + DNS_FETCHOPT_NOVALIDATE | + DNS_FETCHOPT_UNSHARED | DNS_FETCHOPT_NOCACHED, - zone->task, + 0, NULL, zone->task, keyfetch_done, kfetch, &kfetch->dnskeyset, &kfetch->dnskeysigset, diff --git a/lib/ns/query.c b/lib/ns/query.c index 990323aeea..0ecd1db1bf 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -2446,13 +2446,13 @@ query_prefetch(ns_client_t *client, dns_name_t *qname, peeraddr = NULL; ns_client_attach(client, &dummy); options = client->query.fetchoptions | DNS_FETCHOPT_PREFETCH; - result = dns_resolver_createfetch3(client->view->resolver, - qname, rdataset->type, NULL, NULL, - NULL, peeraddr, client->message->id, - options, 0, NULL, client->task, - prefetch_done, client, - tmprdataset, NULL, - &client->query.prefetch); + result = dns_resolver_createfetch(client->view->resolver, + qname, rdataset->type, NULL, NULL, + NULL, peeraddr, client->message->id, + options, 0, NULL, client->task, + prefetch_done, client, + tmprdataset, NULL, + &client->query.prefetch); if (result != ISC_R_SUCCESS) { query_putrdataset(client, &tmprdataset); ns_client_detach(&dummy); @@ -2653,12 +2653,12 @@ query_rpzfetch(ns_client_t *client, dns_name_t *qname, dns_rdatatype_t type) { peeraddr = NULL; ns_client_attach(client, &dummy); options = client->query.fetchoptions; - result = dns_resolver_createfetch3(client->view->resolver, qname, type, - NULL, NULL, NULL, peeraddr, - client->message->id, options, 0, - NULL, client->task, prefetch_done, - client, tmprdataset, NULL, - &client->query.prefetch); + result = dns_resolver_createfetch(client->view->resolver, qname, type, + NULL, NULL, NULL, peeraddr, + client->message->id, options, 0, + NULL, client->task, prefetch_done, + client, tmprdataset, NULL, + &client->query.prefetch); if (result != ISC_R_SUCCESS) { query_putrdataset(client, &tmprdataset); ns_client_detach(&dummy); @@ -5650,13 +5650,13 @@ query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname, peeraddr = &client->peeraddr; } - result = dns_resolver_createfetch3(client->view->resolver, - qname, qtype, qdomain, nameservers, - NULL, peeraddr, client->message->id, - client->query.fetchoptions, 0, NULL, - client->task, fetch_callback, - client, rdataset, sigrdataset, - &client->query.fetch); + result = dns_resolver_createfetch(client->view->resolver, + qname, qtype, qdomain, nameservers, + NULL, peeraddr, client->message->id, + client->query.fetchoptions, 0, NULL, + client->task, fetch_callback, + client, rdataset, sigrdataset, + &client->query.fetch); if (result != ISC_R_SUCCESS) { query_putrdataset(client, &rdataset); if (sigrdataset != NULL) { From 7dbc6768d6633c30dafa1280cd37f5d8e5a08a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 16:34:41 +0200 Subject: [PATCH 12/18] libdns refactoring: get rid of multiple versions of dns_zone_setfile, dns_zone_notifyreceive, dns_zone_dumptostream, dns_zone_getserial --- bin/check/check-tool.c | 7 +-- bin/named/server.c | 15 ++++-- bin/named/statschannel.c | 4 +- bin/named/zoneconf.c | 12 ++--- bin/tests/optional/zone_test.c | 7 ++- bin/tests/system/dyndb/driver/zone.c | 2 +- lib/dns/include/dns/zone.h | 54 +++------------------- lib/dns/tests/zt_test.c | 12 +++-- lib/dns/win32/libdns.def.in | 7 --- lib/dns/zone.c | 69 ++++------------------------ lib/ns/notify.c | 4 +- lib/ns/tests/nstest.c | 3 +- 12 files changed, 58 insertions(+), 138 deletions(-) diff --git a/bin/check/check-tool.c b/bin/check/check-tool.c index 3537c57d99..cf08a4db33 100644 --- a/bin/check/check-tool.c +++ b/bin/check/check-tool.c @@ -691,7 +691,8 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename, CHECK(dns_name_fromtext(origin, &buffer, dns_rootname, 0, NULL)); CHECK(dns_zone_setorigin(zone, origin)); CHECK(dns_zone_setdbtype(zone, 1, (const char * const *) dbtype)); - CHECK(dns_zone_setfile2(zone, filename, fileformat)); + CHECK(dns_zone_setfile(zone, filename, fileformat, + &dns_master_style_default)); if (journal != NULL) CHECK(dns_zone_setjournal(zone, journal)); @@ -764,8 +765,8 @@ dump_zone(const char *zonename, dns_zone_t *zone, const char *filename, } } - result = dns_zone_dumptostream3(zone, output, fileformat, style, - rawversion); + result = dns_zone_dumptostream(zone, output, fileformat, style, + rawversion); if (output != stdout) (void)isc_stdio_close(output); diff --git a/bin/named/server.c b/bin/named/server.c index 7b7286ce95..09f1c5dd14 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -6145,7 +6145,8 @@ add_keydata_zone(dns_view_t *view, const char *directory, isc_mem_t *mctx) { defaultview ? "managed-keys" : view->name, defaultview ? "bind" : "mkeys", filename, sizeof(filename))); - CHECK(dns_zone_setfile(zone, filename)); + CHECK(dns_zone_setfile(zone, filename, dns_masterformat_text, + &dns_master_style_default)); dns_zone_setview(zone, view); dns_zone_settype(zone, dns_zone_key); @@ -13936,10 +13937,18 @@ named_server_zonestatus(named_server_t *server, isc_lex_t *lex, } /* Serial number */ - serial = dns_zone_getserial(mayberaw); + result = dns_zone_getserial(mayberaw, &serial); + /* XXXWPK TODO this is to mirror old behavior with dns_zone_getserial */ + if (result != ISC_R_SUCCESS) { + serial = 0; + } snprintf(serbuf, sizeof(serbuf), "%u", serial); if (hasraw) { - signed_serial = dns_zone_getserial(zone); + result = dns_zone_getserial(zone, &signed_serial); + /* XXXWPK TODO ut supra */ + if (result != ISC_R_SUCCESS) { + serial = 0; + } snprintf(sserbuf, sizeof(sserbuf), "%u", signed_serial); } diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index 3a8a0003a4..22e0fdac9e 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -1494,7 +1494,7 @@ zone_xmlrender(dns_zone_t *zone, void *arg) { TRY0(xmlTextWriterEndElement(writer)); /* type */ TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "serial")); - if (dns_zone_getserial2(zone, &serial) == ISC_R_SUCCESS) + if (dns_zone_getserial(zone, &serial) == ISC_R_SUCCESS) TRY0(xmlTextWriterWriteFormatString(writer, "%u", serial)); else TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR "-")); @@ -2271,7 +2271,7 @@ zone_jsonrender(dns_zone_t *zone, void *arg) { dns_rdataclass_format(rdclass, classbuf, sizeof(classbuf)); class_only = classbuf; - if (dns_zone_getserial2(zone, &serial) != ISC_R_SUCCESS) + if (dns_zone_getserial(zone, &serial) != ISC_R_SUCCESS) zoneobj = addzone(zone_name_only, class_only, user_zonetype(zone), 0, ISC_FALSE); else diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 428266221f..bddbd18f48 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -1049,21 +1049,21 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, size_t signedlen = strlen(filename) + sizeof(SIGNED); char *signedname; - RETERR(dns_zone_setfile3(raw, filename, - masterformat, masterstyle)); + RETERR(dns_zone_setfile(raw, filename, + masterformat, masterstyle)); signedname = isc_mem_get(mctx, signedlen); if (signedname == NULL) return (ISC_R_NOMEMORY); (void)snprintf(signedname, signedlen, "%s" SIGNED, filename); - result = dns_zone_setfile3(zone, signedname, - dns_masterformat_raw, NULL); + result = dns_zone_setfile(zone, signedname, + dns_masterformat_raw, NULL); isc_mem_put(mctx, signedname, signedlen); if (result != ISC_R_SUCCESS) return (result); } else - RETERR(dns_zone_setfile3(zone, filename, - masterformat, masterstyle)); + RETERR(dns_zone_setfile(zone, filename, + masterformat, masterstyle)); obj = NULL; result = cfg_map_get(zoptions, "journal", &obj); diff --git a/bin/tests/optional/zone_test.c b/bin/tests/optional/zone_test.c index c7af967431..6521d4c5f3 100644 --- a/bin/tests/optional/zone_test.c +++ b/bin/tests/optional/zone_test.c @@ -107,7 +107,8 @@ setup(const char *zonename, const char *filename, const char *classname) { result = dns_zone_setdbtype(zone, 1, &rbt); ERRRET(result, "dns_zone_setdatabase"); - result = dns_zone_setfile(zone, filename); + result = dns_zone_setfile(zone, filename, dns_masterformat_text, + &dns_master_style_default); ERRRET(result, "dns_zone_setfile"); region.base = classname; @@ -190,7 +191,9 @@ query(void) { if (s != NULL) *s = '\0'; if (strcmp(buf, "dump") == 0) { - dns_zone_dumptostream(zone, stdout); + dns_zone_dumptostream(zone, stdout, + dns_masterformat_text, + &dns_master_style_default, 0); continue; } if (strlen(buf) == 0U) diff --git a/bin/tests/system/dyndb/driver/zone.c b/bin/tests/system/dyndb/driver/zone.c index 8d957e5970..a9b7505527 100644 --- a/bin/tests/system/dyndb/driver/zone.c +++ b/bin/tests/system/dyndb/driver/zone.c @@ -154,7 +154,7 @@ load_zone(dns_zone_t *zone) { goto cleanup; zone_dynamic = (result == DNS_R_DYNAMIC); - CHECK(dns_zone_getserial2(zone, &serial)); + CHECK(dns_zone_getserial(zone, &serial)); dns_zone_log(zone, ISC_LOG_INFO, "loaded serial %u", serial); if (zone_dynamic) diff --git a/lib/dns/include/dns/zone.h b/lib/dns/include/dns/zone.h index 4c6346a917..3c21ca8f08 100644 --- a/lib/dns/include/dns/zone.h +++ b/lib/dns/include/dns/zone.h @@ -178,15 +178,10 @@ dns_zone_getclass(dns_zone_t *zone); */ isc_result_t -dns_zone_getserial2(dns_zone_t *zone, isc_uint32_t *serialp); - -isc_uint32_t -dns_zone_getserial(dns_zone_t *zone); +dns_zone_getserial(dns_zone_t *zone, isc_uint32_t *serialp); /*%< * Returns the current serial number of the zone. On success, the SOA * serial of the zone will be copied into '*serialp'. - * dns_zone_getserial() cannot catch failure cases and is deprecated by - * dns_zone_getserial2(). * * Requires: *\li 'zone' to be a valid zone. @@ -272,14 +267,8 @@ dns_zone_getorigin(dns_zone_t *zone); */ isc_result_t -dns_zone_setfile(dns_zone_t *zone, const char *file); - -isc_result_t -dns_zone_setfile2(dns_zone_t *zone, const char *file, - dns_masterformat_t format); -isc_result_t -dns_zone_setfile3(dns_zone_t *zone, const char *file, - dns_masterformat_t format, const dns_master_style_t *style); +dns_zone_setfile(dns_zone_t *zone, const char *file, + dns_masterformat_t format, const dns_master_style_t *style); /*%< * Sets the name of the master file in the format of 'format' from which * the zone loads its database to 'file'. @@ -289,15 +278,6 @@ dns_zone_setfile3(dns_zone_t *zone, const char *file, * For zones with persistent databases, the file name * setting is ignored. * - * dns_zone_setfile() is a backward-compatible form of - * dns_zone_setfile2(), which always specifies the - * dns_masterformat_text (RFC1035) format. - * - * dns_zone_setfile2() is a backward-compatible form of - * dns_zone_setfile3(), which also specifies the style - * that should be used if a zone using the 'text' - * masterformat is ever dumped. - * * Require: *\li 'zone' to be a valid zone. * @@ -602,15 +582,9 @@ dns_zone_dump(dns_zone_t *zone); */ isc_result_t -dns_zone_dumptostream(dns_zone_t *zone, FILE *fd); - -isc_result_t -dns_zone_dumptostream2(dns_zone_t *zone, FILE *fd, dns_masterformat_t format, - const dns_master_style_t *style); -isc_result_t -dns_zone_dumptostream3(dns_zone_t *zone, FILE *fd, dns_masterformat_t format, - const dns_master_style_t *style, - const isc_uint32_t rawversion); +dns_zone_dumptostream(dns_zone_t *zone, FILE *fd, dns_masterformat_t format, + const dns_master_style_t *style, + const isc_uint32_t rawversion); /*%< * Write the zone to stream 'fd' in the specified 'format'. * If the 'format' is dns_masterformat_text (RFC1035), 'style' also @@ -632,17 +606,6 @@ dns_zone_dumptostream3(dns_zone_t *zone, FILE *fd, dns_masterformat_t format, *\li 'fd' to be a stream open for writing. */ -isc_result_t -dns_zone_fulldumptostream(dns_zone_t *zone, FILE *fd); -/*%< - * The same as dns_zone_dumptostream, but dumps the zone with - * different dump settings (dns_master_style_full). - * - * Require: - *\li 'zone' to be a valid zone. - *\li 'fd' to be a stream open for writing. - */ - void dns_zone_maintenance(dns_zone_t *zone); /*%< @@ -1266,10 +1229,7 @@ dns_zone_getjournalsize(dns_zone_t *zone); isc_result_t dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from, - dns_message_t *msg); -isc_result_t -dns_zone_notifyreceive2(dns_zone_t *zone, isc_sockaddr_t *from, - isc_sockaddr_t *to, dns_message_t *msg); + isc_sockaddr_t *to, dns_message_t *msg); /*%< * Tell the zone that it has received a NOTIFY message from another * server. This may cause some zone maintenance activity to occur. diff --git a/lib/dns/tests/zt_test.c b/lib/dns/tests/zt_test.c index 57fc3010d1..bf3b96bbc4 100644 --- a/lib/dns/tests/zt_test.c +++ b/lib/dns/tests/zt_test.c @@ -168,7 +168,8 @@ ATF_TC_BODY(asyncload_zone, tc) { ATF_CHECK(!dns__zone_loadpending(zone)); ATF_CHECK(!done); - dns_zone_setfile(zone, "testdata/zt/zone1.db"); + dns_zone_setfile(zone, "testdata/zt/zone1.db", dns_masterformat_text, + &dns_master_style_default); args.arg1 = zone; args.arg2 = &done; @@ -216,17 +217,20 @@ ATF_TC_BODY(asyncload_zt, tc) { result = dns_test_makezone("foo", &zone1, NULL, ISC_TRUE); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - dns_zone_setfile(zone1, "testdata/zt/zone1.db"); + dns_zone_setfile(zone1, "testdata/zt/zone1.db", + dns_masterformat_text, &dns_master_style_default); view = dns_zone_getview(zone1); result = dns_test_makezone("bar", &zone2, view, ISC_TRUE); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - dns_zone_setfile(zone2, "testdata/zt/zone1.db"); + dns_zone_setfile(zone2, "testdata/zt/zone1.db", + dns_masterformat_text, &dns_master_style_default); /* This one will fail to load */ result = dns_test_makezone("fake", &zone3, view, ISC_TRUE); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - dns_zone_setfile(zone3, "testdata/zt/nonexistent.db"); + dns_zone_setfile(zone3, "testdata/zt/nonexistent.db", + dns_masterformat_text, &dns_master_style_default); zt = view->zonetable; ATF_REQUIRE(zt != NULL); diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index e31a8ce549..4b8c72b5a1 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -1132,14 +1132,11 @@ dns_zone_dialup dns_zone_dlzpostload dns_zone_dump dns_zone_dumptostream -dns_zone_dumptostream2 -dns_zone_dumptostream3 dns_zone_expire dns_zone_first dns_zone_flush dns_zone_forcereload dns_zone_forwardupdate -dns_zone_fulldumptostream dns_zone_get_parentcatz dns_zone_get_rpz_num dns_zone_getadded @@ -1191,7 +1188,6 @@ dns_zone_getrequestexpire dns_zone_getrequestixfr dns_zone_getrequeststats dns_zone_getserial -dns_zone_getserial2 dns_zone_getserialupdatemethod dns_zone_getsignatures dns_zone_getsigresigninginterval @@ -1228,7 +1224,6 @@ dns_zone_nameonly dns_zone_next dns_zone_notify dns_zone_notifyreceive -dns_zone_notifyreceive2 dns_zone_nscheck dns_zone_refresh dns_zone_rekey @@ -1254,8 +1249,6 @@ dns_zone_setdb dns_zone_setdbtype dns_zone_setdialup dns_zone_setfile -dns_zone_setfile2 -dns_zone_setfile3 dns_zone_setflag dns_zone_setforwardacl dns_zone_setidlein diff --git a/lib/dns/zone.c b/lib/dns/zone.c index da9b2a70fc..d68355451f 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -1337,7 +1337,7 @@ dns_zone_setnotifytype(dns_zone_t *zone, dns_notifytype_t notifytype) { } isc_result_t -dns_zone_getserial2(dns_zone_t *zone, isc_uint32_t *serialp) { +dns_zone_getserial(dns_zone_t *zone, isc_uint32_t *serialp) { isc_result_t result; unsigned int soacount; @@ -1360,18 +1360,6 @@ dns_zone_getserial2(dns_zone_t *zone, isc_uint32_t *serialp) { return (result); } -isc_uint32_t -dns_zone_getserial(dns_zone_t *zone) { - isc_result_t result; - isc_uint32_t serial; - - result = dns_zone_getserial2(zone, &serial); - if (result != ISC_R_SUCCESS) - serial = 0; /* XXX: not really correct, but no other choice */ - - return (serial); -} - /* * Single shot. */ @@ -1619,23 +1607,9 @@ dns_zone_setstring(dns_zone_t *zone, char **field, const char *value) { } isc_result_t -dns_zone_setfile(dns_zone_t *zone, const char *file) { - return (dns_zone_setfile3(zone, file, dns_masterformat_text, - &dns_master_style_default)); -} - -isc_result_t -dns_zone_setfile2(dns_zone_t *zone, const char *file, - dns_masterformat_t format) -{ - return (dns_zone_setfile3(zone, file, format, - &dns_master_style_default)); -} - -isc_result_t -dns_zone_setfile3(dns_zone_t *zone, const char *file, - dns_masterformat_t format, - const dns_master_style_t *style) +dns_zone_setfile(dns_zone_t *zone, const char *file, + dns_masterformat_t format, + const dns_master_style_t *style) { isc_result_t result = ISC_R_SUCCESS; @@ -10526,31 +10500,13 @@ dumptostream(dns_zone_t *zone, FILE *fd, const dns_master_style_t *style, } isc_result_t -dns_zone_dumptostream3(dns_zone_t *zone, FILE *fd, dns_masterformat_t format, - const dns_master_style_t *style, - const isc_uint32_t rawversion) +dns_zone_dumptostream(dns_zone_t *zone, FILE *fd, dns_masterformat_t format, + const dns_master_style_t *style, + const isc_uint32_t rawversion) { return (dumptostream(zone, fd, style, format, rawversion)); } -isc_result_t -dns_zone_dumptostream2(dns_zone_t *zone, FILE *fd, dns_masterformat_t format, - const dns_master_style_t *style) { - return (dumptostream(zone, fd, style, format, DNS_RAWFORMAT_VERSION)); -} - -isc_result_t -dns_zone_dumptostream(dns_zone_t *zone, FILE *fd) { - return (dumptostream(zone, fd, &dns_master_style_default, - dns_masterformat_text, 0)); -} - -isc_result_t -dns_zone_fulldumptostream(dns_zone_t *zone, FILE *fd) { - return (dumptostream(zone, fd, &dns_master_style_full, - dns_masterformat_text, 0)); -} - void dns_zone_unload(dns_zone_t *zone) { REQUIRE(DNS_ZONE_VALID(zone)); @@ -13141,14 +13097,7 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags, isc_result_t dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from, - dns_message_t *msg) -{ - return (dns_zone_notifyreceive2(zone, from, NULL, msg)); -} - -isc_result_t -dns_zone_notifyreceive2(dns_zone_t *zone, isc_sockaddr_t *from, - isc_sockaddr_t *to, dns_message_t *msg) + isc_sockaddr_t *to, dns_message_t *msg) { unsigned int i; dns_rdata_soa_t soa; @@ -13193,7 +13142,7 @@ dns_zone_notifyreceive2(dns_zone_t *zone, isc_sockaddr_t *from, LOCK_ZONE(zone); INSIST(zone != zone->raw); if (inline_secure(zone)) { - result = dns_zone_notifyreceive2(zone->raw, from, to, msg); + result = dns_zone_notifyreceive(zone->raw, from, to, msg); UNLOCK_ZONE(zone); return (result); } diff --git a/lib/ns/notify.c b/lib/ns/notify.c index fa95d2ef52..f507b0ecad 100644 --- a/lib/ns/notify.c +++ b/lib/ns/notify.c @@ -148,8 +148,8 @@ ns_notify_start(ns_client_t *client) { notify_log(client, ISC_LOG_INFO, "received notify for zone '%s'%s", namebuf, tsigbuf); - result = dns_zone_notifyreceive2(zone, from, to, - request); + result = dns_zone_notifyreceive(zone, from, to, + request); goto done; } } diff --git a/lib/ns/tests/nstest.c b/lib/ns/tests/nstest.c index 966477610c..c63cea62b0 100644 --- a/lib/ns/tests/nstest.c +++ b/lib/ns/tests/nstest.c @@ -471,7 +471,8 @@ ns_test_serve_zone(const char *zonename, const char *filename, /* * Set path to the master file for the zone and then load it. */ - dns_zone_setfile(served_zone, filename); + dns_zone_setfile(served_zone, filename, dns_masterformat_text, + &dns_master_style_default); result = dns_zone_load(served_zone); if (result != ISC_R_SUCCESS) { goto release_zone; From ef0e68bfc3e474eae9ad96ede8880c15bef8835c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 23:56:04 +0200 Subject: [PATCH 13/18] libdns refactoring: integrate zone->options and zone->options2 into one enum, removing unnecessary flags. --- bin/check/check-tool.c | 20 ++++---- bin/check/check-tool.h | 4 +- bin/check/named-checkconf.c | 2 +- bin/check/named-checkzone.c | 2 +- bin/named/server.c | 2 +- bin/named/statschannel.c | 2 +- lib/dns/include/dns/zone.h | 99 +++++++++++++------------------------ lib/dns/win32/libdns.def.in | 2 - lib/dns/zone.c | 36 +++----------- lib/ns/update.c | 7 ++- 10 files changed, 58 insertions(+), 118 deletions(-) diff --git a/bin/check/check-tool.c b/bin/check/check-tool.c index cf08a4db33..e8734e1b1e 100644 --- a/bin/check/check-tool.c +++ b/bin/check/check-tool.c @@ -99,18 +99,17 @@ isc_boolean_t docheckmx = ISC_FALSE; isc_boolean_t dochecksrv = ISC_FALSE; isc_boolean_t docheckns = ISC_FALSE; #endif -unsigned int zone_options = DNS_ZONEOPT_CHECKNS | - DNS_ZONEOPT_CHECKMX | - DNS_ZONEOPT_MANYERRORS | - DNS_ZONEOPT_CHECKNAMES | - DNS_ZONEOPT_CHECKINTEGRITY | +dns_zoneopt_t zone_options = DNS_ZONEOPT_CHECKNS | + DNS_ZONEOPT_CHECKMX | + DNS_ZONEOPT_MANYERRORS | + DNS_ZONEOPT_CHECKNAMES | + DNS_ZONEOPT_CHECKINTEGRITY | #if CHECK_SIBLING - DNS_ZONEOPT_CHECKSIBLING | + DNS_ZONEOPT_CHECKSIBLING | #endif - DNS_ZONEOPT_CHECKWILDCARD | - DNS_ZONEOPT_WARNMXCNAME | - DNS_ZONEOPT_WARNSRVCNAME; -unsigned int zone_options2 = 0; + DNS_ZONEOPT_CHECKWILDCARD | + DNS_ZONEOPT_WARNMXCNAME | + DNS_ZONEOPT_WARNSRVCNAME; /* * This needs to match the list in bin/named/log.c. @@ -702,7 +701,6 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename, dns_zone_setclass(zone, rdclass); dns_zone_setoption(zone, zone_options, ISC_TRUE); - dns_zone_setoption2(zone, zone_options2, ISC_TRUE); dns_zone_setoption(zone, DNS_ZONEOPT_NOMERGE, nomerge); dns_zone_setmaxttl(zone, maxttl); diff --git a/bin/check/check-tool.h b/bin/check/check-tool.h index 55c2016894..8420857f08 100644 --- a/bin/check/check-tool.h +++ b/bin/check/check-tool.h @@ -22,6 +22,7 @@ #include #include +#include ISC_LANG_BEGINDECLS @@ -49,8 +50,7 @@ extern isc_boolean_t nomerge; extern isc_boolean_t docheckmx; extern isc_boolean_t docheckns; extern isc_boolean_t dochecksrv; -extern unsigned int zone_options; -extern unsigned int zone_options2; +extern dns_zoneopt_t zone_options; ISC_LANG_ENDDECLS diff --git a/bin/check/named-checkconf.c b/bin/check/named-checkconf.c index 9c57c48297..944597857e 100644 --- a/bin/check/named-checkconf.c +++ b/bin/check/named-checkconf.c @@ -408,7 +408,7 @@ configure_zone(const char *vclass, const char *view, obj = NULL; if (get_maps(maps, "max-zone-ttl", &obj)) { maxttl = cfg_obj_asuint32(obj); - zone_options2 |= DNS_ZONEOPT2_CHECKTTL; + zone_options |= DNS_ZONEOPT_CHECKTTL; } result = load_zone(mctx, zname, zfile, masterformat, diff --git a/bin/check/named-checkzone.c b/bin/check/named-checkzone.c index 590948ebca..aed4ac89dd 100644 --- a/bin/check/named-checkzone.c +++ b/bin/check/named-checkzone.c @@ -260,7 +260,7 @@ main(int argc, char **argv) { break; case 'l': - zone_options2 |= DNS_ZONEOPT2_CHECKTTL; + zone_options |= DNS_ZONEOPT_CHECKTTL; endp = NULL; maxttl = strtol(isc_commandline_argument, &endp, 0); if (*endp != '\0') { diff --git a/bin/named/server.c b/bin/named/server.c index 09f1c5dd14..d42c001785 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -3350,7 +3350,7 @@ create_empty_zone(dns_zone_t *zone, dns_name_t *name, dns_view_t *view, dns_db_closeversion(db, &version, ISC_TRUE); CHECK(dns_zone_replacedb(zone, db, ISC_FALSE)); } - dns_zone_setoption2(zone, DNS_ZONEOPT2_AUTOEMPTY, ISC_TRUE); + dns_zone_setoption(zone, DNS_ZONEOPT_AUTOEMPTY, ISC_TRUE); dns_zone_setview(zone, view); CHECK(dns_view_addzone(view, zone)); diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index 22e0fdac9e..0080ead9c0 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -100,7 +100,7 @@ user_zonetype( dns_zone_t *zone ) { }; const struct zt *tp; - if ((dns_zone_getoptions2(zone) & DNS_ZONEOPT2_AUTOEMPTY) != 0) + if ((dns_zone_getoptions(zone) & DNS_ZONEOPT_AUTOEMPTY) != 0) return ("builtin"); view = dns_zone_getview(zone); diff --git a/lib/dns/include/dns/zone.h b/lib/dns/include/dns/zone.h index 3c21ca8f08..d3fed857c3 100644 --- a/lib/dns/include/dns/zone.h +++ b/lib/dns/include/dns/zone.h @@ -49,53 +49,38 @@ typedef enum { dns_zonestat_full } dns_zonestat_level_t; -#define DNS_ZONEOPT_SERVERS 0x00000001U /*%< perform server checks */ -#define DNS_ZONEOPT_PARENTS 0x00000002U /*%< perform parent checks */ -#define DNS_ZONEOPT_CHILDREN 0x00000004U /*%< perform child checks */ -#define DNS_ZONEOPT_NOTIFY 0x00000008U /*%< perform NOTIFY */ -#define DNS_ZONEOPT_MANYERRORS 0x00000010U /*%< return many errors on load */ -#define DNS_ZONEOPT_IXFRFROMDIFFS 0x00000020U /*%< calculate differences */ -#define DNS_ZONEOPT_NOMERGE 0x00000040U /*%< don't merge journal */ -#define DNS_ZONEOPT_CHECKNS 0x00000080U /*%< check if NS's are addresses */ -#define DNS_ZONEOPT_FATALNS 0x00000100U /*%< DNS_ZONEOPT_CHECKNS is fatal */ -#define DNS_ZONEOPT_MULTIMASTER 0x00000200U /*%< this zone has multiple masters */ -#define DNS_ZONEOPT_USEALTXFRSRC 0x00000400U /*%< use alternate transfer sources */ -#define DNS_ZONEOPT_CHECKNAMES 0x00000800U /*%< check-names */ -#define DNS_ZONEOPT_CHECKNAMESFAIL 0x00001000U /*%< fatal check-name failures */ -#define DNS_ZONEOPT_CHECKWILDCARD 0x00002000U /*%< check for internal wildcards */ -#define DNS_ZONEOPT_CHECKMX 0x00004000U /*%< check-mx */ -#define DNS_ZONEOPT_CHECKMXFAIL 0x00008000U /*%< fatal check-mx failures */ -#define DNS_ZONEOPT_CHECKINTEGRITY 0x00010000U /*%< perform integrity checks */ -#define DNS_ZONEOPT_CHECKSIBLING 0x00020000U /*%< perform sibling glue checks */ -#define DNS_ZONEOPT_NOCHECKNS 0x00040000U /*%< disable IN NS address checks */ -#define DNS_ZONEOPT_WARNMXCNAME 0x00080000U /*%< warn on MX CNAME check */ -#define DNS_ZONEOPT_IGNOREMXCNAME 0x00100000U /*%< ignore MX CNAME check */ -#define DNS_ZONEOPT_WARNSRVCNAME 0x00200000U /*%< warn on SRV CNAME check */ -#define DNS_ZONEOPT_IGNORESRVCNAME 0x00400000U /*%< ignore SRV CNAME check */ -#define DNS_ZONEOPT_UPDATECHECKKSK 0x00800000U /*%< check dnskey KSK flag */ -#define DNS_ZONEOPT_TRYTCPREFRESH 0x01000000U /*%< try tcp refresh on udp failure */ -#define DNS_ZONEOPT_NOTIFYTOSOA 0x02000000U /*%< Notify the SOA MNAME */ -#define DNS_ZONEOPT_NSEC3TESTZONE 0x04000000U /*%< nsec3-test-zone */ -#define DNS_ZONEOPT_SECURETOINSECURE 0x08000000U /*%< dnssec-secure-to-insecure */ -#define DNS_ZONEOPT_DNSKEYKSKONLY 0x10000000U /*%< dnssec-dnskey-kskonly */ -#define DNS_ZONEOPT_CHECKDUPRR 0x20000000U /*%< check-dup-records */ -#define DNS_ZONEOPT_CHECKDUPRRFAIL 0x40000000U /*%< fatal check-dup-records failures */ -#define DNS_ZONEOPT_CHECKSPF 0x80000000U /*%< check SPF records */ - -/* - * The following zone options are shifted left into the - * higher-order 32 bits of the options. - */ -#define DNS_ZONEOPT2_CHECKTTL 0x00000001U /*%< check max-zone-ttl */ -#define DNS_ZONEOPT2_AUTOEMPTY 0x00000002U /*%< automatic empty zone */ - -#ifndef NOMINUM_PUBLIC -/* - * Nominum specific options build down. - */ -#define DNS_ZONEOPT_NOTIFYFORWARD 0x80000000U /* forward notify to master */ -#endif /* NOMINUM_PUBLIC */ - +typedef enum { + DNS_ZONEOPT_MANYERRORS = 1<<0, /*%< return many errors on load */ + DNS_ZONEOPT_IXFRFROMDIFFS = 1<<1, /*%< calculate differences */ + DNS_ZONEOPT_NOMERGE = 1<<2, /*%< don't merge journal */ + DNS_ZONEOPT_CHECKNS = 1<<3, /*%< check if NS's are addresses */ + DNS_ZONEOPT_FATALNS = 1<<4, /*%< DNS_ZONEOPT_CHECKNS is fatal */ + DNS_ZONEOPT_MULTIMASTER = 1<<5, /*%< this zone has multiple masters */ + DNS_ZONEOPT_USEALTXFRSRC = 1<<6, /*%< use alternate transfer sources */ + DNS_ZONEOPT_CHECKNAMES = 1<<7, /*%< check-names */ + DNS_ZONEOPT_CHECKNAMESFAIL = 1<<8, /*%< fatal check-name failures */ + DNS_ZONEOPT_CHECKWILDCARD = 1<<9, /*%< check for internal wildcards */ + DNS_ZONEOPT_CHECKMX = 1<<10, /*%< check-mx */ + DNS_ZONEOPT_CHECKMXFAIL = 1<<11, /*%< fatal check-mx failures */ + DNS_ZONEOPT_CHECKINTEGRITY = 1<<12, /*%< perform integrity checks */ + DNS_ZONEOPT_CHECKSIBLING = 1<<13, /*%< perform sibling glue checks */ + DNS_ZONEOPT_NOCHECKNS = 1<<14, /*%< disable IN NS address checks */ + DNS_ZONEOPT_WARNMXCNAME = 1<<15, /*%< warn on MX CNAME check */ + DNS_ZONEOPT_IGNOREMXCNAME = 1<<16, /*%< ignore MX CNAME check */ + DNS_ZONEOPT_WARNSRVCNAME = 1<<17, /*%< warn on SRV CNAME check */ + DNS_ZONEOPT_IGNORESRVCNAME = 1<<18, /*%< ignore SRV CNAME check */ + DNS_ZONEOPT_UPDATECHECKKSK = 1<<19, /*%< check dnskey KSK flag */ + DNS_ZONEOPT_TRYTCPREFRESH = 1<<20, /*%< try tcp refresh on udp failure */ + DNS_ZONEOPT_NOTIFYTOSOA = 1<<21, /*%< Notify the SOA MNAME */ + DNS_ZONEOPT_NSEC3TESTZONE = 1<<22, /*%< nsec3-test-zone */ + DNS_ZONEOPT_SECURETOINSECURE = 1<<23, /*%< dnssec-secure-to-insecure */ + DNS_ZONEOPT_DNSKEYKSKONLY = 1<<24, /*%< dnssec-dnskey-kskonly */ + DNS_ZONEOPT_CHECKDUPRR = 1<<25, /*%< check-dup-records */ + DNS_ZONEOPT_CHECKDUPRRFAIL = 1<<26, /*%< fatal check-dup-records failures */ + DNS_ZONEOPT_CHECKSPF = 1<<27, /*%< check SPF records */ + DNS_ZONEOPT_CHECKTTL = 1<<28, /*%< check max-zone-ttl */ + DNS_ZONEOPT_AUTOEMPTY = 1<<29 /*%< automatic empty zone */ +} dns_zoneopt_t; /* * Zone key maintenance options */ @@ -681,37 +666,21 @@ dns_zone_unload(dns_zone_t *zone); */ void -dns_zone_setoption(dns_zone_t *zone, unsigned int option, +dns_zone_setoption(dns_zone_t *zone, dns_zoneopt_t option, isc_boolean_t value); -void -dns_zone_setoption2(dns_zone_t *zone, unsigned int option, - isc_boolean_t value); /*%< * Set the given options on ('value' == ISC_TRUE) or off * ('value' == #ISC_FALSE). * - * dns_zone_setoption2() has been introduced because the number - * of options needed now exceeds the 32 bits in the zone->options - * field; it should be used set options with names beginning - * with DNS_ZONEOPT2_. - * * Require: *\li 'zone' to be a valid zone. */ -unsigned int +dns_zoneopt_t dns_zone_getoptions(dns_zone_t *zone); -unsigned int -dns_zone_getoptions2(dns_zone_t *zone); /*%< * Returns the current zone options. * - * Callers should be aware there is now more than one set of zone - * options. dns_zone_getoptions2() has been introduced because the - * number of options needed now exceeds the 32 bits in the - * zone->options field. It returns the options whose names begin - * with DNS_ZONEOPT2_. - * * Require: *\li 'zone' to be a valid zone. */ diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 4b8c72b5a1..4314c0154d 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -1174,7 +1174,6 @@ dns_zone_getnotifysrc4dscp dns_zone_getnotifysrc6 dns_zone_getnotifysrc6dscp dns_zone_getoptions -dns_zone_getoptions2 dns_zone_getorigin dns_zone_getprivatetype dns_zone_getqueryacl @@ -1278,7 +1277,6 @@ dns_zone_setnotifysrc6dscp dns_zone_setnotifytype dns_zone_setnsec3param dns_zone_setoption -dns_zone_setoption2 dns_zone_setorigin dns_zone_setprivatetype dns_zone_setqueryacl diff --git a/lib/dns/zone.c b/lib/dns/zone.c index d68355451f..8edc8ae022 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -218,8 +218,7 @@ struct dns_zone { dns_rdataclass_t rdclass; dns_zonetype_t type; unsigned int flags; - unsigned int options; - unsigned int options2; + dns_zoneopt_t options; unsigned int db_argc; char **db_argv; isc_time_t expiretime; @@ -498,7 +497,6 @@ typedef struct { * first time. */ #define DNS_ZONE_OPTION(z,o) (((z)->options & (o)) != 0) -#define DNS_ZONE_OPTION2(z,o) (((z)->options2 & (o)) != 0) #define DNS_ZONEKEY_OPTION(z,o) (((z)->keyopts & (o)) != 0) /* Flags for zone_load() */ @@ -941,7 +939,6 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) { zone->type = dns_zone_none; zone->flags = 0; zone->options = 0; - zone->options2 = 0; zone->keyopts = 0; zone->db_argc = 0; zone->db_argv = NULL; @@ -1648,9 +1645,9 @@ dns_zone_setmaxttl(dns_zone_t *zone, dns_ttl_t maxttl) { LOCK_ZONE(zone); if (maxttl != 0) - zone->options2 |= DNS_ZONEOPT2_CHECKTTL; + zone->options |= DNS_ZONEOPT_CHECKTTL; else - zone->options2 &= ~DNS_ZONEOPT2_CHECKTTL; + zone->options &= ~DNS_ZONEOPT_CHECKTTL; zone->maxttl = maxttl; UNLOCK_ZONE(zone); @@ -2269,7 +2266,7 @@ get_master_options(dns_zone_t *zone) { options |= DNS_MASTER_CHECKMXFAIL; if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_CHECKWILDCARD)) options |= DNS_MASTER_CHECKWILDCARD; - if (DNS_ZONE_OPTION2(zone, DNS_ZONEOPT2_CHECKTTL)) + if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_CHECKTTL)) options |= DNS_MASTER_CHECKTTL; return (options); } @@ -5357,7 +5354,7 @@ dns_zone_setflag(dns_zone_t *zone, unsigned int flags, isc_boolean_t value) { } void -dns_zone_setoption(dns_zone_t *zone, unsigned int option, +dns_zone_setoption(dns_zone_t *zone, dns_zoneopt_t option, isc_boolean_t value) { REQUIRE(DNS_ZONE_VALID(zone)); @@ -5370,34 +5367,13 @@ dns_zone_setoption(dns_zone_t *zone, unsigned int option, UNLOCK_ZONE(zone); } -void -dns_zone_setoption2(dns_zone_t *zone, unsigned int option, - isc_boolean_t value) -{ - REQUIRE(DNS_ZONE_VALID(zone)); - - LOCK_ZONE(zone); - if (value) - zone->options2 |= option; - else - zone->options2 &= ~option; - UNLOCK_ZONE(zone); -} - -unsigned int +dns_zoneopt_t dns_zone_getoptions(dns_zone_t *zone) { REQUIRE(DNS_ZONE_VALID(zone)); return (zone->options); } -unsigned int -dns_zone_getoptions2(dns_zone_t *zone) { - REQUIRE(DNS_ZONE_VALID(zone)); - - return (zone->options2); -} - void dns_zone_setkeyopt(dns_zone_t *zone, unsigned int keyopt, isc_boolean_t value) { diff --git a/lib/ns/update.c b/lib/ns/update.c index 05e60d592d..6e99e4a38c 100644 --- a/lib/ns/update.c +++ b/lib/ns/update.c @@ -1714,7 +1714,7 @@ check_mx(ns_client_t *client, dns_zone_t *zone, isc_result_t result; struct in6_addr addr6; struct in_addr addr; - unsigned int options; + dns_zoneopt_t options; dns_fixedname_init(&fixed); foundname = dns_fixedname_name(&fixed); @@ -2503,7 +2503,7 @@ update_action(isc_task_t *task, isc_event_t *event) { dns_ssutable_t *ssutable = NULL; dns_fixedname_t tmpnamefixed; dns_name_t *tmpname = NULL; - unsigned int options, options2; + dns_zoneopt_t options; dns_difftuple_t *tuple; dns_rdata_dnskey_t dnskey; isc_boolean_t had_dnskey; @@ -2782,7 +2782,6 @@ update_action(isc_task_t *task, isc_event_t *event) { */ options = dns_zone_getoptions(zone); - options2 = dns_zone_getoptions2(zone); for (result = dns_message_firstname(request, DNS_SECTION_UPDATE); result == ISC_R_SUCCESS; result = dns_message_nextname(request, DNS_SECTION_UPDATE)) @@ -2911,7 +2910,7 @@ update_action(isc_task_t *task, isc_event_t *event) { "a non-terminal wildcard", namestr); } - if ((options2 & DNS_ZONEOPT2_CHECKTTL) != 0) { + if ((options & DNS_ZONEOPT_CHECKTTL) != 0) { maxttl = dns_zone_getmaxttl(zone); if (ttl > maxttl) { ttl = maxttl; From 702c02201675551bf40dc9a0e6b59fd7163cb46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Wed, 4 Apr 2018 09:44:50 +0200 Subject: [PATCH 14/18] libdns refactoring: get rid of multiple versions of dns_xfrin_create, dst_key_generate, dst_lib_init and dst_context_create --- bin/confgen/keygen.c | 8 ++-- bin/dig/dighost.c | 2 +- bin/dnssec/dnssec-cds.c | 2 +- bin/dnssec/dnssec-dsfromkey.c | 2 +- bin/dnssec/dnssec-importkey.c | 2 +- bin/dnssec/dnssec-keyfromlabel.c | 4 +- bin/dnssec/dnssec-keygen.c | 16 +++---- bin/dnssec/dnssec-revoke.c | 4 +- bin/dnssec/dnssec-settime.c | 4 +- bin/dnssec/dnssec-signzone.c | 2 +- bin/dnssec/dnssec-verify.c | 2 +- bin/named/server.c | 6 +-- bin/nsupdate/nsupdate.c | 2 +- bin/tests/makejournal.c | 2 +- bin/tests/optional/dst_test.c | 13 +++--- bin/tests/optional/gsstest.c | 2 +- bin/tests/optional/sig0_test.c | 2 +- bin/tests/system/pipelined/pipequeries.c | 2 +- bin/tests/system/rsabigexponent/bigkey.c | 2 +- bin/tests/system/tkey/keycreate.c | 2 +- bin/tests/system/tkey/keydelete.c | 2 +- bin/tools/mdig.c | 2 +- lib/dns/dnssec.c | 16 +++---- lib/dns/dst_api.c | 52 +++-------------------- lib/dns/include/dns/xfrin.h | 29 +++---------- lib/dns/include/dst/dst.h | 37 +++------------- lib/dns/lib.c | 2 +- lib/dns/tests/dnstest.c | 2 +- lib/dns/tests/dst_test.c | 4 +- lib/dns/tests/dstrandom_test.c | 2 +- lib/dns/tests/rsa_test.c | 16 +++---- lib/dns/tests/tsig_test.c | 4 +- lib/dns/tsig.c | 18 ++++---- lib/dns/win32/libdns.def.in | 7 --- lib/dns/xfrin.c | 54 +++--------------------- lib/dns/zone.c | 8 ++-- lib/ns/tests/nstest.c | 2 +- 37 files changed, 106 insertions(+), 232 deletions(-) diff --git a/bin/confgen/keygen.c b/bin/confgen/keygen.c index 7391a3e290..21e59631ae 100644 --- a/bin/confgen/keygen.c +++ b/bin/confgen/keygen.c @@ -170,12 +170,12 @@ generate_key(isc_mem_t *mctx, const char *randomfile, dns_secalg_t alg, entropy_flags = ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY; - DO("initialize dst library", dst_lib_init(mctx, ectx, entropy_flags)); + DO("initialize dst library", dst_lib_init(mctx, ectx, NULL, entropy_flags)); DO("generate key", dst_key_generate(dns_rootname, alg, - keysize, 0, 0, - DNS_KEYPROTO_ANY, - dns_rdataclass_in, mctx, &key)); + keysize, 0, 0, DNS_KEYPROTO_ANY, + dns_rdataclass_in, mctx, &key, + NULL)); isc_buffer_init(&key_rawbuffer, &key_rawsecret, sizeof(key_rawsecret)); diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 8d865327f8..2347c14ded 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -1400,7 +1400,7 @@ setup_libs(void) { result = isc_entropy_create(mctx, &entp); check_result(result, "isc_entropy_create"); - result = dst_lib_init(mctx, entp, 0); + result = dst_lib_init(mctx, entp, NULL, 0); check_result(result, "dst_lib_init"); is_dst_up = ISC_TRUE; diff --git a/bin/dnssec/dnssec-cds.c b/bin/dnssec/dnssec-cds.c index c7ab16ace0..a08fdc66dc 100644 --- a/bin/dnssec/dnssec-cds.c +++ b/bin/dnssec/dnssec-cds.c @@ -1237,7 +1237,7 @@ main(int argc, char *argv[]) { if (ectx == NULL) { setup_entropy(mctx, NULL, &ectx); } - result = dst_lib_init(mctx, ectx, + result = dst_lib_init(mctx, ectx, NULL, ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY); if (result != ISC_R_SUCCESS) { fatal("could not initialize dst: %s", diff --git a/bin/dnssec/dnssec-dsfromkey.c b/bin/dnssec/dnssec-dsfromkey.c index 383bee36be..051b6b5bba 100644 --- a/bin/dnssec/dnssec-dsfromkey.c +++ b/bin/dnssec/dnssec-dsfromkey.c @@ -479,7 +479,7 @@ main(int argc, char **argv) { if (ectx == NULL) setup_entropy(mctx, NULL, &ectx); - result = dst_lib_init(mctx, ectx, + result = dst_lib_init(mctx, ectx, NULL, ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY); if (result != ISC_R_SUCCESS) fatal("could not initialize dst: %s", diff --git a/bin/dnssec/dnssec-importkey.c b/bin/dnssec/dnssec-importkey.c index fa8788e236..e96d4fe50b 100644 --- a/bin/dnssec/dnssec-importkey.c +++ b/bin/dnssec/dnssec-importkey.c @@ -408,7 +408,7 @@ main(int argc, char **argv) { if (ectx == NULL) setup_entropy(mctx, NULL, &ectx); - result = dst_lib_init(mctx, ectx, + result = dst_lib_init(mctx, ectx, NULL, ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY); if (result != ISC_R_SUCCESS) fatal("could not initialize dst: %s", diff --git a/bin/dnssec/dnssec-keyfromlabel.c b/bin/dnssec/dnssec-keyfromlabel.c index 69cece8bfa..8e8797146d 100644 --- a/bin/dnssec/dnssec-keyfromlabel.c +++ b/bin/dnssec/dnssec-keyfromlabel.c @@ -349,8 +349,8 @@ main(int argc, char **argv) { if (ectx == NULL) setup_entropy(mctx, NULL, &ectx); - ret = dst_lib_init2(mctx, ectx, engine, - ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY); + ret = dst_lib_init(mctx, ectx, engine, + ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY); if (ret != ISC_R_SUCCESS) fatal("could not initialize dst: %s", isc_result_totext(ret)); diff --git a/bin/dnssec/dnssec-keygen.c b/bin/dnssec/dnssec-keygen.c index cc8b4898f8..ba20c32bf2 100644 --- a/bin/dnssec/dnssec-keygen.c +++ b/bin/dnssec/dnssec-keygen.c @@ -496,8 +496,8 @@ main(int argc, char **argv) { if (ectx == NULL) setup_entropy(mctx, NULL, &ectx); - ret = dst_lib_init2(mctx, ectx, engine, - ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY); + ret = dst_lib_init(mctx, ectx, engine, + ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY); if (ret != ISC_R_SUCCESS) fatal("could not initialize dst: %s", isc_result_totext(ret)); @@ -862,15 +862,15 @@ main(int argc, char **argv) { if (!quiet && show_progress) { fprintf(stderr, "Generating key pair."); - ret = dst_key_generate2(name, alg, size, param, flags, - protocol, rdclass, mctx, &key, - &progress); + ret = dst_key_generate(name, alg, size, param, flags, + protocol, rdclass, mctx, &key, + &progress); putc('\n', stderr); fflush(stderr); } else { - ret = dst_key_generate2(name, alg, size, param, flags, - protocol, rdclass, mctx, &key, - NULL); + ret = dst_key_generate(name, alg, size, param, flags, + protocol, rdclass, mctx, &key, + NULL); } isc_entropy_stopcallbacksources(ectx); diff --git a/bin/dnssec/dnssec-revoke.c b/bin/dnssec/dnssec-revoke.c index 1d7ae8f275..3363c1d59b 100644 --- a/bin/dnssec/dnssec-revoke.c +++ b/bin/dnssec/dnssec-revoke.c @@ -182,8 +182,8 @@ main(int argc, char **argv) { if (ectx == NULL) setup_entropy(mctx, NULL, &ectx); - result = dst_lib_init2(mctx, ectx, engine, - ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY); + result = dst_lib_init(mctx, ectx, engine, + ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY); if (result != ISC_R_SUCCESS) fatal("Could not initialize dst: %s", isc_result_totext(result)); diff --git a/bin/dnssec/dnssec-settime.c b/bin/dnssec/dnssec-settime.c index e82a08e559..221152361f 100644 --- a/bin/dnssec/dnssec-settime.c +++ b/bin/dnssec/dnssec-settime.c @@ -380,8 +380,8 @@ main(int argc, char **argv) { if (ectx == NULL) setup_entropy(mctx, NULL, &ectx); - result = dst_lib_init2(mctx, ectx, engine, - ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY); + result = dst_lib_init(mctx, ectx, engine, + ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY); if (result != ISC_R_SUCCESS) fatal("Could not initialize dst: %s", isc_result_totext(result)); diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 7e504c2bcd..c5e21ef8d6 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -3505,7 +3505,7 @@ main(int argc, char *argv[]) { if (!pseudorandom) eflags |= ISC_ENTROPY_GOODONLY; - result = dst_lib_init2(mctx, ectx, engine, eflags); + result = dst_lib_init(mctx, ectx, engine, eflags); if (result != ISC_R_SUCCESS) fatal("could not initialize dst: %s", isc_result_totext(result)); diff --git a/bin/dnssec/dnssec-verify.c b/bin/dnssec/dnssec-verify.c index 54acb7a57f..21b157cd4a 100644 --- a/bin/dnssec/dnssec-verify.c +++ b/bin/dnssec/dnssec-verify.c @@ -281,7 +281,7 @@ main(int argc, char *argv[]) { if (ectx == NULL) setup_entropy(mctx, NULL, &ectx); - result = dst_lib_init2(mctx, ectx, engine, ISC_ENTROPY_BLOCKING); + result = dst_lib_init(mctx, ectx, engine, ISC_ENTROPY_BLOCKING); if (result != ISC_R_SUCCESS) fatal("could not initialize dst: %s", isc_result_totext(result)); diff --git a/bin/named/server.c b/bin/named/server.c index d42c001785..7511a680f2 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -6820,7 +6820,7 @@ generate_session_key(const char *filename, const char *keynamestr, /* generate key */ result = dst_key_generate(keyname, algtype, bits, 1, 0, DNS_KEYPROTO_ANY, dns_rdataclass_in, - mctx, &key); + mctx, &key, NULL); if (result != ISC_R_SUCCESS) return (result); @@ -9424,8 +9424,8 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) { server->in_roothints = NULL; /* Must be first. */ - CHECKFATAL(dst_lib_init2(named_g_mctx, named_g_entropy, - named_g_engine, ISC_ENTROPY_GOODONLY), + CHECKFATAL(dst_lib_init(named_g_mctx, named_g_entropy, + named_g_engine, ISC_ENTROPY_GOODONLY), "initializing DST"); CHECKFATAL(dns_rootns_create(mctx, dns_rdataclass_in, NULL, diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 5baf409313..4c416ab880 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -989,7 +989,7 @@ setup_system(void) { result = isc_task_onshutdown(global_task, shutdown_program, NULL); check_result(result, "isc_task_onshutdown"); - result = dst_lib_init(gmctx, entropy, 0); + result = dst_lib_init(gmctx, entropy, NULL, 0); check_result(result, "dst_lib_init"); is_dst_up = ISC_TRUE; diff --git a/bin/tests/makejournal.c b/bin/tests/makejournal.c index 03481b9ce2..36cd32b332 100644 --- a/bin/tests/makejournal.c +++ b/bin/tests/makejournal.c @@ -101,7 +101,7 @@ main(int argc, char **argv) { CHECK(isc_mem_create(0, 0, &mctx)); CHECK(isc_entropy_create(mctx, &ectx)); - CHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_BLOCKING)); + CHECK(dst_lib_init(mctx, ectx, NULL, ISC_ENTROPY_BLOCKING)); dst_active = ISC_TRUE; CHECK(isc_log_create(mctx, &lctx, &logconfig)); diff --git a/bin/tests/optional/dst_test.c b/bin/tests/optional/dst_test.c index f2b1bc15bf..30f071e4f1 100644 --- a/bin/tests/optional/dst_test.c +++ b/bin/tests/optional/dst_test.c @@ -52,8 +52,8 @@ use(dst_key_t *key, isc_mem_t *mctx) { isc_buffer_add(&databuf, strlen(data)); isc_buffer_usedregion(&databuf, &datareg); - ret = dst_context_create3(key, mctx, - DNS_LOGCATEGORY_GENERAL, ISC_TRUE, &ctx); + ret = dst_context_create(key, mctx, + DNS_LOGCATEGORY_GENERAL, ISC_TRUE, 0, &ctx); if (ret != ISC_R_SUCCESS) { printf("contextcreate(%u) returned: %s\n", dst_key_alg(key), isc_result_totext(ret)); @@ -73,8 +73,8 @@ use(dst_key_t *key, isc_mem_t *mctx) { isc_buffer_forward(&sigbuf, 1); isc_buffer_remainingregion(&sigbuf, &sigreg); - ret = dst_context_create3(key, mctx, - DNS_LOGCATEGORY_GENERAL, ISC_FALSE, &ctx); + ret = dst_context_create(key, mctx, + DNS_LOGCATEGORY_GENERAL, ISC_FALSE, 0, &ctx); if (ret != ISC_R_SUCCESS) { printf("contextcreate(%u) returned: %s\n", dst_key_alg(key), isc_result_totext(ret)); @@ -214,7 +214,7 @@ generate(int alg, isc_mem_t *mctx) { dst_key_t *key = NULL; ret = dst_key_generate(dns_rootname, alg, 512, 0, 0, 0, - dns_rdataclass_in, mctx, &key); + dns_rdataclass_in, mctx, &key, NULL); printf("generate(%d) returned: %s\n", alg, isc_result_totext(ret)); if (ret != ISC_R_SUCCESS) return; @@ -254,7 +254,8 @@ main(void) { result = isc_entropy_createfilesource(ectx, "randomfile"); if (result != ISC_R_SUCCESS) return (1); - dst_lib_init(mctx, ectx, ISC_ENTROPY_BLOCKING|ISC_ENTROPY_GOODONLY); + dst_lib_init(mctx, ectx, NULL, + ISC_ENTROPY_BLOCKING|ISC_ENTROPY_GOODONLY); dns_fixedname_init(&fname); name = dns_fixedname_name(&fname); diff --git a/bin/tests/optional/gsstest.c b/bin/tests/optional/gsstest.c index 7b4ddddf6b..74ff400808 100644 --- a/bin/tests/optional/gsstest.c +++ b/bin/tests/optional/gsstest.c @@ -475,7 +475,7 @@ main(int argc, char *argv[]) { RUNCHECK(isc_entropy_create(mctx, &ectx)); RUNCHECK(isc_entropy_createfilesource(ectx, "/dev/urandom")); - RUNCHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_GOODONLY)); + RUNCHECK(dst_lib_init(mctx, ectx, NULL, ISC_ENTROPY_GOODONLY)); taskmgr = NULL; RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr)); diff --git a/bin/tests/optional/sig0_test.c b/bin/tests/optional/sig0_test.c index b64e1ada2d..a8db222ba4 100644 --- a/bin/tests/optional/sig0_test.c +++ b/bin/tests/optional/sig0_test.c @@ -225,7 +225,7 @@ main(int argc, char *argv[]) { } RUNTIME_CHECK(isc_entropy_create(mctx, &ent) == ISC_R_SUCCESS); - RUNTIME_CHECK(dst_lib_init(mctx, ent, 0) == ISC_R_SUCCESS); + RUNTIME_CHECK(dst_lib_init(mctx, ent, NULL, 0) == ISC_R_SUCCESS); dns_result_register(); dst_result_register(); diff --git a/bin/tests/system/pipelined/pipequeries.c b/bin/tests/system/pipelined/pipequeries.c index c6801d32be..0a042fbcf5 100644 --- a/bin/tests/system/pipelined/pipequeries.c +++ b/bin/tests/system/pipelined/pipequeries.c @@ -286,7 +286,7 @@ main(int argc, char *argv[]) { if (randomfile != NULL) RUNCHECK(isc_entropy_createfilesource(ectx, randomfile)); - RUNCHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_GOODONLY)); + RUNCHECK(dst_lib_init(mctx, ectx, NULL, ISC_ENTROPY_GOODONLY)); taskmgr = NULL; RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr)); diff --git a/bin/tests/system/rsabigexponent/bigkey.c b/bin/tests/system/rsabigexponent/bigkey.c index ba87fbeca2..0100c39f0a 100644 --- a/bin/tests/system/rsabigexponent/bigkey.c +++ b/bin/tests/system/rsabigexponent/bigkey.c @@ -192,7 +192,7 @@ main(int argc, char **argv) { "../random.data", ISC_ENTROPY_KEYBOARDNO), "isc_entropy_usebestsource(\"../random.data\")"); - CHECK(dst_lib_init2(mctx, ectx, NULL, 0), "dst_lib_init2()"); + CHECK(dst_lib_init(mctx, ectx, NULL, 0), "dst_lib_init()"); CHECK(isc_log_create(mctx, &log_, &logconfig), "isc_log_create()"); isc_log_setcontext(log_); dns_log_init(log_); diff --git a/bin/tests/system/tkey/keycreate.c b/bin/tests/system/tkey/keycreate.c index ea41bc3bdf..4bbc721aa1 100644 --- a/bin/tests/system/tkey/keycreate.c +++ b/bin/tests/system/tkey/keycreate.c @@ -264,7 +264,7 @@ main(int argc, char *argv[]) { logconfig = NULL; RUNCHECK(isc_log_create(mctx, &log, &logconfig)); - RUNCHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_GOODONLY)); + RUNCHECK(dst_lib_init(mctx, ectx, NULL, ISC_ENTROPY_GOODONLY)); taskmgr = NULL; RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr)); diff --git a/bin/tests/system/tkey/keydelete.c b/bin/tests/system/tkey/keydelete.c index 931e77f496..b49c1711fb 100644 --- a/bin/tests/system/tkey/keydelete.c +++ b/bin/tests/system/tkey/keydelete.c @@ -195,7 +195,7 @@ main(int argc, char **argv) { logconfig = NULL; RUNCHECK(isc_log_create(mctx, &log, &logconfig)); - RUNCHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_GOODONLY)); + RUNCHECK(dst_lib_init(mctx, ectx, NULL, ISC_ENTROPY_GOODONLY)); taskmgr = NULL; RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr)); diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index e615243ca9..82bb5c2d58 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -1934,7 +1934,7 @@ main(int argc, char *argv[]) { ectx = NULL; RUNCHECK(isc_entropy_create(mctx, &ectx)); - RUNCHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_GOODONLY)); + RUNCHECK(dst_lib_init(mctx, ectx, NULL, ISC_ENTROPY_GOODONLY)); RUNCHECK(isc_entropy_getdata(ectx, cookie_secret, sizeof(cookie_secret), NULL, 0)); diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index dd1e75bdef..6628177f63 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -268,8 +268,8 @@ dns_dnssec_sign(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, if (ret != ISC_R_SUCCESS) goto cleanup_databuf; - ret = dst_context_create3(key, mctx, - DNS_LOGCATEGORY_DNSSEC, ISC_TRUE, &ctx); + ret = dst_context_create(key, mctx, + DNS_LOGCATEGORY_DNSSEC, ISC_TRUE, 0, &ctx); if (ret != ISC_R_SUCCESS) goto cleanup_databuf; @@ -455,8 +455,8 @@ dns_dnssec_verify(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, } again: - ret = dst_context_create4(key, mctx, DNS_LOGCATEGORY_DNSSEC, - ISC_FALSE, maxbits, &ctx); + ret = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, + ISC_FALSE, maxbits, &ctx); if (ret != ISC_R_SUCCESS) goto cleanup_struct; @@ -919,8 +919,8 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) { isc_buffer_init(&databuf, data, sizeof(data)); - RETERR(dst_context_create3(key, mctx, - DNS_LOGCATEGORY_DNSSEC, ISC_TRUE, &ctx)); + RETERR(dst_context_create(key, mctx, + DNS_LOGCATEGORY_DNSSEC, ISC_TRUE, 0, &ctx)); /* * Digest the fields of the SIG - we can cheat and use @@ -1068,8 +1068,8 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg, goto failure; } - RETERR(dst_context_create3(key, mctx, - DNS_LOGCATEGORY_DNSSEC, ISC_FALSE, &ctx)); + RETERR(dst_context_create(key, mctx, + DNS_LOGCATEGORY_DNSSEC, ISC_FALSE, 0, &ctx)); /* * Digest the SIG(0) record, except for the signature. diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index eb304157ec..97340bcad2 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -148,13 +148,8 @@ default_memfree(void *arg, void *ptr) { #endif isc_result_t -dst_lib_init(isc_mem_t *mctx, isc_entropy_t *ectx, unsigned int eflags) { - return (dst_lib_init2(mctx, ectx, NULL, eflags)); -} - -isc_result_t -dst_lib_init2(isc_mem_t *mctx, isc_entropy_t *ectx, - const char *engine, unsigned int eflags) { +dst_lib_init(isc_mem_t *mctx, isc_entropy_t *ectx, + const char *engine, unsigned int eflags) { isc_result_t result; REQUIRE(mctx != NULL); @@ -339,31 +334,9 @@ dst_ds_digest_supported(unsigned int digest_type) { } isc_result_t -dst_context_create(dst_key_t *key, isc_mem_t *mctx, dst_context_t **dctxp) { - return (dst_context_create4(key, mctx, DNS_LOGCATEGORY_GENERAL, - ISC_TRUE, 0, dctxp)); -} - -isc_result_t -dst_context_create2(dst_key_t *key, isc_mem_t *mctx, - isc_logcategory_t *category, dst_context_t **dctxp) -{ - return (dst_context_create4(key, mctx, category, ISC_TRUE, 0, dctxp)); -} - -isc_result_t -dst_context_create3(dst_key_t *key, isc_mem_t *mctx, - isc_logcategory_t *category, isc_boolean_t useforsigning, - dst_context_t **dctxp) -{ - return (dst_context_create4(key, mctx, category, - useforsigning, 0, dctxp)); -} - -isc_result_t -dst_context_create4(dst_key_t *key, isc_mem_t *mctx, - isc_logcategory_t *category, isc_boolean_t useforsigning, - int maxbits, dst_context_t **dctxp) +dst_context_create(dst_key_t *key, isc_mem_t *mctx, + isc_logcategory_t *category, isc_boolean_t useforsigning, + int maxbits, dst_context_t **dctxp) { dst_context_t *dctx; isc_result_t result; @@ -983,19 +956,8 @@ dst_key_generate(const dns_name_t *name, unsigned int alg, unsigned int bits, unsigned int param, unsigned int flags, unsigned int protocol, dns_rdataclass_t rdclass, - isc_mem_t *mctx, dst_key_t **keyp) -{ - return (dst_key_generate2(name, alg, bits, param, flags, protocol, - rdclass, mctx, keyp, NULL)); -} - -isc_result_t -dst_key_generate2(const dns_name_t *name, unsigned int alg, - unsigned int bits, unsigned int param, - unsigned int flags, unsigned int protocol, - dns_rdataclass_t rdclass, - isc_mem_t *mctx, dst_key_t **keyp, - void (*callback)(int)) + isc_mem_t *mctx, dst_key_t **keyp, + void (*callback)(int)) { dst_key_t *key; isc_result_t ret; diff --git a/lib/dns/include/dns/xfrin.h b/lib/dns/include/dns/xfrin.h index 4edc9ffd48..18d918cb41 100644 --- a/lib/dns/include/dns/xfrin.h +++ b/lib/dns/include/dns/xfrin.h @@ -46,31 +46,14 @@ typedef struct dns_xfrin_ctx dns_xfrin_ctx_t; ISC_LANG_BEGINDECLS -/*% see dns_xfrin_create2() */ isc_result_t dns_xfrin_create(dns_zone_t *zone, dns_rdatatype_t xfrtype, - const isc_sockaddr_t *masteraddr, dns_tsigkey_t *tsigkey, - isc_mem_t *mctx, isc_timermgr_t *timermgr, - isc_socketmgr_t *socketmgr, isc_task_t *task, - dns_xfrindone_t done, dns_xfrin_ctx_t **xfrp); - -isc_result_t -dns_xfrin_create2(dns_zone_t *zone, dns_rdatatype_t xfrtype, - const isc_sockaddr_t *masteraddr, - const isc_sockaddr_t *sourceaddr, - dns_tsigkey_t *tsigkey, isc_mem_t *mctx, - isc_timermgr_t *timermgr, isc_socketmgr_t *socketmgr, - isc_task_t *task, dns_xfrindone_t done, - dns_xfrin_ctx_t **xfrp); - -isc_result_t -dns_xfrin_create3(dns_zone_t *zone, dns_rdatatype_t xfrtype, - const isc_sockaddr_t *masteraddr, - const isc_sockaddr_t *sourceaddr, - isc_dscp_t dscp, dns_tsigkey_t *tsigkey, isc_mem_t *mctx, - isc_timermgr_t *timermgr, isc_socketmgr_t *socketmgr, - isc_task_t *task, dns_xfrindone_t done, - dns_xfrin_ctx_t **xfrp); + const isc_sockaddr_t *masteraddr, + const isc_sockaddr_t *sourceaddr, + isc_dscp_t dscp, dns_tsigkey_t *tsigkey, isc_mem_t *mctx, + isc_timermgr_t *timermgr, isc_socketmgr_t *socketmgr, + isc_task_t *task, dns_xfrindone_t done, + dns_xfrin_ctx_t **xfrp); /*%< * Attempt to start an incoming zone transfer of 'zone' * from 'masteraddr', creating a dns_xfrin_ctx_t object to diff --git a/lib/dns/include/dst/dst.h b/lib/dns/include/dst/dst.h index 53baf0bcdf..2053ff8264 100644 --- a/lib/dns/include/dst/dst.h +++ b/lib/dns/include/dst/dst.h @@ -128,13 +128,9 @@ typedef struct dst_context dst_context_t; /*** *** Functions ***/ - isc_result_t -dst_lib_init(isc_mem_t *mctx, isc_entropy_t *ectx, unsigned int eflags); - -isc_result_t -dst_lib_init2(isc_mem_t *mctx, isc_entropy_t *ectx, - const char *engine, unsigned int eflags); +dst_lib_init(isc_mem_t *mctx, isc_entropy_t *ectx, + const char *engine, unsigned int eflags); /*%< * Initializes the DST subsystem. * @@ -196,21 +192,9 @@ dst_ds_digest_supported(unsigned int digest_type); */ isc_result_t -dst_context_create(dst_key_t *key, isc_mem_t *mctx, dst_context_t **dctxp); - -isc_result_t -dst_context_create2(dst_key_t *key, isc_mem_t *mctx, - isc_logcategory_t *category, dst_context_t **dctxp); - -isc_result_t -dst_context_create3(dst_key_t *key, isc_mem_t *mctx, - isc_logcategory_t *category, isc_boolean_t useforsigning, - dst_context_t **dctxp); - -isc_result_t -dst_context_create4(dst_key_t *key, isc_mem_t *mctx, - isc_logcategory_t *category, isc_boolean_t useforsigning, - int maxbits, dst_context_t **dctxp); +dst_context_create(dst_key_t *key, isc_mem_t *mctx, + isc_logcategory_t *category, isc_boolean_t useforsigning, + int maxbits, dst_context_t **dctxp); /*%< * Creates a context to be used for a sign or verify operation. * @@ -583,15 +567,8 @@ dst_key_generate(const dns_name_t *name, unsigned int alg, unsigned int bits, unsigned int param, unsigned int flags, unsigned int protocol, dns_rdataclass_t rdclass, - isc_mem_t *mctx, dst_key_t **keyp); - -isc_result_t -dst_key_generate2(const dns_name_t *name, unsigned int alg, - unsigned int bits, unsigned int param, - unsigned int flags, unsigned int protocol, - dns_rdataclass_t rdclass, - isc_mem_t *mctx, dst_key_t **keyp, - void (*callback)(int)); + isc_mem_t *mctx, dst_key_t **keyp, + void (*callback)(int)); /*%< * Generate a DST key (or keypair) with the supplied parameters. The diff --git a/lib/dns/lib.c b/lib/dns/lib.c index 20aabc9a80..887851141f 100644 --- a/lib/dns/lib.c +++ b/lib/dns/lib.c @@ -91,7 +91,7 @@ initialize(void) { if (result != ISC_R_SUCCESS) goto cleanup_db; - result = dst_lib_init(dns_g_mctx, ectx, 0); + result = dst_lib_init(dns_g_mctx, ectx, NULL, 0); if (result != ISC_R_SUCCESS) goto cleanup_ectx; diff --git a/lib/dns/tests/dnstest.c b/lib/dns/tests/dnstest.c index ef6d1844c0..b672b50f61 100644 --- a/lib/dns/tests/dnstest.c +++ b/lib/dns/tests/dnstest.c @@ -120,7 +120,7 @@ dns_test_begin(FILE *logfile, isc_boolean_t start_managers) { CHECK(isc_mem_create(0, 0, &mctx)); CHECK(isc_entropy_create(mctx, &ectx)); - CHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_BLOCKING)); + CHECK(dst_lib_init(mctx, ectx, NULL, ISC_ENTROPY_BLOCKING)); dst_active = ISC_TRUE; if (logfile != NULL) { diff --git a/lib/dns/tests/dst_test.c b/lib/dns/tests/dst_test.c index 284249b65f..397381bb60 100644 --- a/lib/dns/tests/dst_test.c +++ b/lib/dns/tests/dst_test.c @@ -177,8 +177,8 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname, */ isc_buffer_remainingregion(&sigbuf, &sigreg); - result = dst_context_create3(key, mctx, DNS_LOGCATEGORY_GENERAL, - ISC_FALSE, &ctx); + result = dst_context_create(key, mctx, DNS_LOGCATEGORY_GENERAL, + ISC_FALSE, 0, &ctx); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = dst_context_adddata(ctx, &datareg); diff --git a/lib/dns/tests/dstrandom_test.c b/lib/dns/tests/dstrandom_test.c index 58577153e6..55d1de66a3 100644 --- a/lib/dns/tests/dstrandom_test.c +++ b/lib/dns/tests/dstrandom_test.c @@ -48,7 +48,7 @@ ATF_TC_BODY(isc_entropy_getdata, tc) { ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = isc_entropy_create(mctx, &ectx); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - result = dst_lib_init(mctx, ectx, 0); + result = dst_lib_init(mctx, ectx, NULL, 0); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); #ifdef ISC_PLATFORM_CRYPTORANDOM diff --git a/lib/dns/tests/rsa_test.c b/lib/dns/tests/rsa_test.c index a700b5e18f..fb9a035460 100644 --- a/lib/dns/tests/rsa_test.c +++ b/lib/dns/tests/rsa_test.c @@ -208,8 +208,8 @@ ATF_TC_BODY(isc_rsa_verify, tc) { /* RSASHA1 */ - ret = dst_context_create3(key, mctx, DNS_LOGCATEGORY_DNSSEC, - ISC_FALSE, &ctx); + ret = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, + ISC_FALSE, 0, &ctx); ATF_REQUIRE_EQ(ret, ISC_R_SUCCESS); r.base = d; @@ -229,8 +229,8 @@ ATF_TC_BODY(isc_rsa_verify, tc) { #ifndef PK11_MD5_DISABLE key->key_alg = DST_ALG_RSAMD5; - ret = dst_context_create3(key, mctx, DNS_LOGCATEGORY_DNSSEC, - ISC_FALSE, &ctx); + ret = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, + ISC_FALSE, 0, &ctx); ATF_REQUIRE_EQ(ret, ISC_R_SUCCESS); r.base = d; @@ -250,8 +250,8 @@ ATF_TC_BODY(isc_rsa_verify, tc) { key->key_alg = DST_ALG_RSASHA256; - ret = dst_context_create3(key, mctx, DNS_LOGCATEGORY_DNSSEC, - ISC_FALSE, &ctx); + ret = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, + ISC_FALSE, 0, &ctx); ATF_REQUIRE_EQ(ret, ISC_R_SUCCESS); r.base = d; @@ -270,8 +270,8 @@ ATF_TC_BODY(isc_rsa_verify, tc) { key->key_alg = DST_ALG_RSASHA512; - ret = dst_context_create3(key, mctx, DNS_LOGCATEGORY_DNSSEC, - ISC_FALSE, &ctx); + ret = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, + ISC_FALSE, 0, &ctx); ATF_REQUIRE_EQ(ret, ISC_R_SUCCESS); r.base = d; diff --git a/lib/dns/tests/tsig_test.c b/lib/dns/tests/tsig_test.c index 490eb0b73e..7ac73676df 100644 --- a/lib/dns/tests/tsig_test.c +++ b/lib/dns/tests/tsig_test.c @@ -357,8 +357,8 @@ ATF_TC_BODY(tsig_tcp, tc) { isc_buffer_free(&buf); dns_message_destroy(&msg); - result = dst_context_create3(key->key, mctx, DNS_LOGCATEGORY_DNSSEC, - ISC_FALSE, &outctx); + result = dst_context_create(key->key, mctx, DNS_LOGCATEGORY_DNSSEC, + ISC_FALSE, 0, &outctx); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); ATF_REQUIRE(outctx != NULL); diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index 0310958e1c..758b81dc54 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -850,9 +850,9 @@ dns_tsig_sign(dns_message_t *msg) { * has validated at this point. This is why we include a * MAC length > 0 in the reply. */ - ret = dst_context_create3(key->key, mctx, - DNS_LOGCATEGORY_DNSSEC, - ISC_TRUE, &ctx); + ret = dst_context_create(key->key, mctx, + DNS_LOGCATEGORY_DNSSEC, + ISC_TRUE, 0, &ctx); if (ret != ISC_R_SUCCESS) return (ret); @@ -1235,9 +1235,9 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg, sig_r.base = tsig.signature; sig_r.length = tsig.siglen; - ret = dst_context_create3(key, mctx, - DNS_LOGCATEGORY_DNSSEC, - ISC_FALSE, &ctx); + ret = dst_context_create(key, mctx, + DNS_LOGCATEGORY_DNSSEC, + ISC_FALSE, 0, &ctx); if (ret != ISC_R_SUCCESS) return (ret); @@ -1531,9 +1531,9 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) { } if (msg->tsigctx == NULL) { - ret = dst_context_create3(key, mctx, - DNS_LOGCATEGORY_DNSSEC, - ISC_FALSE, &msg->tsigctx); + ret = dst_context_create(key, mctx, + DNS_LOGCATEGORY_DNSSEC, + ISC_FALSE, 0, &msg->tsigctx); if (ret != ISC_R_SUCCESS) goto cleanup_querystruct; diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 4314c0154d..2ad2be8ce2 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -1109,8 +1109,6 @@ dns_viewlist_find dns_viewlist_findzone dns_xfrin_attach dns_xfrin_create -dns_xfrin_create2 -dns_xfrin_create3 dns_xfrin_detach dns_xfrin_shutdown dns_zone_addnsec3chain @@ -1357,9 +1355,6 @@ dns_zt_unmount dst_algorithm_supported dst_context_adddata dst_context_create -dst_context_create2 -dst_context_create3 -dst_context_create4 dst_context_destroy dst_context_sign dst_context_verify @@ -1390,7 +1385,6 @@ dst_key_fromgssapi dst_key_fromlabel dst_key_fromnamedfile dst_key_generate -dst_key_generate2 dst_key_getbits dst_key_getfilename dst_key_getgssctx @@ -1431,7 +1425,6 @@ dst_key_unsetnum dst_key_unsettime dst_lib_destroy dst_lib_init -dst_lib_init2 dst_lib_initmsgcat @IF PKCS11 dst_random_getdata diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 162987100e..8e192ace10 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -630,54 +630,12 @@ xfr_rr(dns_xfrin_ctx_t *xfr, dns_name_t *name, isc_uint32_t ttl, isc_result_t dns_xfrin_create(dns_zone_t *zone, dns_rdatatype_t xfrtype, - const isc_sockaddr_t *masteraddr, dns_tsigkey_t *tsigkey, - isc_mem_t *mctx, isc_timermgr_t *timermgr, - isc_socketmgr_t *socketmgr, isc_task_t *task, - dns_xfrindone_t done, dns_xfrin_ctx_t **xfrp) -{ - isc_sockaddr_t sourceaddr; - isc_dscp_t dscp; - - switch (isc_sockaddr_pf(masteraddr)) { - case PF_INET: - sourceaddr = *dns_zone_getxfrsource4(zone); - dscp = dns_zone_getxfrsource4dscp(zone); - break; - case PF_INET6: - sourceaddr = *dns_zone_getxfrsource6(zone); - dscp = dns_zone_getxfrsource6dscp(zone); - break; - default: - INSIST(0); - } - - return(dns_xfrin_create3(zone, xfrtype, masteraddr, &sourceaddr, - dscp, tsigkey, mctx, timermgr, socketmgr, - task, done, xfrp)); -} - -isc_result_t -dns_xfrin_create2(dns_zone_t *zone, dns_rdatatype_t xfrtype, - const isc_sockaddr_t *masteraddr, - const isc_sockaddr_t *sourceaddr, - dns_tsigkey_t *tsigkey, isc_mem_t *mctx, - isc_timermgr_t *timermgr, isc_socketmgr_t *socketmgr, - isc_task_t *task, dns_xfrindone_t done, - dns_xfrin_ctx_t **xfrp) -{ - return (dns_xfrin_create3(zone, xfrtype, masteraddr, sourceaddr, -1, - tsigkey, mctx, timermgr, socketmgr, task, - done, xfrp)); -} - -isc_result_t -dns_xfrin_create3(dns_zone_t *zone, dns_rdatatype_t xfrtype, - const isc_sockaddr_t *masteraddr, - const isc_sockaddr_t *sourceaddr, - isc_dscp_t dscp, dns_tsigkey_t *tsigkey, isc_mem_t *mctx, - isc_timermgr_t *timermgr, isc_socketmgr_t *socketmgr, - isc_task_t *task, dns_xfrindone_t done, - dns_xfrin_ctx_t **xfrp) + const isc_sockaddr_t *masteraddr, + const isc_sockaddr_t *sourceaddr, + isc_dscp_t dscp, dns_tsigkey_t *tsigkey, isc_mem_t *mctx, + isc_timermgr_t *timermgr, isc_socketmgr_t *socketmgr, + isc_task_t *task, dns_xfrindone_t done, + dns_xfrin_ctx_t **xfrp) { dns_name_t *zonename = dns_zone_getorigin(zone); dns_xfrin_ctx_t *xfr = NULL; diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 8edc8ae022..b02da3b3b2 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -15546,10 +15546,10 @@ got_transfer_quota(isc_task_t *task, isc_event_t *event) { }; UNLOCK_ZONE(zone); INSIST(isc_sockaddr_pf(&masteraddr) == isc_sockaddr_pf(&sourceaddr)); - result = dns_xfrin_create3(zone, xfrtype, &masteraddr, &sourceaddr, - dscp, zone->tsigkey, zone->mctx, - zone->zmgr->timermgr, zone->zmgr->socketmgr, - zone->task, zone_xfrdone, &zone->xfr); + result = dns_xfrin_create(zone, xfrtype, &masteraddr, &sourceaddr, + dscp, zone->tsigkey, zone->mctx, + zone->zmgr->timermgr, zone->zmgr->socketmgr, + zone->task, zone_xfrdone, &zone->xfr); if (result == ISC_R_SUCCESS) { LOCK_ZONE(zone); if (xfrtype == dns_rdatatype_axfr) { diff --git a/lib/ns/tests/nstest.c b/lib/ns/tests/nstest.c index c63cea62b0..ce43815272 100644 --- a/lib/ns/tests/nstest.c +++ b/lib/ns/tests/nstest.c @@ -245,7 +245,7 @@ ns_test_begin(FILE *logfile, isc_boolean_t start_managers) { CHECK(isc_mem_create(0, 0, &mctx)); CHECK(isc_entropy_create(mctx, &ectx)); - CHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_BLOCKING)); + CHECK(dst_lib_init(mctx, ectx, NULL, ISC_ENTROPY_BLOCKING)); dst_active = ISC_TRUE; if (logfile != NULL) { From d54d482af0ced26484ac3860a9b90645f01719c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Wed, 4 Apr 2018 09:51:42 +0200 Subject: [PATCH 15/18] libdns refactoring: get rid of multiple versions of dns_view_find, dns_view_findzonecut and dns_view_flushcache --- bin/named/server.c | 6 ++--- lib/dns/adb.c | 18 +++++++------- lib/dns/client.c | 3 ++- lib/dns/include/dns/view.h | 25 +++++--------------- lib/dns/lookup.c | 6 ++--- lib/dns/resolver.c | 3 ++- lib/dns/validator.c | 8 +++---- lib/dns/view.c | 47 +++++++++---------------------------- lib/dns/win32/libdns.def.in | 3 --- 9 files changed, 40 insertions(+), 79 deletions(-) diff --git a/bin/named/server.c b/bin/named/server.c index 7511a680f2..789b064949 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -10877,7 +10877,7 @@ named_server_validation(named_server_t *server, isc_lex_t *lex, { if (ptr != NULL && strcasecmp(ptr, view->name) != 0) continue; - CHECK(dns_view_flushcache(view)); + CHECK(dns_view_flushcache(view, ISC_FALSE)); if (set) { view->enablevalidation = enable; @@ -10968,7 +10968,7 @@ named_server_flushcache(named_server_t *server, isc_lex_t *lex) { if (ptr != NULL && !nsc->needflush) continue; nsc->needflush = ISC_TRUE; - result = dns_view_flushcache2(nsc->primaryview, ISC_FALSE); + result = dns_view_flushcache(nsc->primaryview, ISC_FALSE); if (result != ISC_R_SUCCESS) { flushed = ISC_FALSE; isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, @@ -10999,7 +10999,7 @@ named_server_flushcache(named_server_t *server, isc_lex_t *lex) { nsc = ISC_LIST_NEXT(nsc, link)) { if (!nsc->needflush || nsc->cache != view->cache) continue; - result = dns_view_flushcache2(view, ISC_TRUE); + result = dns_view_flushcache(view, ISC_TRUE); if (result != ISC_R_SUCCESS) { flushed = ISC_FALSE; isc_log_write(named_g_lctx, diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 3c38d97a65..8dd8f319ec 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -3700,12 +3700,12 @@ dbfind_name(dns_adbname_t *adbname, isc_stdtime_t now, dns_rdatatype_t rdtype) * matching static-stub zone without looking into the cache to honor * the configuration on which server we should send queries to. */ - result = dns_view_find2(adb->view, &adbname->name, rdtype, now, - NAME_GLUEOK(adbname) ? DNS_DBFIND_GLUEOK : 0, - ISC_TF(NAME_HINTOK(adbname)), - (adbname->flags & NAME_STARTATZONE) != 0 ? - ISC_TRUE : ISC_FALSE, - NULL, NULL, fname, &rdataset, NULL); + result = dns_view_find(adb->view, &adbname->name, rdtype, now, + NAME_GLUEOK(adbname) ? DNS_DBFIND_GLUEOK : 0, + ISC_TF(NAME_HINTOK(adbname)), + (adbname->flags & NAME_STARTATZONE) != 0 ? + ISC_TRUE : ISC_FALSE, + NULL, NULL, fname, &rdataset, NULL); /* XXXVIX this switch statement is too sparse to gen a jump table. */ switch (result) { @@ -4027,9 +4027,9 @@ fetch_name(dns_adbname_t *adbname, isc_boolean_t start_at_zone, adbname); dns_fixedname_init(&fixed); name = dns_fixedname_name(&fixed); - result = dns_view_findzonecut2(adb->view, &adbname->name, name, - 0, 0, ISC_TRUE, ISC_FALSE, - &rdataset, NULL); + result = dns_view_findzonecut(adb->view, &adbname->name, name, + 0, 0, ISC_TRUE, ISC_FALSE, + &rdataset, NULL); if (result != ISC_R_SUCCESS && result != DNS_R_HINT) goto cleanup; nameservers = &rdataset; diff --git a/lib/dns/client.c b/lib/dns/client.c index 1535562ee6..2844429e2a 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -797,7 +797,8 @@ view_find(resctx_t *rctx, dns_db_t **dbp, dns_dbnode_t **nodep, type = rctx->type; result = dns_view_find(rctx->view, name, type, 0, 0, ISC_FALSE, - dbp, nodep, foundname, rctx->rdataset, + ISC_FALSE, dbp, nodep, foundname, + rctx->rdataset, rctx->sigrdataset); return (result); diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index 46cd2a777d..a28bd7b410 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -546,17 +546,13 @@ dns_view_thaw(dns_view_t *view); * *\li 'view' is no longer frozen. */ + isc_result_t dns_view_find(dns_view_t *view, const dns_name_t *name, dns_rdatatype_t type, - isc_stdtime_t now, unsigned int options, isc_boolean_t use_hints, + isc_stdtime_t now, unsigned int options, + isc_boolean_t use_hints, isc_boolean_t use_static_stub, dns_db_t **dbp, dns_dbnode_t **nodep, dns_name_t *foundname, dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset); -isc_result_t -dns_view_find2(dns_view_t *view, const dns_name_t *name, dns_rdatatype_t type, - isc_stdtime_t now, unsigned int options, - isc_boolean_t use_hints, isc_boolean_t use_static_stub, - dns_db_t **dbp, dns_dbnode_t **nodep, dns_name_t *foundname, - dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset); /*%< * Find an rdataset whose owner name is 'name', and whose type is * 'type'. @@ -703,19 +699,12 @@ dns_view_simplefind(dns_view_t *view, const dns_name_t *name, * or an error occurred. */ -/*% See dns_view_findzonecut2() */ isc_result_t dns_view_findzonecut(dns_view_t *view, const dns_name_t *name, dns_name_t *fname, isc_stdtime_t now, - unsigned int options, isc_boolean_t use_hints, + unsigned int options, + isc_boolean_t use_hints, isc_boolean_t use_cache, dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset); - -isc_result_t -dns_view_findzonecut2(dns_view_t *view, const dns_name_t *name, - dns_name_t *fname, isc_stdtime_t now, - unsigned int options, - isc_boolean_t use_hints, isc_boolean_t use_cache, - dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset); /*%< * Find the best known zonecut containing 'name'. * @@ -907,9 +896,7 @@ dns_view_dumpdbtostream(dns_view_t *view, FILE *fp); */ isc_result_t -dns_view_flushcache(dns_view_t *view); -isc_result_t -dns_view_flushcache2(dns_view_t *view, isc_boolean_t fixuponly); +dns_view_flushcache(dns_view_t *view, isc_boolean_t fixuponly); /*%< * Flush the view's cache (and ADB). If 'fixuponly' is true, it only updates * the internal reference to the cache DB with omitting actual flush operation. diff --git a/lib/dns/lookup.c b/lib/dns/lookup.c index 152ece260b..ffac55e55f 100644 --- a/lib/dns/lookup.c +++ b/lib/dns/lookup.c @@ -166,9 +166,9 @@ view_find(dns_lookup_t *lookup, dns_name_t *foundname) { type = lookup->type; result = dns_view_find(lookup->view, name, type, 0, 0, ISC_FALSE, - &lookup->event->db, &lookup->event->node, - foundname, &lookup->rdataset, - &lookup->sigrdataset); + ISC_FALSE, &lookup->event->db, + &lookup->event->node, foundname, + &lookup->rdataset, &lookup->sigrdataset); return (result); } diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index b38cff76ef..3933147791 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -4617,6 +4617,7 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type, findoptions |= DNS_DBFIND_NOEXACT; result = dns_view_findzonecut(res->view, name, fname, 0, findoptions, ISC_TRUE, + ISC_TRUE, &fctx->nameservers, NULL); if (result != ISC_R_SUCCESS) @@ -8999,7 +9000,7 @@ rctx_nextserver(respctx_t *rctx, dns_adbaddrinfo_t *addrinfo, result = dns_view_findzonecut(fctx->res->view, name, fname, rctx->now, findoptions, - ISC_TRUE, + ISC_TRUE, ISC_TRUE, &fctx->nameservers, NULL); if (result != ISC_R_SUCCESS) { diff --git a/lib/dns/validator.c b/lib/dns/validator.c index f551a11c6b..c43cf75618 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -997,7 +997,7 @@ view_find(dns_validator_t *val, dns_name_t *name, dns_rdatatype_t type) { dns_fixedname_init(&fixedname); foundname = dns_fixedname_name(&fixedname); result = dns_view_find(val->view, name, type, 0, options, - ISC_FALSE, NULL, NULL, foundname, + ISC_FALSE, ISC_FALSE, NULL, NULL, foundname, &val->frdataset, &val->fsigrdataset); if (result == DNS_R_NXDOMAIN) { @@ -3409,9 +3409,9 @@ proveunsecure(dns_validator_t *val, isc_boolean_t have_ds, isc_boolean_t resume) */ if (result == DNS_R_NXRRSET && !dns_rdataset_isassociated(&val->frdataset) && - dns_view_findzonecut2(val->view, tname, found, - 0, 0, ISC_FALSE, ISC_FALSE, - NULL, NULL) == ISC_R_SUCCESS && + dns_view_findzonecut(val->view, tname, found, + 0, 0, ISC_FALSE, ISC_FALSE, + NULL, NULL) == ISC_R_SUCCESS && dns_name_equal(tname, found)) { if (val->mustbesecure) { validator_log(val, ISC_LOG_WARNING, diff --git a/lib/dns/view.c b/lib/dns/view.c index 7a569bb26a..c96e0a2681 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -991,20 +991,10 @@ dns_view_findzone(dns_view_t *view, const dns_name_t *name, isc_result_t dns_view_find(dns_view_t *view, const dns_name_t *name, dns_rdatatype_t type, - isc_stdtime_t now, unsigned int options, isc_boolean_t use_hints, + isc_stdtime_t now, unsigned int options, + isc_boolean_t use_hints, isc_boolean_t use_static_stub, dns_db_t **dbp, dns_dbnode_t **nodep, dns_name_t *foundname, - dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset) { - return (dns_view_find2(view, name, type, now, options, use_hints, - ISC_FALSE, dbp, nodep, foundname, rdataset, - sigrdataset)); -} - -isc_result_t -dns_view_find2(dns_view_t *view, const dns_name_t *name, dns_rdatatype_t type, - isc_stdtime_t now, unsigned int options, - isc_boolean_t use_hints, isc_boolean_t use_static_stub, - dns_db_t **dbp, dns_dbnode_t **nodep, dns_name_t *foundname, - dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset) + dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset) { isc_result_t result; dns_db_t *db, *zdb; @@ -1223,8 +1213,9 @@ dns_view_simplefind(dns_view_t *view, const dns_name_t *name, dns_fixedname_init(&foundname); result = dns_view_find(view, name, type, now, options, use_hints, - NULL, NULL, dns_fixedname_name(&foundname), - rdataset, sigrdataset); + ISC_FALSE, NULL, NULL, + dns_fixedname_name(&foundname), rdataset, + sigrdataset); if (result == DNS_R_NXDOMAIN) { /* * The rdataset and sigrdataset of the relevant NSEC record @@ -1258,21 +1249,10 @@ dns_view_simplefind(dns_view_t *view, const dns_name_t *name, isc_result_t dns_view_findzonecut(dns_view_t *view, const dns_name_t *name, - dns_name_t *fname, isc_stdtime_t now, unsigned int options, - isc_boolean_t use_hints, - dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset) -{ - return(dns_view_findzonecut2(view, name, fname, now, options, - use_hints, ISC_TRUE, - rdataset, sigrdataset)); -} - -isc_result_t -dns_view_findzonecut2(dns_view_t *view, const dns_name_t *name, - dns_name_t *fname, isc_stdtime_t now, - unsigned int options, isc_boolean_t use_hints, - isc_boolean_t use_cache, dns_rdataset_t *rdataset, - dns_rdataset_t *sigrdataset) + dns_name_t *fname, isc_stdtime_t now, + unsigned int options, isc_boolean_t use_hints, + isc_boolean_t use_cache, dns_rdataset_t *rdataset, + dns_rdataset_t *sigrdataset) { isc_result_t result; dns_db_t *db; @@ -1621,12 +1601,7 @@ dns_view_dumpdbtostream(dns_view_t *view, FILE *fp) { } isc_result_t -dns_view_flushcache(dns_view_t *view) { - return (dns_view_flushcache2(view, ISC_FALSE)); -} - -isc_result_t -dns_view_flushcache2(dns_view_t *view, isc_boolean_t fixuponly) { +dns_view_flushcache(dns_view_t *view, isc_boolean_t fixuponly) { isc_result_t result; REQUIRE(DNS_VIEW_VALID(view)); diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 2ad2be8ce2..0382bdcc8c 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -1051,13 +1051,10 @@ dns_view_dialup dns_view_dumpdbtostream dns_view_excludedelegationonly dns_view_find -dns_view_find2 dns_view_findzone dns_view_findzonecut -dns_view_findzonecut2 dns_view_flushanddetach dns_view_flushcache -dns_view_flushcache2 dns_view_flushname dns_view_flushnode dns_view_freeze From c8aa1ee9e6d763a1da577e2bab22d80c58c23ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Thu, 5 Apr 2018 16:27:36 +0200 Subject: [PATCH 16/18] 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 --- bin/named/server.c | 8 ++--- bin/named/statschannel.c | 8 +++-- bin/tests/optional/adb_test.c | 2 +- bin/tests/optional/byaddr_test.c | 2 +- bin/tests/optional/byname_test.c | 2 +- contrib/sdb/bdb/zone2bdb.c | 2 +- lib/dns/dnstap.c | 11 ++----- lib/dns/include/dns/dnstap.h | 8 ++--- lib/dns/include/dns/message.h | 16 +++------ lib/dns/include/dns/ssu.h | 4 --- lib/dns/include/dns/ttl.h | 5 +-- lib/dns/include/dns/view.h | 4 +-- lib/dns/include/dns/zt.h | 6 +--- lib/dns/masterdump.c | 5 +-- lib/dns/message.c | 31 ++++-------------- lib/dns/rdata/generic/soa_6.c | 3 +- lib/dns/resolver.c | 56 ++++++++++++++++---------------- lib/dns/ssu.c | 14 ++------ lib/dns/tests/dnstap_test.c | 8 ++--- lib/dns/tests/zt_test.c | 3 +- lib/dns/ttl.c | 9 ++--- lib/dns/view.c | 9 ++--- lib/dns/win32/libdns.def.in | 7 ---- lib/dns/xfrin.c | 10 +++--- lib/dns/zt.c | 19 ++++------- lib/ns/tests/nstest.c | 2 +- lib/ns/update.c | 16 ++++----- 27 files changed, 96 insertions(+), 174 deletions(-) diff --git a/bin/named/server.c b/bin/named/server.c index 789b064949..515127dbc5 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -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; diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index 0080ead9c0..760aaa7952 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -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; } diff --git a/bin/tests/optional/adb_test.c b/bin/tests/optional/adb_test.c index 0d6995d9c3..2dfaa09a8c 100644 --- a/bin/tests/optional/adb_test.c +++ b/bin/tests/optional/adb_test.c @@ -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); { diff --git a/bin/tests/optional/byaddr_test.c b/bin/tests/optional/byaddr_test.c index 7d95c05bb5..8089942d20 100644 --- a/bin/tests/optional/byaddr_test.c +++ b/bin/tests/optional/byaddr_test.c @@ -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); diff --git a/bin/tests/optional/byname_test.c b/bin/tests/optional/byname_test.c index 89c9a263dd..384e5b01da 100644 --- a/bin/tests/optional/byname_test.c +++ b/bin/tests/optional/byname_test.c @@ -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); diff --git a/contrib/sdb/bdb/zone2bdb.c b/contrib/sdb/bdb/zone2bdb.c index 1d92804b65..7db731eb8a 100644 --- a/contrib/sdb/bdb/zone2bdb.c +++ b/contrib/sdb/bdb/zone2bdb.c @@ -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); diff --git a/lib/dns/dnstap.c b/lib/dns/dnstap.c index 54ae1e9cd9..35b325f207 100644 --- a/lib/dns/dnstap.c +++ b/lib/dns/dnstap.c @@ -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; diff --git a/lib/dns/include/dns/dnstap.h b/lib/dns/include/dns/dnstap.h index 54d3f9474e..a37ed1a74c 100644 --- a/lib/dns/include/dns/dnstap.h +++ b/lib/dns/include/dns/dnstap.h @@ -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. * diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index 58839cfd29..3d8493e409 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -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. * diff --git a/lib/dns/include/dns/ssu.h b/lib/dns/include/dns/ssu.h index 281ca2f2e0..ed7f61e3d0 100644 --- a/lib/dns/include/dns/ssu.h +++ b/lib/dns/include/dns/ssu.h @@ -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); diff --git a/lib/dns/include/dns/ttl.h b/lib/dns/include/dns/ttl.h index 887f4cb583..ea26d09ebd 100644 --- a/lib/dns/include/dns/ttl.h +++ b/lib/dns/include/dns/ttl.h @@ -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'. diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index a28bd7b410..df49832e5d 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -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() diff --git a/lib/dns/include/dns/zt.h b/lib/dns/include/dns/zt.h index 0af2a1aee3..1194a9ac97 100644 --- a/lib/dns/include/dns/zt.h +++ b/lib/dns/include/dns/zt.h @@ -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 diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 6fd0d29a40..28dad9061a 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -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, diff --git a/lib/dns/message.c b/lib/dns/message.c index e3f2858e33..cb1aaa1b1e 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -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); diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index 25f5e100d1..3ab5f5ec04 100644 --- a/lib/dns/rdata/generic/soa_6.c +++ b/lib/dns/rdata/generic/soa_6.c @@ -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)); diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 3933147791..d8a83e4e58 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -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 /* diff --git a/lib/dns/ssu.c b/lib/dns/ssu.c index 2fc9c61435..12894068dd 100644 --- a/lib/dns/ssu.c +++ b/lib/dns/ssu.c @@ -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; diff --git a/lib/dns/tests/dnstap_test.c b/lib/dns/tests/dnstap_test.c index 9f9f09c297..c21a28aedc 100644 --- a/lib/dns/tests/dnstap_test.c +++ b/lib/dns/tests/dnstap_test.c @@ -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); diff --git a/lib/dns/tests/zt_test.c b/lib/dns/tests/zt_test.c index bf3b96bbc4..6fed4a4769 100644 --- a/lib/dns/tests/zt_test.c +++ b/lib/dns/tests/zt_test.c @@ -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); diff --git a/lib/dns/ttl.c b/lib/dns/ttl.c index 1f75daf333..557058ea16 100644 --- a/lib/dns/ttl.c +++ b/lib/dns/ttl.c @@ -72,13 +72,8 @@ ttlfmt(unsigned int t, const char *s, isc_boolean_t verbose, * Derived from bind8 ns_format_ttl(). */ isc_result_t -dns_ttl_totext(isc_uint32_t src, isc_boolean_t verbose, isc_buffer_t *target) { - return (dns_ttl_totext2(src, verbose, ISC_TRUE, target)); -} - -isc_result_t -dns_ttl_totext2(isc_uint32_t src, isc_boolean_t verbose, - isc_boolean_t upcase, isc_buffer_t *target) +dns_ttl_totext(isc_uint32_t src, isc_boolean_t verbose, + isc_boolean_t upcase, isc_buffer_t *target) { unsigned secs, mins, hours, days, weeks, x; diff --git a/lib/dns/view.c b/lib/dns/view.c index c96e0a2681..f5409cbbab 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -652,7 +652,7 @@ dns_view_dialup(dns_view_t *view) { REQUIRE(DNS_VIEW_VALID(view)); REQUIRE(view->zonetable != NULL); - (void)dns_zt_apply(view->zonetable, ISC_FALSE, dialup, NULL); + (void)dns_zt_apply(view->zonetable, ISC_FALSE, NULL, dialup, NULL); } void @@ -845,12 +845,7 @@ dns_view_createresolver(dns_view_t *view, } void -dns_view_setcache(dns_view_t *view, dns_cache_t *cache) { - dns_view_setcache2(view, cache, ISC_FALSE); -} - -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) { REQUIRE(DNS_VIEW_VALID(view)); REQUIRE(!view->frozen); diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 0382bdcc8c..f81efeff9c 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -339,7 +339,6 @@ dns_dsdigest_totext dns_dt_attach dns_dt_close dns_dt_create -dns_dt_create2 dns_dt_datatotext dns_dt_detach dns_dt_getframe @@ -496,9 +495,7 @@ dns_message_gettimeadjust dns_message_gettsig dns_message_gettsigkey dns_message_logfmtpacket -dns_message_logfmtpacket2 dns_message_logpacket -dns_message_logpacket2 dns_message_movename dns_message_nextname dns_message_parse @@ -978,7 +975,6 @@ dns_ssu_mtypefromstring dns_ssutable_addrule dns_ssutable_attach dns_ssutable_checkrules -dns_ssutable_checkrules2 dns_ssutable_create dns_ssutable_createdlz dns_ssutable_detach @@ -1030,7 +1026,6 @@ dns_tsigrcode_fromtext dns_tsigrcode_totext dns_ttl_fromtext dns_ttl_totext -dns_ttl_totext2 dns_update_signatures dns_update_signaturesinc dns_update_soaserial @@ -1084,7 +1079,6 @@ dns_view_saventa dns_view_searchdlz dns_view_setadbstats dns_view_setcache -dns_view_setcache2 dns_view_setdstport dns_view_setdynamickeyring dns_view_setfailttl @@ -1335,7 +1329,6 @@ dns_zonemgr_unreachable dns_zonemgr_unreachableadd dns_zonemgr_unreachabledel dns_zt_apply -dns_zt_apply2 dns_zt_asyncload dns_zt_attach dns_zt_create diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 8e192ace10..0a970da201 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -1234,11 +1234,11 @@ xfrin_recv_done(isc_task_t *task, isc_event_t *ev) { DNS_MESSAGEPARSE_PRESERVEORDER); if (result == ISC_R_SUCCESS) - dns_message_logpacket2(msg, "received message from", - &tcpmsg->address, - DNS_LOGCATEGORY_XFER_IN, - DNS_LOGMODULE_XFER_IN, - ISC_LOG_DEBUG(10), xfr->mctx); + dns_message_logpacket(msg, "received message from", + &tcpmsg->address, + DNS_LOGCATEGORY_XFER_IN, + DNS_LOGMODULE_XFER_IN, + ISC_LOG_DEBUG(10), xfr->mctx); else xfrin_log(xfr, ISC_LOG_DEBUG(10), "dns_message_parse: %s", dns_result_totext(result)); diff --git a/lib/dns/zt.c b/lib/dns/zt.c index 830deb51be..42787f5fca 100644 --- a/lib/dns/zt.c +++ b/lib/dns/zt.c @@ -199,7 +199,7 @@ flush(dns_zone_t *zone, void *uap) { static void zt_destroy(dns_zt_t *zt) { if (zt->flush) - (void)dns_zt_apply(zt, ISC_FALSE, flush, NULL); + (void)dns_zt_apply(zt, ISC_FALSE, NULL, flush, NULL); dns_rbt_destroy(&zt->table); isc_rwlock_destroy(&zt->rwlock); zt->magic = 0; @@ -249,7 +249,7 @@ dns_zt_load(dns_zt_t *zt, isc_boolean_t stop) { REQUIRE(VALID_ZT(zt)); RWLOCK(&zt->rwlock, isc_rwlocktype_read); - result = dns_zt_apply(zt, stop, load, NULL); + result = dns_zt_apply(zt, stop, NULL, load, NULL); RWUNLOCK(&zt->rwlock, isc_rwlocktype_read); return (result); } @@ -277,7 +277,7 @@ dns_zt_asyncload(dns_zt_t *zt, dns_zt_allloaded_t alldone, void *arg) { RWLOCK(&zt->rwlock, isc_rwlocktype_write); INSIST(zt->loads_pending == 0); - result = dns_zt_apply2(zt, ISC_FALSE, NULL, asyncload, &dl); + result = dns_zt_apply(zt, ISC_FALSE, NULL, asyncload, &dl); pending = zt->loads_pending; if (pending != 0) { @@ -328,7 +328,7 @@ dns_zt_loadnew(dns_zt_t *zt, isc_boolean_t stop) { REQUIRE(VALID_ZT(zt)); RWLOCK(&zt->rwlock, isc_rwlocktype_read); - result = dns_zt_apply(zt, stop, loadnew, NULL); + result = dns_zt_apply(zt, stop, NULL, loadnew, NULL); RWUNLOCK(&zt->rwlock, isc_rwlocktype_read); return (result); } @@ -352,7 +352,7 @@ dns_zt_freezezones(dns_zt_t *zt, isc_boolean_t freeze) { REQUIRE(VALID_ZT(zt)); RWLOCK(&zt->rwlock, isc_rwlocktype_read); - result = dns_zt_apply2(zt, ISC_FALSE, &tresult, freezezones, &freeze); + result = dns_zt_apply(zt, ISC_FALSE, &tresult, freezezones, &freeze); RWUNLOCK(&zt->rwlock, isc_rwlocktype_read); if (tresult == ISC_R_NOTFOUND) tresult = ISC_R_SUCCESS; @@ -475,15 +475,8 @@ dns_zt_setviewrevert(dns_zt_t *zt) { } 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) -{ - return (dns_zt_apply2(zt, stop, NULL, action, 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) { dns_rbtnode_t *node; dns_rbtnodechain_t chain; diff --git a/lib/ns/tests/nstest.c b/lib/ns/tests/nstest.c index ce43815272..d95f5aa2b0 100644 --- a/lib/ns/tests/nstest.c +++ b/lib/ns/tests/nstest.c @@ -324,7 +324,7 @@ ns_test_makeview(const char *name, isc_boolean_t with_cache, CHECK(dns_cache_create(mctx, mctx, taskmgr, timermgr, dns_rdataclass_in, "", "rbt", 0, NULL, &cache)); - dns_view_setcache(view, cache); + dns_view_setcache(view, cache, ISC_FALSE); /* * Reference count for "cache" is now at 2, so decrement it in * order for the cache to be automatically freed when "view" diff --git a/lib/ns/update.c b/lib/ns/update.c index 6e99e4a38c..e649663ae7 100644 --- a/lib/ns/update.c +++ b/lib/ns/update.c @@ -895,10 +895,10 @@ ssu_checkrule(void *data, dns_rdataset_t *rrset) { if (rrset->type == dns_rdatatype_rrsig || rrset->type == dns_rdatatype_nsec) return (ISC_R_SUCCESS); - result = dns_ssutable_checkrules2(ssuinfo->table, ssuinfo->signer, - ssuinfo->name, ssuinfo->addr, - ssuinfo->tcp, ssuinfo->aclenv, - rrset->type, ssuinfo->key); + result = dns_ssutable_checkrules(ssuinfo->table, ssuinfo->signer, + ssuinfo->name, ssuinfo->addr, + ssuinfo->tcp, ssuinfo->aclenv, + rrset->type, ssuinfo->key); return (result == ISC_TRUE ? ISC_R_SUCCESS : ISC_R_FAILURE); } @@ -2750,10 +2750,10 @@ update_action(isc_task_t *task, isc_event_t *event) { tsigkey = client->message->tsigkey->key; if (rdata.type != dns_rdatatype_any) { - if (!dns_ssutable_checkrules2 - (ssutable, client->signer, name, &netaddr, - ISC_TF(TCPCLIENT(client)), - env, rdata.type, tsigkey)) + if (!dns_ssutable_checkrules + (ssutable, client->signer, name, &netaddr, + ISC_TF(TCPCLIENT(client)), + env, rdata.type, tsigkey)) { FAILC(DNS_R_REFUSED, "rejected by secure update"); From 102a397e39bf61d3ca459cd0a08b80b496fb0147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Thu, 5 Apr 2018 16:23:56 +0200 Subject: [PATCH 17/18] libdns refactoring: get rid of multiple versions of dns_keytable_add, dns_iptable_addprefix and dns_iptable_addprefix --- bin/named/server.c | 14 ++++----- lib/dns/acl.c | 3 +- lib/dns/client.c | 2 +- lib/dns/forward.c | 9 +----- lib/dns/include/dns/forward.h | 19 +----------- lib/dns/include/dns/iptable.h | 7 ++--- lib/dns/include/dns/keytable.h | 3 -- lib/dns/iptable.c | 11 ++----- lib/dns/keytable.c | 9 +----- lib/dns/resolver.c | 8 ++--- lib/dns/tests/acl_test.c | 56 +++++++++++++++++----------------- lib/dns/tests/keytable_test.c | 22 ++++++------- lib/dns/win32/libdns.def.in | 3 -- lib/dns/zone.c | 2 +- lib/isccfg/aclconf.c | 15 ++++++--- lib/ns/interfacemgr.c | 4 +-- 16 files changed, 73 insertions(+), 114 deletions(-) diff --git a/bin/named/server.c b/bin/named/server.c index 515127dbc5..0f6ea49248 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -869,8 +869,8 @@ load_view_keys(const cfg_obj_t *keys, const cfg_obj_t *vconfig, * initializing key; that's why 'managed' * is duplicated below. */ - CHECK(dns_keytable_add2(secroots, managed, - managed, &dstkey)); + CHECK(dns_keytable_add(secroots, managed, + managed, &dstkey)); } } @@ -3615,8 +3615,8 @@ create_mapped_acl(void) { if (result != ISC_R_SUCCESS) return (result); - result = dns_iptable_addprefix2(acl->iptable, &addr, 96, - ISC_TRUE, ISC_FALSE); + result = dns_iptable_addprefix(acl->iptable, &addr, 96, + ISC_TRUE, ISC_FALSE); if (result == ISC_R_SUCCESS) dns_acl_attach(acl, &named_g_mapped); dns_acl_detach(&acl); @@ -5254,7 +5254,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, * empty zone for it. */ result = dns_fwdtable_find(view->fwdtable, name, - &dnsforwarders); + NULL, &dnsforwarders); if (result == ISC_R_SUCCESS && dnsforwarders->fwdpolicy == dns_fwdpolicy_only) continue; @@ -6267,8 +6267,8 @@ add_listenelt(isc_mem_t *mctx, ns_listenlist_t *list, isc_sockaddr_t *addr, if (result != ISC_R_SUCCESS) return (result); - result = dns_iptable_addprefix(src_acl->iptable, - &netaddr, 128, ISC_TRUE); + result = dns_iptable_addprefix(src_acl->iptable, &netaddr, + 128, ISC_TRUE, ISC_FALSE); if (result != ISC_R_SUCCESS) goto clean; diff --git a/lib/dns/acl.c b/lib/dns/acl.c index f2c550c557..9a9d56ccfe 100644 --- a/lib/dns/acl.c +++ b/lib/dns/acl.c @@ -100,7 +100,8 @@ dns_acl_anyornone(isc_mem_t *mctx, isc_boolean_t neg, dns_acl_t **target) { if (result != ISC_R_SUCCESS) return (result); - result = dns_iptable_addprefix(acl->iptable, NULL, 0, ISC_TF(!neg)); + result = dns_iptable_addprefix(acl->iptable, NULL, 0, ISC_TF(!neg), + ISC_FALSE); if (result != ISC_R_SUCCESS) { dns_acl_detach(&acl); return (result); diff --git a/lib/dns/client.c b/lib/dns/client.c index 2844429e2a..9d044446e8 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -1540,7 +1540,7 @@ dns_client_addtrustedkey(dns_client_t *client, dns_rdataclass_t rdclass, if (result != ISC_R_SUCCESS) goto cleanup; - result = dns_keytable_add2(secroots, ISC_FALSE, ISC_FALSE, &dstkey); + result = dns_keytable_add(secroots, ISC_FALSE, ISC_FALSE, &dstkey); cleanup: if (dstkey != NULL) diff --git a/lib/dns/forward.c b/lib/dns/forward.c index 8b3f992a68..2380118404 100644 --- a/lib/dns/forward.c +++ b/lib/dns/forward.c @@ -192,14 +192,7 @@ dns_fwdtable_delete(dns_fwdtable_t *fwdtable, const dns_name_t *name) { isc_result_t dns_fwdtable_find(dns_fwdtable_t *fwdtable, const dns_name_t *name, - dns_forwarders_t **forwardersp) -{ - return (dns_fwdtable_find2(fwdtable, name, NULL, forwardersp)); -} - -isc_result_t -dns_fwdtable_find2(dns_fwdtable_t *fwdtable, const dns_name_t *name, - dns_name_t *foundname, dns_forwarders_t **forwardersp) + dns_name_t *foundname, dns_forwarders_t **forwardersp) { isc_result_t result; diff --git a/lib/dns/include/dns/forward.h b/lib/dns/include/dns/forward.h index 16e1009223..2d7602a9dc 100644 --- a/lib/dns/include/dns/forward.h +++ b/lib/dns/include/dns/forward.h @@ -89,24 +89,7 @@ dns_fwdtable_delete(dns_fwdtable_t *fwdtable, const dns_name_t *name); isc_result_t dns_fwdtable_find(dns_fwdtable_t *fwdtable, const dns_name_t *name, - dns_forwarders_t **forwardersp); -/*%< - * Finds a domain in the forwarding table. The closest matching parent - * domain is returned. - * - * Requires: - * \li fwdtable is a valid forwarding table. - * \li name is a valid name - * \li forwardersp != NULL && *forwardersp == NULL - * - * Returns: - * \li #ISC_R_SUCCESS - * \li #ISC_R_NOTFOUND - */ - -isc_result_t -dns_fwdtable_find2(dns_fwdtable_t *fwdtable, const dns_name_t *name, - dns_name_t *foundname, dns_forwarders_t **forwardersp); + dns_name_t *foundname, dns_forwarders_t **forwardersp); /*%< * Finds a domain in the forwarding table. The closest matching parent * domain is returned. diff --git a/lib/dns/include/dns/iptable.h b/lib/dns/include/dns/iptable.h index 6dcbfabe72..20c455de8d 100644 --- a/lib/dns/include/dns/iptable.h +++ b/lib/dns/include/dns/iptable.h @@ -45,11 +45,8 @@ dns_iptable_create(isc_mem_t *mctx, dns_iptable_t **target); isc_result_t dns_iptable_addprefix(dns_iptable_t *tab, const isc_netaddr_t *addr, - isc_uint16_t bitlen, isc_boolean_t pos); -isc_result_t -dns_iptable_addprefix2(dns_iptable_t *tab, const isc_netaddr_t *addr, - isc_uint16_t bitlen, isc_boolean_t pos, - isc_boolean_t is_ecs); + isc_uint16_t bitlen, isc_boolean_t pos, + isc_boolean_t is_ecs); /* * Add an IP prefix to an existing IP table */ diff --git a/lib/dns/include/dns/keytable.h b/lib/dns/include/dns/keytable.h index 4dccad10c5..32567e0c99 100644 --- a/lib/dns/include/dns/keytable.h +++ b/lib/dns/include/dns/keytable.h @@ -105,9 +105,6 @@ dns_keytable_detach(dns_keytable_t **keytablep); isc_result_t dns_keytable_add(dns_keytable_t *keytable, isc_boolean_t managed, - dst_key_t **keyp) ISC_DEPRECATED; -isc_result_t -dns_keytable_add2(dns_keytable_t *keytable, isc_boolean_t managed, isc_boolean_t initial, dst_key_t **keyp); /*%< * Add '*keyp' to 'keytable' (using the name in '*keyp'). diff --git a/lib/dns/iptable.c b/lib/dns/iptable.c index 09323cb9ca..f44bae7d63 100644 --- a/lib/dns/iptable.c +++ b/lib/dns/iptable.c @@ -56,15 +56,8 @@ static isc_boolean_t dns_iptable_pos = ISC_TRUE; */ isc_result_t dns_iptable_addprefix(dns_iptable_t *tab, const isc_netaddr_t *addr, - isc_uint16_t bitlen, isc_boolean_t pos) -{ - return(dns_iptable_addprefix2(tab, addr, bitlen, pos, ISC_FALSE)); -} - -isc_result_t -dns_iptable_addprefix2(dns_iptable_t *tab, const isc_netaddr_t *addr, - isc_uint16_t bitlen, isc_boolean_t pos, - isc_boolean_t is_ecs) + isc_uint16_t bitlen, isc_boolean_t pos, + isc_boolean_t is_ecs) { isc_result_t result; isc_prefix_t pfx; diff --git a/lib/dns/keytable.c b/lib/dns/keytable.c index 356791db6a..af2666c954 100644 --- a/lib/dns/keytable.c +++ b/lib/dns/keytable.c @@ -308,14 +308,7 @@ insert(dns_keytable_t *keytable, isc_boolean_t managed, isc_boolean_t initial, isc_result_t dns_keytable_add(dns_keytable_t *keytable, isc_boolean_t managed, - dst_key_t **keyp) -{ - return (dns_keytable_add2(keytable, managed, ISC_FALSE, keyp)); -} - -isc_result_t -dns_keytable_add2(dns_keytable_t *keytable, isc_boolean_t managed, - isc_boolean_t initial, dst_key_t **keyp) + isc_boolean_t initial, dst_key_t **keyp) { REQUIRE(keyp != NULL && *keyp != NULL); REQUIRE(!initial || managed); diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index d8a83e4e58..724219cde3 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -3521,8 +3521,8 @@ fctx_getaddresses(fetchctx_t *fctx, isc_boolean_t badcache) { dns_fixedname_init(&fixed); domain = dns_fixedname_name(&fixed); - result = dns_fwdtable_find2(res->view->fwdtable, name, - domain, &forwarders); + result = dns_fwdtable_find(res->view->fwdtable, name, + domain, &forwarders); if (result == ISC_R_SUCCESS) { fwd = ISC_LIST_HEAD(forwarders->fwdrs); fctx->fwdpolicy = forwarders->fwdpolicy; @@ -4602,8 +4602,8 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type, /* Find the forwarder for this name. */ dns_fixedname_init(&fixed); fname = dns_fixedname_name(&fixed); - result = dns_fwdtable_find2(fctx->res->view->fwdtable, fwdname, - fname, &forwarders); + result = dns_fwdtable_find(fctx->res->view->fwdtable, fwdname, + fname, &forwarders); if (result == ISC_R_SUCCESS) fctx->fwdpolicy = forwarders->fwdpolicy; diff --git a/lib/dns/tests/acl_test.c b/lib/dns/tests/acl_test.c index 99ff5c8c74..e4b338117b 100644 --- a/lib/dns/tests/acl_test.c +++ b/lib/dns/tests/acl_test.c @@ -138,13 +138,13 @@ ATF_TC_BODY(dns_acl_isinsecure, tc) { inaddr.s_addr = htonl(0x0a000000); /* 10.0.0.0 */ isc_netaddr_fromin(&addr, &inaddr); - result = dns_iptable_addprefix2(pos4pos6->iptable, &addr, 8, - ISC_TRUE, ecs[pass].first); + result = dns_iptable_addprefix(pos4pos6->iptable, &addr, 8, + ISC_TRUE, ecs[pass].first); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); addr.family = AF_INET6; /* 0a00:: */ - result = dns_iptable_addprefix2(pos4pos6->iptable, &addr, 8, - ISC_TRUE, ecs[pass].second); + result = dns_iptable_addprefix(pos4pos6->iptable, &addr, 8, + ISC_TRUE, ecs[pass].second); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = dns_acl_merge(notpos4pos6, pos4pos6, ISC_FALSE); @@ -152,13 +152,13 @@ ATF_TC_BODY(dns_acl_isinsecure, tc) { inaddr.s_addr = htonl(0x0a000000); /* !10.0.0.0/8 */ isc_netaddr_fromin(&addr, &inaddr); - result = dns_iptable_addprefix2(neg4pos6->iptable, &addr, 8, - ISC_FALSE, ecs[pass].first); + result = dns_iptable_addprefix(neg4pos6->iptable, &addr, 8, + ISC_FALSE, ecs[pass].first); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); addr.family = AF_INET6; /* 0a00::/8 */ - result = dns_iptable_addprefix2(neg4pos6->iptable, &addr, 8, - ISC_TRUE, ecs[pass].second); + result = dns_iptable_addprefix(neg4pos6->iptable, &addr, 8, + ISC_TRUE, ecs[pass].second); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = dns_acl_merge(notneg4pos6, neg4pos6, ISC_FALSE); @@ -166,13 +166,13 @@ ATF_TC_BODY(dns_acl_isinsecure, tc) { inaddr.s_addr = htonl(0x0a000000); /* 10.0.0.0/8 */ isc_netaddr_fromin(&addr, &inaddr); - result = dns_iptable_addprefix2(pos4neg6->iptable, &addr, 8, - ISC_TRUE, ecs[pass].first); + result = dns_iptable_addprefix(pos4neg6->iptable, &addr, 8, + ISC_TRUE, ecs[pass].first); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); addr.family = AF_INET6; /* !0a00::/8 */ - result = dns_iptable_addprefix2(pos4neg6->iptable, &addr, 8, - ISC_FALSE, ecs[pass].second); + result = dns_iptable_addprefix(pos4neg6->iptable, &addr, 8, + ISC_FALSE, ecs[pass].second); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = dns_acl_merge(notpos4neg6, pos4neg6, ISC_FALSE); @@ -180,13 +180,13 @@ ATF_TC_BODY(dns_acl_isinsecure, tc) { inaddr.s_addr = htonl(0x0a000000); /* !10.0.0.0/8 */ isc_netaddr_fromin(&addr, &inaddr); - result = dns_iptable_addprefix2(neg4neg6->iptable, &addr, 8, - ISC_FALSE, ecs[pass].first); + result = dns_iptable_addprefix(neg4neg6->iptable, &addr, 8, + ISC_FALSE, ecs[pass].first); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); addr.family = AF_INET6; /* !0a00::/8 */ - result = dns_iptable_addprefix2(neg4neg6->iptable, &addr, 8, - ISC_FALSE, ecs[pass].second); + result = dns_iptable_addprefix(neg4neg6->iptable, &addr, 8, + ISC_FALSE, ecs[pass].second); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = dns_acl_merge(notneg4neg6, neg4neg6, ISC_FALSE); @@ -224,16 +224,16 @@ ATF_TC_BODY(dns_acl_isinsecure, tc) { inaddr.s_addr = htonl(0x7f000001); /* 127.0.0.1 */ isc_netaddr_fromin(&addr, &inaddr); - result = dns_iptable_addprefix2(loop4->iptable, &addr, 32, - ISC_TRUE, ecs[pass].first); + result = dns_iptable_addprefix(loop4->iptable, &addr, 32, + ISC_TRUE, ecs[pass].first); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = dns_acl_merge(notloop4, loop4, ISC_FALSE); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); isc_netaddr_fromin6(&addr, &in6addr_loopback); /* ::1 */ - result = dns_iptable_addprefix2(loop6->iptable, &addr, 128, - ISC_TRUE, ecs[pass].first); + result = dns_iptable_addprefix(loop6->iptable, &addr, 128, + ISC_TRUE, ecs[pass].first); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = dns_acl_merge(notloop6, loop6, ISC_FALSE); @@ -270,13 +270,13 @@ ATF_TC_BODY(dns_acl_isinsecure, tc) { inaddr.s_addr = htonl(0x7f000001); /* 127.0.0.1 */ isc_netaddr_fromin(&addr, &inaddr); - result = dns_iptable_addprefix2(loop4pos6->iptable, &addr, 32, - ISC_TRUE, ecs[pass].first); + result = dns_iptable_addprefix(loop4pos6->iptable, &addr, 32, + ISC_TRUE, ecs[pass].first); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); addr.family = AF_INET6; /* f700:0001::/32 */ - result = dns_iptable_addprefix2(loop4pos6->iptable, &addr, 32, - ISC_TRUE, ecs[pass].second); + result = dns_iptable_addprefix(loop4pos6->iptable, &addr, 32, + ISC_TRUE, ecs[pass].second); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = dns_acl_merge(notloop4pos6, loop4pos6, ISC_FALSE); @@ -284,13 +284,13 @@ ATF_TC_BODY(dns_acl_isinsecure, tc) { inaddr.s_addr = htonl(0x7f000001); /* 127.0.0.1 */ isc_netaddr_fromin(&addr, &inaddr); - result = dns_iptable_addprefix2(loop4neg6->iptable, &addr, 32, - ISC_TRUE, ecs[pass].first); + result = dns_iptable_addprefix(loop4neg6->iptable, &addr, 32, + ISC_TRUE, ecs[pass].first); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); addr.family = AF_INET6; /* !f700:0001::/32 */ - result = dns_iptable_addprefix2(loop4neg6->iptable, &addr, 32, - ISC_FALSE, ecs[pass].second); + result = dns_iptable_addprefix(loop4neg6->iptable, &addr, 32, + ISC_FALSE, ecs[pass].second); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); result = dns_acl_merge(notloop4neg6, loop4neg6, ISC_FALSE); diff --git a/lib/dns/tests/keytable_test.c b/lib/dns/tests/keytable_test.c index ae54f9e9a6..b3929bc62b 100644 --- a/lib/dns/tests/keytable_test.c +++ b/lib/dns/tests/keytable_test.c @@ -129,12 +129,12 @@ create_tables() { /* Add a normal key */ create_key(257, 3, 5, "example.com", keystr1, &key); - ATF_REQUIRE_EQ(dns_keytable_add2(keytable, ISC_FALSE, ISC_FALSE, &key), + ATF_REQUIRE_EQ(dns_keytable_add(keytable, ISC_FALSE, ISC_FALSE, &key), ISC_R_SUCCESS); /* Add an initializing managed key */ create_key(257, 3, 5, "managed.com", keystr1, &key); - ATF_REQUIRE_EQ(dns_keytable_add2(keytable, ISC_TRUE, ISC_TRUE, &key), + ATF_REQUIRE_EQ(dns_keytable_add(keytable, ISC_TRUE, ISC_TRUE, &key), ISC_R_SUCCESS); /* Add a null key */ @@ -193,7 +193,7 @@ ATF_TC_BODY(add, tc) { * nextkeynode() should still return NOTFOUND. */ create_key(257, 3, 5, "example.com", keystr1, &key); - ATF_REQUIRE_EQ(dns_keytable_add2(keytable, ISC_FALSE, ISC_FALSE, &key), + ATF_REQUIRE_EQ(dns_keytable_add(keytable, ISC_FALSE, ISC_FALSE, &key), ISC_R_SUCCESS); ATF_REQUIRE_EQ(dns_keytable_nextkeynode(keytable, keynode, &next_keynode), ISC_R_NOTFOUND); @@ -201,7 +201,7 @@ ATF_TC_BODY(add, tc) { /* Add another key (different keydata) */ dns_keytable_detachkeynode(keytable, &keynode); create_key(257, 3, 5, "example.com", keystr2, &key); - ATF_REQUIRE_EQ(dns_keytable_add2(keytable, ISC_FALSE, ISC_FALSE, &key), + ATF_REQUIRE_EQ(dns_keytable_add(keytable, ISC_FALSE, ISC_FALSE, &key), ISC_R_SUCCESS); ATF_REQUIRE_EQ(dns_keytable_find(keytable, str2name("example.com"), &keynode), ISC_R_SUCCESS); @@ -231,7 +231,7 @@ ATF_TC_BODY(add, tc) { * ISC_R_NOTFOUND and that the added key is an initializing key. */ create_key(257, 3, 5, "managed.com", keystr2, &key); - ATF_REQUIRE_EQ(dns_keytable_add2(keytable, ISC_TRUE, ISC_TRUE, &key), + ATF_REQUIRE_EQ(dns_keytable_add(keytable, ISC_TRUE, ISC_TRUE, &key), ISC_R_SUCCESS); ATF_REQUIRE_EQ(dns_keytable_find(keytable, str2name("managed.com"), &keynode), ISC_R_SUCCESS); @@ -248,7 +248,7 @@ ATF_TC_BODY(add, tc) { * nodes for managed.com, both containing non-initializing keys. */ create_key(257, 3, 5, "managed.com", keystr2, &key); - ATF_REQUIRE_EQ(dns_keytable_add2(keytable, ISC_TRUE, ISC_FALSE, &key), + ATF_REQUIRE_EQ(dns_keytable_add(keytable, ISC_TRUE, ISC_FALSE, &key), ISC_R_SUCCESS); ATF_REQUIRE_EQ(dns_keytable_find(keytable, str2name("managed.com"), &keynode), ISC_R_SUCCESS); @@ -269,7 +269,7 @@ ATF_TC_BODY(add, tc) { * that the added key is an initializing key. */ create_key(257, 3, 5, "two.com", keystr1, &key); - ATF_REQUIRE_EQ(dns_keytable_add2(keytable, ISC_TRUE, ISC_TRUE, &key), + ATF_REQUIRE_EQ(dns_keytable_add(keytable, ISC_TRUE, ISC_TRUE, &key), ISC_R_SUCCESS); ATF_REQUIRE_EQ(dns_keytable_find(keytable, str2name("two.com"), &keynode), ISC_R_SUCCESS); @@ -284,7 +284,7 @@ ATF_TC_BODY(add, tc) { * ISC_R_NOTFOUND and that the added key is not an initializing key. */ create_key(257, 3, 5, "two.com", keystr2, &key); - ATF_REQUIRE_EQ(dns_keytable_add2(keytable, ISC_TRUE, ISC_FALSE, &key), + ATF_REQUIRE_EQ(dns_keytable_add(keytable, ISC_TRUE, ISC_FALSE, &key), ISC_R_SUCCESS); ATF_REQUIRE_EQ(dns_keytable_find(keytable, str2name("two.com"), &keynode), ISC_R_SUCCESS); @@ -301,7 +301,7 @@ ATF_TC_BODY(add, tc) { * nodes for two.com, both containing non-initializing keys. */ create_key(257, 3, 5, "two.com", keystr1, &key); - ATF_REQUIRE_EQ(dns_keytable_add2(keytable, ISC_TRUE, ISC_FALSE, &key), + ATF_REQUIRE_EQ(dns_keytable_add(keytable, ISC_TRUE, ISC_FALSE, &key), ISC_R_SUCCESS); ATF_REQUIRE_EQ(dns_keytable_find(keytable, str2name("two.com"), &keynode), ISC_R_SUCCESS); @@ -323,7 +323,7 @@ ATF_TC_BODY(add, tc) { ATF_REQUIRE_EQ(dns_keytable_find(keytable, str2name("null.example"), &null_keynode), ISC_R_SUCCESS); create_key(257, 3, 5, "null.example", keystr2, &key); - ATF_REQUIRE_EQ(dns_keytable_add2(keytable, ISC_FALSE, ISC_FALSE, &key), + ATF_REQUIRE_EQ(dns_keytable_add(keytable, ISC_FALSE, ISC_FALSE, &key), ISC_R_SUCCESS); ATF_REQUIRE_EQ(dns_keytable_find(keytable, str2name("null.example"), &keynode), ISC_R_SUCCESS); @@ -629,7 +629,7 @@ ATF_TC_BODY(nta, tc) { ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); create_key(257, 3, 5, "example", keystr1, &key); - result = dns_keytable_add2(keytable, ISC_FALSE, ISC_FALSE, &key); + result = dns_keytable_add(keytable, ISC_FALSE, ISC_FALSE, &key); ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); isc_stdtime_get(&now); diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index f81efeff9c..a5f6060e75 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -372,7 +372,6 @@ dns_fwdtable_create dns_fwdtable_delete dns_fwdtable_destroy dns_fwdtable_find -dns_fwdtable_find2 dns_generalstats_create dns_generalstats_dump dns_generalstats_increment @@ -386,7 +385,6 @@ dns_ipkeylist_copy dns_ipkeylist_init dns_ipkeylist_resize dns_iptable_addprefix -dns_iptable_addprefix2 dns_iptable_attach dns_iptable_create dns_iptable_detach @@ -422,7 +420,6 @@ dns_keynode_managed dns_keynode_trust dns_keyring_restore dns_keytable_add -dns_keytable_add2 dns_keytable_attach dns_keytable_attachkeynode dns_keytable_create diff --git a/lib/dns/zone.c b/lib/dns/zone.c index b02da3b3b2..000e0bbbf6 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -3877,7 +3877,7 @@ trust_key(dns_zone_t *zone, dns_name_t *keyname, goto failure; CHECK(dns_dnssec_keyfromrdata(keyname, &rdata, mctx, &dstkey)); - CHECK(dns_keytable_add2(sr, ISC_TRUE, initial, &dstkey)); + CHECK(dns_keytable_add(sr, ISC_TRUE, initial, &dstkey)); dns_keytable_detach(&sr); failure: diff --git a/lib/isccfg/aclconf.c b/lib/isccfg/aclconf.c index e598e4d5ba..b3650c231a 100644 --- a/lib/isccfg/aclconf.c +++ b/lib/isccfg/aclconf.c @@ -632,6 +632,7 @@ cfg_acl_fromconfig2(const cfg_obj_t *caml, const cfg_obj_t *cctx, const cfg_listelt_t *elt; dns_iptable_t *iptab; int new_nest_level = 0; + isc_boolean_t setpos; if (nest_level != 0) new_nest_level = nest_level - 1; @@ -710,7 +711,7 @@ cfg_acl_fromconfig2(const cfg_obj_t *caml, const cfg_obj_t *cctx, /* Network prefix */ isc_netaddr_t addr; unsigned int bitlen; - isc_boolean_t setpos, setecs; + isc_boolean_t setecs; cfg_obj_asnetprefix(ce, &addr, &bitlen); if (family != 0 && family != addr.family) { @@ -739,8 +740,8 @@ cfg_acl_fromconfig2(const cfg_obj_t *caml, const cfg_obj_t *cctx, */ setpos = ISC_TF(nest_level != 0 || !neg); setecs = cfg_obj_istype(ce, &cfg_type_ecsprefix); - result = dns_iptable_addprefix2(iptab, &addr, bitlen, - setpos, setecs); + result = dns_iptable_addprefix(iptab, &addr, bitlen, + setpos, setecs); if (result != ISC_R_SUCCESS) goto cleanup; @@ -812,8 +813,10 @@ nested_acl: const char *name = cfg_obj_asstring(ce); if (strcasecmp(name, "any") == 0) { /* Iptable entry with zero bit length. */ + setpos = ISC_TF(nest_level != 0 || !neg); result = dns_iptable_addprefix(iptab, NULL, 0, - ISC_TF(nest_level != 0 || !neg)); + setpos, + ISC_FALSE); if (result != ISC_R_SUCCESS) goto cleanup; @@ -831,8 +834,10 @@ nested_acl: * de->negative to true so we can handle * "!none;". */ + setpos = ISC_TF(nest_level != 0 || neg); result = dns_iptable_addprefix(iptab, NULL, 0, - ISC_TF(nest_level != 0 || neg)); + setpos, + ISC_FALSE); if (result != ISC_R_SUCCESS) goto cleanup; diff --git a/lib/ns/interfacemgr.c b/lib/ns/interfacemgr.c index 358caeb2d2..9538d7fe99 100644 --- a/lib/ns/interfacemgr.c +++ b/lib/ns/interfacemgr.c @@ -760,7 +760,7 @@ setup_locals(ns_interfacemgr_t *mgr, isc_interface_t *interface) { /* First add localhost address */ prefixlen = (netaddr->family == AF_INET) ? 32 : 128; result = dns_iptable_addprefix(mgr->aclenv.localhost->iptable, - netaddr, prefixlen, ISC_TRUE); + netaddr, prefixlen, ISC_TRUE, ISC_FALSE); if (result != ISC_R_SUCCESS) return (result); @@ -790,7 +790,7 @@ setup_locals(ns_interfacemgr_t *mgr, isc_interface_t *interface) { } result = dns_iptable_addprefix(mgr->aclenv.localnets->iptable, - netaddr, prefixlen, ISC_TRUE); + netaddr, prefixlen, ISC_TRUE, ISC_FALSE); if (result != ISC_R_SUCCESS) return (result); From f6a16bbd4a842e45aa43a59b17bc945858beeeaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Thu, 5 Apr 2018 20:12:47 +0200 Subject: [PATCH 18/18] libdns refactoring: CHANGES entry --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index d424804872..16fdf8b808 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +4920. [cleanup] Clean up libdns removing most of the backwards + compatibility wrappers. + 4919. [cleanup] Clean up the isc_hash_* namespace and leave only the FNV-1a hash implementation. [GL #178]