Compare commits

..
Author SHA1 Message Date
Mark Andrews 6c7e86aa51 suppress DOXYGEN 2020-02-03 17:44:15 +11:00
Mark Andrews 5c4917f66e remove unused label 2020-02-03 16:45:15 +11:00
Mark Andrews b7f9192ff1 add --library=std.cfg 2020-02-03 16:38:39 +11:00
Mark Andrews d9fa5d5a9a isc_mem_get cannot fail 2020-01-30 19:54:27 +11:00
Mark Andrews 6ab0b3d51a fixup! limit jobs when debugging cppcheck 2020-01-30 19:47:12 +11:00
Mark Andrews 8917d2f9b6 fixup! limit jobs when debugging cppcheck 2020-01-30 19:45:36 +11:00
Mark Andrews 1a8b581510 isc_mem_get cannot fail 2020-01-30 19:41:32 +11:00
Mark Andrews 2c823cc84f delay assignment until after REQUIRE 2020-01-30 19:38:47 +11:00
Mark Andrews e4e753f46a fixup! limit jobs when debugging cppcheck 2020-01-30 19:14:27 +11:00
Mark Andrews 228e769d75 fixup! limit jobs when debugging cppcheck 2020-01-30 19:11:14 +11:00
Mark Andrews 3590a811a2 fixup! limit jobs when debugging cppcheck 2020-01-30 19:07:04 +11:00
Mark Andrews 4de0a36a42 fixup! limit jobs when debugging cppcheck 2020-01-30 19:00:24 +11:00
Mark Andrews bbe83c3b2a delay assignment until after REQUIRE 2020-01-30 18:56:03 +11:00
Mark Andrews fe745d238d skip if first is NULL 2020-01-30 18:55:36 +11:00
Mark Andrews f1326c124a limit jobs when debugging cppcheck 2020-01-30 18:41:50 +11:00
Mark Andrews 05cb183b91 fixup! delay assignment until after REQUIRE 2020-01-30 18:24:22 +11:00
Mark Andrews b7b62bf0b2 delay assignment until after REQUIRE 2020-01-30 18:19:11 +11:00
Mark Andrews 2c17edf417 make expression logical for cppcheck 2020-01-30 17:57:25 +11:00
Mark Andrews feba3113c4 remove brackets 2020-01-30 17:49:15 +11:00
Mark Andrews 18194962f2 simplify ISC_LIKELY/ISC_UNLIKELY for CPPCHECK 2020-01-30 17:27:08 +11:00
Mark Andrews d3786c0cf1 simplify RUNTIME_CHECK for cppcheck 2020-01-30 17:14:42 +11:00
Mark Andrews 1c2f8ab09f add untracked 2020-01-30 16:42:27 +11:00
Mark Andrews 2f7613333f fixup! add --dump 2020-01-30 16:15:47 +11:00
Mark Andrews 0ff879f145 add --dump 2020-01-30 16:13:21 +11:00
102 changed files with 1130 additions and 1586 deletions
+38 -9
View File
@@ -29,6 +29,9 @@ variables:
TARBALL_COMPRESSOR: xz
TARBALL_EXTENSION: xz
# limit jobs when debugging cppcheck
DEBUG_CPPCHECK: 1
stages:
- precheck
- build
@@ -60,7 +63,7 @@ stages:
.openbsd-amd64: &openbsd_amd64
tags:
- libvirt
- openbsd
- amd64
### Docker Image Templates
@@ -209,6 +212,9 @@ stages:
artifacts:
untracked: true
expire_in: "1 day"
except:
variables:
- $DEBUG_CPPCHECK == "1"
.windows_build: &windows_build_job
stage: build
@@ -239,6 +245,9 @@ stages:
artifacts:
untracked: true
expire_in: "1 day"
except:
variables:
- $DEBUG_CPPCHECK == "1"
.setup_interfaces: &setup_interfaces |
if [ "$(id -u)" -eq "0" ]; then
@@ -263,6 +272,9 @@ stages:
untracked: true
expire_in: "1 day"
when: on_failure
except:
variables:
- $DEBUG_CPPCHECK == "1"
.kyua_report: &kyua_report_html |
kyua --logfile /dev/null report-html \
@@ -311,12 +323,17 @@ stages:
- kyua_html/
expire_in: "1 day"
when: on_failure
except:
variables:
- $DEBUG_CPPCHECK == "1"
.cppcheck_args: &run_cppcheck |
cppcheck --enable=warning,performance,portability,information,missingInclude \
--dump \
--include=config.h \
--quiet \
--std=c11 \
--library=std.cfg \
--language=c \
--project=compile_commands.json \
--error-exitcode=2 \
@@ -325,6 +342,7 @@ stages:
--output-file=cppcheck.results \
--relative-paths="$CI_PROJECT_DIR" \
--inline-suppr \
-U DOXYGEN \
--suppressions-list=util/suppressions.txt
.cppcheck_report: &cppcheck_report_html |
@@ -343,6 +361,7 @@ stages:
after_script:
- *cppcheck_report_html
artifacts:
untracked: true
paths:
- compile_commands.json
- cppcheck.results
@@ -426,6 +445,9 @@ docs:sid:amd64:
paths:
- doc/arm/
expire_in: "1 day"
except:
variables:
- $DEBUG_CPPCHECK == "1"
push:docs:sid:amd64:
<<: *debian_sid_amd64_image
@@ -634,6 +656,9 @@ scan-build:buster:amd64:
- scan-build.reports/
expire_in: "1 day"
when: on_failure
except:
variables:
- $DEBUG_CPPCHECK == "1"
# Jobs for regular GCC builds on Debian Sid (amd64)
@@ -644,6 +669,7 @@ gcc:sid:amd64:
EXTRA_CONFIGURE: "--enable-dnstap --with-libidn2"
RUN_MAKE_INSTALL: 1
MAKE: bear make
DEBUG_CPPCHECK: 0
<<: *debian_sid_amd64_image
<<: *build_job
@@ -1071,23 +1097,20 @@ unit:clang:freebsd12.0:amd64:
- clang:freebsd12.0:amd64
needs: ["clang:freebsd12.0:amd64"]
# Jobs for Clang builds on OpenBSD 6.6 (amd64)
# Jobs for Clang builds on OpenBSD 6.5 (amd64)
clang:openbsd6.6:amd64:
clang:openbsd6.5:amd64:
variables:
CC: clang
USER: gitlab-runner
<<: *openbsd_amd64
<<: *build_job
system:clang:openbsd6.6:amd64:
system:clang:openbsd6.5:amd64:
<<: *openbsd_amd64
<<: *system_test_job
variables:
USER: gitlab-runner
dependencies:
- clang:openbsd6.6:amd64
needs: ["clang:openbsd6.6:amd64"]
- clang:openbsd6.5:amd64
needs: ["clang:openbsd6.5:amd64"]
only:
- schedules
- tags
@@ -1132,6 +1155,9 @@ system:msvc:windows:amd64:
dependencies:
- msvc:windows:amd64
needs: ["msvc:windows:amd64"]
except:
variables:
- $DEBUG_CPPCHECK == "1"
msvc-debug:windows:amd64:
<<: *windows_build_job
@@ -1149,6 +1175,9 @@ system:msvc-debug:windows:amd64:
dependencies:
- msvc-debug:windows:amd64
needs: ["msvc-debug:windows:amd64"]
except:
variables:
- $DEBUG_CPPCHECK == "1"
# Job producing a release tarball
-15
View File
@@ -1,18 +1,3 @@
5354. [bug] dnssec-policy created new KSK keys when zone is in
initial stage of signing (the DS is not yet in
rumoured or omnipresent state). Fix by checking
key goals rather than active state when determining
new keys are needed. [GL #1593]
5353. [doc] Document port and dscp parameters in forwarders
configuration option. [GL !914]
5352. [bug] Correctly handle catalog zone entries containing
characters that aren't legal in filenames. [GL #1592]
5351. [bug] CDS / CDNSKEY consistency checks failed to handle
removal records. [GL #1554]
5350. [bug] When a view was configured with class CHAOS, the
server could crash while processing a query for a
non-existent record. [GL #1540]
+2 -2
View File
@@ -34,7 +34,7 @@ offer support on a "best effort" basis for some.
Regularly tested platforms
As of Feb 2020, BIND 9.15 is fully supported and regularly tested on the
As of Dec 2019, BIND 9.15 is fully supported and regularly tested on the
following systems:
* Debian 9, 10
@@ -42,7 +42,7 @@ following systems:
* Fedora 31
* Red Hat Enterprise Linux / CentOS 7, 8
* FreeBSD 11.3, 12.0
* OpenBSD 6.6
* OpenBSD 6.5
* Alpine Linux
The amd64, i386, armhf and arm64 CPU architectures are all fully
+2 -2
View File
@@ -42,7 +42,7 @@ offer support on a "best effort" basis for some.
### Regularly tested platforms
As of Feb 2020, BIND 9.15 is fully supported and regularly tested on the
As of Dec 2019, BIND 9.15 is fully supported and regularly tested on the
following systems:
* Debian 9, 10
@@ -50,7 +50,7 @@ following systems:
* Fedora 31
* Red Hat Enterprise Linux / CentOS 7, 8
* FreeBSD 11.3, 12.0
* OpenBSD 6.6
* OpenBSD 6.5
* Alpine Linux
The amd64, i386, armhf and arm64 CPU architectures are all fully supported.
+8 -3
View File
@@ -568,7 +568,8 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
if (!query->lookup->comments)
flags |= DNS_MESSAGETEXTFLAG_NOCOMMENTS;
isc_buffer_allocate(mctx, &buf, len);
result = isc_buffer_allocate(mctx, &buf, len);
check_result(result, "isc_buffer_allocate");
if (yaml) {
enum { Q = 0x1, R = 0x2 }; /* Q:query; R:ecursive */
@@ -741,8 +742,11 @@ repopulate_buffer:
buftoosmall:
len += OUTPUTBUF;
isc_buffer_free(&buf);
isc_buffer_allocate(mctx, &buf, len);
goto repopulate_buffer;
result = isc_buffer_allocate(mctx, &buf, len);
if (result == ISC_R_SUCCESS)
goto repopulate_buffer;
else
goto cleanup;
}
check_result(result,
"dns_message_pseudosectiontotext");
@@ -823,6 +827,7 @@ buftoosmall:
(char *)isc_buffer_base(buf));
isc_buffer_free(&buf);
cleanup:
if (style != NULL)
dns_master_styledestroy(&style, mctx);
return (result);
+5 -2
View File
@@ -883,8 +883,10 @@ setup_text_key(void) {
unsigned char *secretstore;
debug("setup_text_key()");
isc_buffer_allocate(mctx, &namebuf, MXNAME);
result = isc_buffer_allocate(mctx, &namebuf, MXNAME);
check_result(result, "isc_buffer_allocate");
dns_name_init(&keyname, NULL);
check_result(result, "dns_name_init");
isc_buffer_putstr(namebuf, keynametext);
secretsize = (unsigned int) strlen(keysecret) * 3 / 4;
secretstore = isc_mem_allocate(mctx, secretsize);
@@ -1394,7 +1396,8 @@ setup_libs(void) {
check_result(result, "dst_lib_init");
is_dst_up = true;
isc_mempool_create(mctx, COMMSIZE, &commctx);
result = isc_mempool_create(mctx, COMMSIZE, &commctx);
check_result(result, "isc_mempool_create");
isc_mempool_setname(commctx, "COMMPOOL");
/*
* 6 and 2 set as reasonable parameters for 3 or 4 nameserver
+2 -1
View File
@@ -199,7 +199,8 @@ say_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
dns_name_format(name, namestr, sizeof(namestr));
retry:
isc_buffer_allocate(mctx, &b, bufsize);
result = isc_buffer_allocate(mctx, &b, bufsize);
check_result(result, "isc_buffer_allocate");
result = dns_rdata_totext(rdata, NULL, b);
if (result == ISC_R_NOSPACE) {
isc_buffer_free(&b);
+3 -1
View File
@@ -221,7 +221,9 @@ printrdata(dns_rdata_t *rdata) {
printf("rdata_%d = ", rdata->type);
while (!done) {
isc_buffer_allocate(mctx, &b, size);
result = isc_buffer_allocate(mctx, &b, size);
if (result != ISC_R_SUCCESS)
check_result(result, "isc_buffer_allocate");
result = dns_rdata_totext(rdata, NULL, b);
if (result == ISC_R_SUCCESS) {
printf("%.*s\n", (int)isc_buffer_usedlength(b),
+4 -2
View File
@@ -370,7 +370,8 @@ formatset(dns_rdataset_t *rdataset) {
mctx);
check_result(result, "dns_master_stylecreate2 failed");
isc_buffer_allocate(mctx, &buf, MAX_CDS_RDATA_TEXT_SIZE);
result = isc_buffer_allocate(mctx, &buf, MAX_CDS_RDATA_TEXT_SIZE);
check_result(result, "printing DS records");
result = dns_master_rdatasettotext(name, rdataset, style, NULL, buf);
if ((result == ISC_R_SUCCESS) && isc_buffer_availablelength(buf) < 1) {
@@ -833,7 +834,8 @@ make_new_ds_set(ds_maker_func_t *ds_from_rdata,
result = dns_rdatalist_tordataset(dslist, &new_ds_set);
check_result(result, "dns_rdatalist_tordataset(dslist)");
isc_buffer_allocate(mctx, &new_ds_buf, size);
result = isc_buffer_allocate(mctx, &new_ds_buf, size);
check_result(result, "building new DS records");
for (result = dns_rdataset_first(rdset);
result == ISC_R_SUCCESS;
+4 -2
View File
@@ -226,7 +226,8 @@ dumpnode(dns_name_t *name, dns_dbnode_t *node) {
dns_rdataset_init(&rds);
isc_buffer_allocate(mctx, &buffer, bufsize);
result = isc_buffer_allocate(mctx, &buffer, bufsize);
check_result(result, "isc_buffer_allocate");
for (result = dns_rdatasetiter_first(iter);
result == ISC_R_SUCCESS;
@@ -252,7 +253,8 @@ dumpnode(dns_name_t *name, dns_dbnode_t *node) {
bufsize <<= 1;
isc_buffer_free(&buffer);
isc_buffer_allocate(mctx, &buffer, bufsize);
result = isc_buffer_allocate(mctx, &buffer, bufsize);
check_result(result, "isc_buffer_allocate");
}
check_result(result, "dns_master_rdatasettotext");
+7 -2
View File
@@ -445,7 +445,9 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
goto cleanup_request;
}
isc_buffer_allocate(listener->mctx, &text, 2 * 2048);
result = isc_buffer_allocate(listener->mctx, &text, 2 * 2048);
if (result != ISC_R_SUCCESS)
goto cleanup_request;
/*
* Establish nonce.
@@ -491,7 +493,10 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
goto cleanup_response;
if (conn->buffer == NULL) {
isc_buffer_allocate(listener->mctx, &conn->buffer, 2 * 2048);
result = isc_buffer_allocate(listener->mctx,
&conn->buffer, 2 * 2048);
if (result != ISC_R_SUCCESS)
goto cleanup_response;
}
isc_buffer_clear(conn->buffer);
+26 -8
View File
@@ -1344,7 +1344,7 @@ get_view_querysource_dispatch(const cfg_obj_t **maps, int af,
break;
}
if (isc_sockaddr_getport(&sa) == 0) {
// attrs |= DNS_DISPATCHATTR_EXCLUSIVE;
attrs |= DNS_DISPATCHATTR_EXCLUSIVE;
maxdispatchbuffers = EXCLBUFFERS;
} else {
INSIST(obj != NULL);
@@ -7694,7 +7694,9 @@ data_to_cfg(dns_view_t *view, MDB_val *key, MDB_val *data,
REQUIRE(zoneconfig != NULL && *zoneconfig == NULL);
if (*text == NULL) {
isc_buffer_allocate(view->mctx, text, 256);
result = isc_buffer_allocate(view->mctx, text, 256);
if (result != ISC_R_SUCCESS)
goto cleanup;
} else {
isc_buffer_clear(*text);
}
@@ -9544,7 +9546,7 @@ run_server(isc_task_t *task, isc_event_t *event) {
named_g_nm,
named_g_dispatchmgr,
server->task, named_g_udpdisp, geoip,
named_g_cpus, &server->interfacemgr),
&server->interfacemgr),
"creating interface manager");
CHECKFATAL(isc_timer_create(named_g_timermgr, isc_timertype_inactive,
@@ -10065,7 +10067,8 @@ named_add_reserved_dispatch(named_server_t *server,
return;
cleanup:
isc_mem_put(server->mctx, dispatch, sizeof(*dispatch));
if (dispatch != NULL)
isc_mem_put(server->mctx, dispatch, sizeof(*dispatch));
isc_sockaddr_format(addr, addrbuf, sizeof(addrbuf));
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
@@ -11027,7 +11030,8 @@ named_server_dumpdb(named_server_t *server, isc_lex_t *lex,
return (ISC_R_SUCCESS);
cleanup:
dumpcontext_destroy(dctx);
if (dctx != NULL)
dumpcontext_destroy(dctx);
return (result);
}
@@ -12390,7 +12394,17 @@ nzd_save(MDB_txn **txnp, MDB_dbi dbi, dns_zone_t *zone,
/* We're creating or overwriting the zone */
const cfg_obj_t *zoptions;
isc_buffer_allocate(view->mctx, &text, 256);
result = isc_buffer_allocate(view->mctx, &text, 256);
if (result != ISC_R_SUCCESS) {
isc_log_write(named_g_lctx,
NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER,
ISC_LOG_ERROR,
"Unable to allocate buffer in "
"nzd_save(): %s",
isc_result_totext(result));
goto cleanup;
}
zoptions = cfg_tuple_get(zconfig, "options");
if (zoptions == NULL) {
@@ -12415,7 +12429,7 @@ nzd_save(MDB_txn **txnp, MDB_dbi dbi, dns_zone_t *zone,
ISC_LOG_ERROR,
"Error writing zone config to "
"buffer in nzd_save(): %s",
isc_result_totext(dzarg.result));
isc_result_totext(result));
result = dzarg.result;
goto cleanup;
}
@@ -12747,7 +12761,7 @@ migrate_nzf(dns_view_t *view) {
CHECK(nzd_open(view, 0, &txn, &dbi));
isc_buffer_allocate(view->mctx, &text, 256);
CHECK(isc_buffer_allocate(view->mctx, &text, 256));
for (element = cfg_list_first(zonelist);
element != NULL;
@@ -13833,6 +13847,10 @@ named_server_delzone(named_server_t *server, isc_lex_t *lex,
dns_zone_detach(&raw);
if (zone != NULL)
dns_zone_detach(&zone);
if (dz != NULL) {
dns_zone_detach(&dz->zone);
isc_mem_put(named_g_mctx, dz, sizeof(*dz));
}
return (result);
}
+8 -4
View File
@@ -1238,7 +1238,8 @@ parse_name(char **cmdlinep, dns_message_t *msg, dns_name_t **namep) {
result = dns_message_gettempname(msg, namep);
check_result(result, "dns_message_gettempname");
isc_buffer_allocate(gmctx, &namebuf, DNS_NAME_MAXWIRE);
result = isc_buffer_allocate(gmctx, &namebuf, DNS_NAME_MAXWIRE);
check_result(result, "isc_buffer_allocate");
dns_name_init(*namep, NULL);
dns_name_setbuffer(*namep, namebuf);
dns_message_takebuffer(msg, &namebuf);
@@ -1283,14 +1284,16 @@ parse_rdata(char **cmdlinep, dns_rdataclass_t rdataclass,
isc_buffer_add(&source, strlen(cmdline));
result = isc_lex_openbuffer(lex, &source);
check_result(result, "isc_lex_openbuffer");
isc_buffer_allocate(gmctx, &buf, MAXWIRE);
result = isc_buffer_allocate(gmctx, &buf, MAXWIRE);
check_result(result, "isc_buffer_allocate");
result = dns_rdata_fromtext(NULL, rdataclass, rdatatype, lex,
dns_rootname, 0, gmctx, buf,
&callbacks);
isc_lex_destroy(&lex);
if (result == ISC_R_SUCCESS) {
isc_buffer_usedregion(buf, &r);
isc_buffer_allocate(gmctx, &newbuf, r.length);
result = isc_buffer_allocate(gmctx, &newbuf, r.length);
check_result(result, "isc_buffer_allocate");
isc_buffer_putmem(newbuf, r.base, r.length);
isc_buffer_usedregion(newbuf, &r);
dns_rdata_fromregion(rdata, rdataclass, rdatatype, &r);
@@ -2038,7 +2041,8 @@ show_message(FILE *stream, dns_message_t *msg, const char *description) {
}
if (buf != NULL)
isc_buffer_free(&buf);
isc_buffer_allocate(gmctx, &buf, bufsz);
result = isc_buffer_allocate(gmctx, &buf, bufsz);
check_result(result, "isc_buffer_allocate");
result = dns_message_totext(msg, style, 0, buf);
bufsz *= 2;
} while (result == ISC_R_NOSPACE);
+2 -2
View File
@@ -374,8 +374,8 @@ plugin_register(const char *parameters,
cfg_line, mctx, lctx, actx));
}
isc_mempool_create(mctx, sizeof(filter_data_t),
&inst->datapool);
CHECK(isc_mempool_create(mctx, sizeof(filter_data_t),
&inst->datapool));
CHECK(isc_ht_init(&inst->ht, mctx, 16));
isc_mutex_init(&inst->hlock);
+2 -1
View File
@@ -965,7 +965,8 @@ main(int argc, char **argv) {
command = *argv;
isc_buffer_allocate(rndc_mctx, &databuf, 2048);
DO("allocate data buffer",
isc_buffer_allocate(rndc_mctx, &databuf, 2048));
/*
* Convert argc/argv into a space-delimited command string
+2 -2
View File
@@ -297,8 +297,8 @@ main(int argc, char **argv) {
isc_mem_create(&mctx);
cmp = NULL;
isc_mempool_create(mctx, sizeof(client_t), &cmp)
;
RUNTIME_CHECK(isc_mempool_create(mctx, sizeof(client_t), &cmp)
== ISC_R_SUCCESS);
isc_mempool_setname(cmp, "adb test clients");
result = isc_log_create(mctx, &lctx, &lcfg);
+2 -2
View File
@@ -34,10 +34,10 @@ main(int argc, char *argv[]) {
isc_mem_create(&mctx);
mp1 = NULL;
isc_mempool_create(mctx, 24, &mp1);
RUNTIME_CHECK(isc_mempool_create(mctx, 24, &mp1) == ISC_R_SUCCESS);
mp2 = NULL;
isc_mempool_create(mctx, 31, &mp2);
RUNTIME_CHECK(isc_mempool_create(mctx, 31, &mp2) == ISC_R_SUCCESS);
isc_mempool_associatelock(mp1, &lock);
isc_mempool_associatelock(mp2, &lock);
+81 -109
View File
@@ -378,7 +378,7 @@ ret=0
$NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
server 10.53.0.1 ${PORT}
update add masters.catalog1.example. 3600 IN A 10.53.0.3
update add masters.catalog1.example. 3600 IN AAAA fd92:7065:b8e:ffff::3
update add masters.catalog1.example. 3600 IN AAAA fd92:7065:b8e:ffff::3
update add 4346f565b4d63ddb99e5d2497ff22d04e878e8f8.zones.catalog1.example. 3600 IN PTR dom6.example.
send
END
@@ -759,127 +759,96 @@ if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
##########################################################################
echo_i "Testing catalog entries that can't be represented as filenames"
# note: we need 4 backslashes in the shell to get 2 backslashes in DNS
# presentation format, which is 1 backslash on the wire.
for special in \
this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example \
this.zone/domain.has.a.slash.dom10.example \
this.zone\\\\domain.has.backslash.dom10.example \
this.zone:domain.has.a.colon.dom.10.example
do
# hashes below are generated by:
# python ${TOP}/contrib/scripts/catzhash.py "${special}"
echo_i "Testing very long domain in catalog"
n=$((n+1))
echo_i "checking that this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example. is not served by master ($n)"
ret=0
wait_for_no_soa @10.53.0.1 this.is.aery.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example. dig.out.test$n || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
case "$special" in
this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example)
hash=825f48b1ce1b4cf5a041d20255a0c8e98d114858
db=__catz__4d70696f2335687069467f11f5d5378c480383f97782e553fb2d04a7bb2a23ed.db
;;
this.zone/domain.has.a.slash.dom10.example)
hash=e64cc64c99bf52d0a77fb16dd7ed57cf925a36aa
db=__catz__46ba3e1b28d5955e5313d5fee61bedc78c71d08035aa7ea2f7bf0b8228ab3acc.db
;;
this.zone\\\\domain.has.backslash.dom10.example)
hash=91e27e02153d38cf656a9b376d7747fbcd19f985
db=__catz__b667f7ff802c0895e0506699951cff9a1cab68c5ef8546aa0d07425f244ed870.db
;;
this.zone:domain.has.a.colon.dom.10.example)
hash=8b7238bf4c34045834c573ba4116557ebb24d33c
db=__catz__5c721f7872913a4e7fa8ad42589cce5dd6e551a4c9e6ab3f86e77c0bbc7c2ca6.db
;;
esac
n=$((n+1))
echo_i "Adding a domain this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example. to master via RNDC ($n)"
ret=0
echo "@ 3600 IN SOA . . 1 3600 3600 3600 3600" > ns1/dom10.example.db
echo "@ IN NS invalid." >> ns1/dom10.example.db
rndccmd 10.53.0.1 addzone this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example. '{type master; file "dom10.example.db";};' || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "checking that ${special}. is not served by master ($n)"
ret=0
wait_for_no_soa @10.53.0.1 "${special}" dig.out.test$n || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "checking that this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example. is now served by master ($n)"
ret=0
wait_for_soa @10.53.0.1 this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example. dig.out.test$n || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "Adding a domain ${special}. to master via RNDC ($n)"
ret=0
echo "@ 3600 IN SOA . . 1 3600 3600 3600 3600" > ns1/dom10.example.db
echo "@ IN NS invalid." >> ns1/dom10.example.db
rndccmd 10.53.0.1 addzone '"'"${special}"'"' '{type master; file "dom10.example.db";};' || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
nextpart ns2/named.run >/dev/null
n=$((n+1))
echo_i "checking that ${special}. is now served by master ($n)"
ret=0
wait_for_soa @10.53.0.1 "${special}." dig.out.test$n || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
nextpart ns2/named.run >/dev/null
n=$((n+1))
echo_i "Adding domain ${special}. to catalog1 zone ($n)"
ret=0
$NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
server 10.53.0.1 ${PORT}
update add ${hash}.zones.catalog1.example 3600 IN PTR ${special}.
send
n=$((n+1))
echo_i "Adding domain this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example. to catalog1 zone ($n)"
ret=0
$NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
server 10.53.0.1 ${PORT}
update add 825f48b1ce1b4cf5a041d20255a0c8e98d114858.zones.catalog1.example 3600 IN PTR this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example.
send
END
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "waiting for slave to sync up ($n)"
ret=0
wait_for_message ns2/named.run "catz: adding zone '$special' from catalog 'catalog1.example'" &&
wait_for_message ns2/named.run "transfer of '$special/IN' from 10.53.0.1#${PORT}: Transfer status: success" || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "waiting for slave to sync up ($n)"
ret=0
wait_for_message ns2/named.run "catz: adding zone 'this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example' from catalog 'catalog1.example'" &&
wait_for_message ns2/named.run "transfer of 'this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example/IN' from 10.53.0.1#${PORT}: Transfer status: success" || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "checking that ${special}. is served by slave ($n)"
ret=0
wait_for_soa @10.53.0.2 "${special}." dig.out.test$n || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "checking that this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example. is served by slave ($n)"
ret=0
wait_for_soa @10.53.0.2 this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example. dig.out.test$n || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "checking that zone-directory is populated with a hashed filename ($n)"
ret=0
wait_for_zonefile "ns2/zonedir/$db" || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "checking that zone-directory is populated with a hashed filename ($n)"
ret=0
wait_for_zonefile "ns2/zonedir/__catz__4d70696f2335687069467f11f5d5378c480383f97782e553fb2d04a7bb2a23ed.db" || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "removing domain ${special}. from catalog1 zone ($n)"
ret=0
$NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
server 10.53.0.1 ${PORT}
update delete ${hash}.zones.catalog1.example
send
n=$((n+1))
echo_i "removing domain this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example. from catalog1 zone ($n)"
ret=0
$NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
server 10.53.0.1 ${PORT}
update delete 825f48b1ce1b4cf5a041d20255a0c8e98d114858.zones.catalog1.example
send
END
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "waiting for slave to sync up ($n)"
ret=0
wait_for_message ns2/named.run "zone_shutdown: zone ${special}/IN: shutting down" || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "waiting for slave to sync up ($n)"
ret=0
wait_for_message ns2/named.run "zone_shutdown: zone this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example/IN: shutting down" || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "checking that ${special}. is not served by slave ($n)"
ret=0
wait_for_no_soa @10.53.0.2 "${special}." dig.out.test$n || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "checking that this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example. is not served by slave ($n)"
ret=0
wait_for_no_soa @10.53.0.2 this.is.aery.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example. dig.out.test$n || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "checking that zone-directory is emptied ($n)"
ret=0
wait_for_no_zonefile "ns2/zonedir/$db" || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
done
n=$((n+1))
echo_i "checking that zone-directory is emptied ($n)"
ret=0
wait_for_no_zonefile "ns2/zonedir/__catz__4d70696f2335687069467f11f5d5378c480383f97782e553fb2d04a7bb2a23ed.db" || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
##########################################################################
echo_i "Testing adding a domain and a subdomain of it"
@@ -985,6 +954,8 @@ wait_for_soa @10.53.0.2 subdomain.of.dom11.example. dig.out.test$n || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
n=$((n+1))
echo_i "removing domain dom11.example. from catalog1 zone ($n)"
ret=0
@@ -1042,6 +1013,7 @@ wait_for_no_soa @10.53.0.2 subdomain.of.d11.example. dig.out.test$n || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status+ret))
##########################################################################
echo_i "Testing adding a catalog zone at runtime with rndc reconfig"
n=$((n+1))
+23 -40
View File
@@ -95,8 +95,6 @@ else
COLOR_WARN=''
fi
SYSTESTDIR="`basename $PWD`"
if type printf > /dev/null 2>&1
then
echofail () {
@@ -117,23 +115,6 @@ then
echoend () {
printf "${COLOR_END}%s${COLOR_NONE}\n" "$*"
}
echo_i() {
printf '%s\n' "$*" | while read -r __LINE ; do
echoinfo "I:$SYSTESTDIR:$__LINE"
done
}
echo_ic() {
printf '%s\n' "$*" | while read -r __LINE ; do
echoinfo "I:$SYSTESTDIR: $__LINE"
done
}
echo_d() {
printf '%s\n' "$*" | while read -r __LINE ; do
echoinfo "D:$SYSTESTDIR:$__LINE"
done
}
else
echofail () {
echo "$*"
@@ -153,34 +134,36 @@ else
echoend () {
echo "$*"
}
echo_i() {
echo "$@" | while read -r __LINE ; do
echoinfo "I:$SYSTESTDIR:$__LINE"
done
}
echo_ic() {
echo "$@" | while read -r __LINE ; do
echoinfo "I:$SYSTESTDIR: $__LINE"
done
}
echo_d() {
echo "$@" | while read -r __LINE ; do
echoinfo "D:$SYSTESTDIR:$__LINE"
done
}
fi
cat_i() {
while read -r __LINE ; do
SYSTESTDIR="`basename $PWD`"
echo_i() {
echo "$@" | while read __LINE ; do
echoinfo "I:$SYSTESTDIR:$__LINE"
done
}
echo_ic() {
echo "$@" | while read __LINE ; do
echoinfo "I:$SYSTESTDIR: $__LINE"
done
}
cat_i() {
while read __LINE ; do
echoinfo "I:$SYSTESTDIR:$__LINE"
done
}
echo_d() {
echo "$@" | while read __LINE ; do
echoinfo "D:$SYSTESTDIR:$__LINE"
done
}
cat_d() {
while read -r __LINE ; do
while read __LINE ; do
echoinfo "D:$SYSTESTDIR:$__LINE"
done
}
+5 -7
View File
@@ -24,9 +24,9 @@ rm -f ./canonical?.*
rm -f ./delv.out*
rm -f ./delve.out*
rm -f ./dig.out.*
rm -f ./dnssectools.out*
rm -f ./dsfromkey.out.*
rm -f ./keygen.err
rm -f ./dnssectools.out*
rm -f ./named.secroots.test*
rm -f ./nosign.before
rm -f ./ns*/*.nta
@@ -37,19 +37,19 @@ rm -f ./ns1/root.db ./ns2/example.db ./ns2/managed.db ./ns2/trusted.db
rm -f ./ns2/algroll.db
rm -f ./ns2/badparam.db ./ns2/badparam.db.bad
rm -f ./ns2/cdnskey-kskonly.secure.db
rm -f ./ns2/cdnskey-kskonly.secure.id
rm -f ./ns2/cdnskey-update.secure.db
rm -f ./ns2/cdnskey-x.secure.db
rm -f ./ns2/cdnskey.secure.db
rm -f ./ns2/cds-auto.secure.db ./ns2/cds-auto.secure.db.jnl
rm -f ./ns2/cds-kskonly.secure.db
rm -f ./ns2/cds-kskonly.secure.id
rm -f ./ns2/cds-update.secure.db ./ns2/cds-update.secure.db.jnl
rm -f ./ns2/cds.secure.db ./ns2/cds-x.secure.db
rm -f ./ns2/in-addr.arpa.db
rm -f ./ns2/nsec3chain-test.db
rm -f ./ns2/single-nsec3.db
rm -f ./ns2/updatecheck-kskonly.secure.*
rm -f ./ns3/secure.example.db ./ns3/*.managed.db ./ns3/*.trusted.db
rm -f ./ns3/unsupported.managed.db.tmp ./ns3/unsupported.trusted.db.tmp
rm -f ./ns3/auto-nsec.example.db ./ns3/auto-nsec3.example.db
rm -f ./ns3/badds.example.db
rm -f ./ns3/dname-at-apex-nsec3.example.db
@@ -57,10 +57,10 @@ rm -f ./ns3/dnskey-nsec3-unknown.example.db
rm -f ./ns3/dnskey-nsec3-unknown.example.db.tmp
rm -f ./ns3/dnskey-unknown.example.db
rm -f ./ns3/dnskey-unknown.example.db.tmp
rm -f ./ns3/dnskey-unsupported-2.example.db
rm -f ./ns3/dnskey-unsupported-2.example.db.tmp
rm -f ./ns3/dnskey-unsupported.example.db
rm -f ./ns3/dnskey-unsupported.example.db.tmp
rm -f ./ns3/dnskey-unsupported-2.example.db
rm -f ./ns3/dnskey-unsupported-2.example.db.tmp
rm -f ./ns3/dynamic.example.db ./ns3/dynamic.example.db.signed.jnl
rm -f ./ns3/expired.example.db ./ns3/update-nsec3.example.db
rm -f ./ns3/expiring.example.db ./ns3/nosign.example.db
@@ -80,7 +80,6 @@ rm -f ./ns3/publish-inactive.example.db
rm -f ./ns3/revkey.example.db
rm -f ./ns3/rsasha256.example.db ./ns3/rsasha512.example.db
rm -f ./ns3/secure.below-cname.example.db
rm -f ./ns3/secure.example.db ./ns3/*.managed.db ./ns3/*.trusted.db
rm -f ./ns3/secure.nsec3.example.db
rm -f ./ns3/secure.optout.example.db
rm -f ./ns3/siginterval.conf
@@ -90,7 +89,6 @@ rm -f ./ns3/split-smart.example.db
rm -f ./ns3/ttlpatch.example.db ./ns3/ttlpatch.example.db.signed
rm -f ./ns3/ttlpatch.example.db.patched
rm -f ./ns3/unsecure.example.db ./ns3/bogus.example.db ./ns3/keyless.example.db
rm -f ./ns3/unsupported.managed.db.tmp ./ns3/unsupported.trusted.db.tmp
rm -f ./ns4/managed-keys.bind*
rm -f ./ns4/named_dump.db*
rm -f ./ns6/optout-tld.db
-2
View File
@@ -238,7 +238,6 @@ key1=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" -n zone -f KSK "$
key2=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" -n zone "$zone")
cat "$infile" "$key1.key" "$key2.key" > "$zonefile"
"$SIGNER" -P -g -o "$zone" "$zonefile" > /dev/null 2>&1
keyfile_to_key_id "$key1" > cds-kskonly.secure.id
zone=cds-auto.secure
infile=cds-auto.secure.db.in
@@ -282,7 +281,6 @@ key1=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" -n zone -f KSK "$
key2=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" -n zone "$zone")
cat "$infile" "$key1.key" "$key2.key" > "$zonefile"
"$SIGNER" -P -g -o "$zone" "$zonefile" > /dev/null 2>&1
keyfile_to_key_id "$key1" > cdnskey-kskonly.secure.id
zone=cdnskey-auto.secure
infile=cdnskey-auto.secure.db.in
-90
View File
@@ -3317,24 +3317,6 @@ n=$((n+1))
test "$ret" -eq 0 || echo_i "failed"
status=$((status+ret))
echo_i "check that a CDS deletion record is accepted ($n)"
ret=0
(
echo zone cds-update.secure
echo server 10.53.0.2 "$PORT"
echo update delete cds-update.secure CDS
echo update add cds-update.secure 0 CDS 0 0 0 00
echo send
) | $NSUPDATE > nsupdate.out.test$n 2>&1
dig_with_opts +noall +answer @10.53.0.2 cds cds-update.secure > dig.out.test$n
lines=$(awk '$4 == "CDS" {print}' dig.out.test$n | wc -l)
test "${lines:-10}" -eq 1 || ret=1
lines=$(tr -d '\r' < dig.out.test$n | awk '$4 == "CDS" && $5 == "0" && $6 == "0" && $7 == "0" && $8 == "00" {print}' | wc -l)
test "$lines" -eq 1 || ret=1
n=$((n+1))
test "$ret" -eq 0 || echo_i "failed"
status=$((status+ret))
echo_i "check that CDS records are signed using KSK when added by nsupdate ($n)"
ret=0
(
@@ -3360,7 +3342,6 @@ status=$((status+ret))
echo_i "check that CDS records are signed only using KSK when added by"
echo_i " nsupdate when dnssec-dnskey-kskonly is yes ($n)"
ret=0
keyid=$(cat ns2/cds-kskonly.secure.id)
(
echo zone cds-kskonly.secure
echo server 10.53.0.2 "$PORT"
@@ -3375,38 +3356,12 @@ echo send
dig_with_opts +noall +answer @10.53.0.2 cds cds-kskonly.secure > dig.out.test$n
lines=$(awk '$4 == "RRSIG" && $5 == "CDS" {print}' dig.out.test$n | wc -l)
test "$lines" -eq 1 || ret=1
lines=$(awk -v id="${keyid}" '$4 == "RRSIG" && $5 == "CDS" && $11 == id {print}' dig.out.test$n | wc -l)
test "$lines" -eq 1 || ret=1
lines=$(awk '$4 == "CDS" {print}' dig.out.test$n | wc -l)
test "$lines" -eq 2 || ret=1
n=$((n+1))
test "$ret" -eq 0 || echo_i "failed"
status=$((status+ret))
echo_i "check that CDS deletion records are signed only using KSK when added by"
echo_i " nsupdate when dnssec-dnskey-kskonly is yes ($n)"
ret=0
keyid=$(cat ns2/cds-kskonly.secure.id)
(
echo zone cds-kskonly.secure
echo server 10.53.0.2 "$PORT"
echo update delete cds-kskonly.secure CDS
echo update add cds-kskonly.secure 0 CDS 0 0 0 00
echo send
) | $NSUPDATE
dig_with_opts +noall +answer @10.53.0.2 cds cds-kskonly.secure > dig.out.test$n
lines=$(awk '$4 == "RRSIG" && $5 == "CDS" {print}' dig.out.test$n | wc -l)
test "$lines" -eq 1 || ret=1
lines=$(awk -v id="${keyid}" '$4 == "RRSIG" && $5 == "CDS" && $11 == id {print}' dig.out.test$n | wc -l)
test "$lines" -eq 1 || ret=1
lines=$(awk '$4 == "CDS" {print}' dig.out.test$n | wc -l)
test "$lines" -eq 1 || ret=1
lines=$(tr -d '\r' < dig.out.test$n | awk '$4 == "CDS" && $5 == "0" && $6 == "0" && $7 == "0" && $8 == "00" {print}' | wc -l)
test "$lines" -eq 1 || ret=1
n=$((n+1))
test "$ret" -eq 0 || echo_i "failed"
status=$((status+ret))
echo_i "checking that positive unknown NSEC3 hash algorithm with OPTOUT does validate ($n)"
ret=0
dig_with_opts +noauth +noadd +nodnssec +adflag @10.53.0.3 optout-unknown.example SOA > dig.out.ns3.test$n
@@ -3542,24 +3497,6 @@ n=$((n+1))
test "$ret" -eq 0 || echo_i "failed"
status=$((status+ret))
echo_i "check that a CDNSKEY deletion record is accepted ($n)"
ret=0
(
echo zone cdnskey-update.secure
echo server 10.53.0.2 "$PORT"
echo update delete cdnskey-update.secure CDNSKEY
echo update add cdnskey-update.secure 0 CDNSKEY 0 3 0 AA==
echo send
) | $NSUPDATE > nsupdate.out.test$n 2>&1
dig_with_opts +noall +answer @10.53.0.2 cdnskey cdnskey-update.secure > dig.out.test$n
lines=$(awk '$4 == "CDNSKEY" {print}' dig.out.test$n | wc -l)
test "${lines:-10}" -eq 1 || ret=1
lines=$(tr -d '\r' < dig.out.test$n | awk '$4 == "CDNSKEY" && $5 == "0" && $6 == "3" && $7 == "0" && $8 == "AA==" {print}' | wc -l)
test "${lines:-10}" -eq 1 || ret=1
n=$((n+1))
test "$ret" -eq 0 || echo_i "failed"
status=$((status+ret))
echo_i "checking that unknown DNSKEY algorithm + unknown NSEC3 has algorithm validates as insecure ($n)"
ret=0
dig_with_opts +noauth +noadd +nodnssec +adflag @10.53.0.3 dnskey-nsec3-unknown.example A > dig.out.ns3.test$n
@@ -3593,7 +3530,6 @@ status=$((status+ret))
echo_i "check that CDNSKEY records are signed only using KSK when added by"
echo_i " nsupdate when dnssec-dnskey-kskonly is yes ($n)"
ret=0
keyid=$(cat ns2/cdnskey-kskonly.secure.id)
(
echo zone cdnskey-kskonly.secure
echo server 10.53.0.2 "$PORT"
@@ -3605,38 +3541,12 @@ echo send
dig_with_opts +noall +answer @10.53.0.2 cdnskey cdnskey-kskonly.secure > dig.out.test$n
lines=$(awk '$4 == "RRSIG" && $5 == "CDNSKEY" {print}' dig.out.test$n | wc -l)
test "$lines" -eq 1 || ret=1
lines=$(awk -v id="${keyid}" '$4 == "RRSIG" && $5 == "CDNSKEY" && $11 == id {print}' dig.out.test$n | wc -l)
test "$lines" -eq 1 || ret=1
lines=$(awk '$4 == "CDNSKEY" {print}' dig.out.test$n | wc -l)
test "$lines" -eq 1 || ret=1
n=$((n+1))
test "$ret" -eq 0 || echo_i "failed"
status=$((status+ret))
echo_i "check that CDNSKEY deletion records are signed only using KSK when added by"
echo_i " nsupdate when dnssec-dnskey-kskonly is yes ($n)"
ret=0
keyid=$(cat ns2/cdnskey-kskonly.secure.id)
(
echo zone cdnskey-kskonly.secure
echo server 10.53.0.2 "$PORT"
echo update delete cdnskey-kskonly.secure CDNSKEY
echo update add cdnskey-kskonly.secure 0 CDNSKEY 0 3 0 AA==
echo send
) | $NSUPDATE
dig_with_opts +noall +answer @10.53.0.2 cdnskey cdnskey-kskonly.secure > dig.out.test$n
lines=$(awk '$4 == "RRSIG" && $5 == "CDNSKEY" {print}' dig.out.test$n | wc -l)
test "$lines" -eq 1 || ret=1
lines=$(awk -v id="${keyid}" '$4 == "RRSIG" && $5 == "CDNSKEY" && $11 == id {print}' dig.out.test$n | wc -l)
test "$lines" -eq 1 || ret=1
lines=$(awk '$4 == "CDNSKEY" {print}' dig.out.test$n | wc -l)
test "$lines" -eq 1 || ret=1
lines=$(tr -d '\r' < dig.out.test$n | awk '$4 == "CDNSKEY" && $5 == "0" && $6 == "3" && $7 == "0" && $8 == "AA==" {print}' | wc -l)
test "${lines:-10}" -eq 1 || ret=1
n=$((n+1))
test "$ret" -eq 0 || echo_i "failed"
status=$((status+ret))
echo_i "checking initialization with a revoked managed key ($n)"
ret=0
copy_setports ns5/named2.conf.in ns5/named.conf
+2 -1
View File
@@ -120,7 +120,8 @@ dyndb_init(isc_mem_t *mctx, const char *name, const char *parameters,
*instp = sample_inst;
cleanup:
isc_mem_free(mctx, s);
if (s != NULL)
isc_mem_free(mctx, s);
if (argv != NULL)
isc_mem_put(mctx, argv, argc * sizeof(*argv));
-10
View File
@@ -107,16 +107,6 @@ zone "pregenerated.kasp" {
dnssec-policy "rsasha1";
};
/*
* A configured dnssec-policy with one rumoured key.
* Bugfix case for GL #1593.
*/
zone "rumoured.kasp" {
type master;
file "rumoured.kasp.db";
dnssec-policy "rsasha1";
};
/*
* Different algorithms.
*/
+1 -11
View File
@@ -43,7 +43,7 @@ U="UNRETENTIVE"
# Set up zones that will be initially signed.
#
for zn in default rsasha1 dnssec-keygen some-keys legacy-keys pregenerated \
rumoured rsasha1-nsec3 rsasha256 rsasha512 ecdsa256 ecdsa384 inherit
rsasha1-nsec3 rsasha256 rsasha512 ecdsa256 ecdsa384 inherit
do
setup "${zn}.kasp"
cp template.db.in "$zonefile"
@@ -72,16 +72,6 @@ zone="pregenerated.kasp"
$KEYGEN -k rsasha1 -l policies/kasp.conf $zone > keygen.out.$zone.1 2>&1
$KEYGEN -k rsasha1 -l policies/kasp.conf $zone > keygen.out.$zone.2 2>&1
zone="rumoured.kasp"
Tpub="now"
Tact="now+1d"
KSK=$($KEYGEN -a RSASHA1 -f KSK -L 1234 $zone 2> keygen.out.$zone.1)
ZSK1=$($KEYGEN -a RSASHA1 -b 2000 -L 1234 $zone 2> keygen.out.$zone.2)
ZSK2=$($KEYGEN -a RSASHA1 -L 1234 $zone 2> keygen.out.$zone.3)
$SETTIME -s -P $Tpub -A $Tact -g $O -k $R $Tpub -r $R $Tpub -d $H $Tpub "$KSK" > settime.out.$zone.1 2>&1
$SETTIME -s -P $Tpub -A $Tact -g $O -k $R $Tpub -z $R $Tpub "$ZSK1" > settime.out.$zone.2 2>&1
$SETTIME -s -P $Tpub -A $Tact -g $O -k $R $Tpub -z $R $Tpub "$ZSK2" > settime.out.$zone.2 2>&1
#
# Set up zones that are already signed.
#
+15 -59
View File
@@ -855,7 +855,7 @@ check_signatures() {
response_has_cds_for_key() (
awk -v zone="${ZONE%%.}." \
-v ttl="${DNSKEY_TTL}" \
-v qtype="CDS" \
-v qtype="${_qtype}" \
-v keyid="$(key_get "${1}" ID)" \
-v keyalg="${_key_algnum}" \
-v hashalg="2" \
@@ -865,70 +865,37 @@ response_has_cds_for_key() (
"$2"
)
response_has_cdnskey_for_key() (
awk -v zone="${ZONE%%.}." \
-v ttl="${DNSKEY_TTL}" \
-v qtype="CDNSKEY" \
-v flags="257" \
-v keyalg="${_key_algnum}" \
'BEGIN { ret=1; }
$1 == zone && $2 == ttl && $4 == qtype && $5 == flags && $7 == keyalg { ret=0; exit; }
END { exit ret; }' \
"$2"
)
# Test CDS and CDNSKEY publication.
check_cds() {
_qtype="CDS"
_key_algnum="$(key_get KEY1 ALG_NUM)"
n=$((n+1))
echo_i "check CDS and CDNSKEY rrset are signed correctly for zone ${ZONE} ($n)"
echo_i "check ${_qtype} rrset is signed correctly for zone ${ZONE} ($n)"
ret=0
dig_with_opts "$ZONE" "@${SERVER}" "CDS" > "dig.out.$DIR.test$n.cds" || log_error "dig ${ZONE} CDS failed"
grep "status: NOERROR" "dig.out.$DIR.test$n.cds" > /dev/null || log_error "mismatch status in DNS response"
dig_with_opts "$ZONE" "@${SERVER}" "CDNSKEY" > "dig.out.$DIR.test$n.cdnskey" || log_error "dig ${ZONE} CDNSKEY failed"
grep "status: NOERROR" "dig.out.$DIR.test$n.cdnskey" > /dev/null || log_error "mismatch status in DNS response"
dig_with_opts "$ZONE" "@${SERVER}" $_qtype > "dig.out.$DIR.test$n" || log_error "dig ${ZONE} ${_qtype} failed"
grep "status: NOERROR" "dig.out.$DIR.test$n" > /dev/null || log_error "mismatch status in DNS response"
if [ "$(key_get KEY1 STATE_DS)" = "rumoured" ] || [ "$(key_get KEY1 STATE_DS)" = "omnipresent" ]; then
response_has_cds_for_key KEY1 "dig.out.$DIR.test$n.cds" || log_error "missing CDS record in response for key $(key_get KEY1 ID)"
check_signatures "CDS" "dig.out.$DIR.test$n.cds" "KSK"
response_has_cdnskey_for_key KEY1 "dig.out.$DIR.test$n.cdnskey" || log_error "missing CDNSKEY record in response for key $(key_get KEY1 ID)"
check_signatures "CDNSKEY" "dig.out.$DIR.test$n.cdnskey" "KSK"
response_has_cds_for_key KEY1 "dig.out.$DIR.test$n" || log_error "missing ${_qtype} record in response for key $(key_get KEY1 ID)"
check_signatures $_qtype "dig.out.$DIR.test$n" "KSK"
elif [ "$(key_get KEY1 EXPECT)" = "yes" ]; then
response_has_cds_for_key KEY1 "dig.out.$DIR.test$n.cds" && log_error "unexpected CDS record in response for key $(key_get KEY1 ID)"
# KEY1 should not have an associated CDNSKEY, but there may be
# one for another key. Since the CDNSKEY has no field for key
# id, it is hard to check what key the CDNSKEY may belong to
# so let's skip this check for now.
response_has_cds_for_key KEY1 "dig.out.$DIR.test$n" && log_error "unexpected ${_qtype} record in response for key $(key_get KEY1 ID)"
fi
if [ "$(key_get KEY2 STATE_DS)" = "rumoured" ] || [ "$(key_get KEY2 STATE_DS)" = "omnipresent" ]; then
response_has_cds_for_key KEY2 "dig.out.$DIR.test$n.cds" || log_error "missing CDS record in response for key $(key_get KEY2 ID)"
check_signatures "CDS" "dig.out.$DIR.test$n.cds" "KSK"
response_has_cdnskey_for_key KEY2 "dig.out.$DIR.test$n.cdnskey" || log_error "missing CDNSKEY record in response for key $(key_get KEY2 ID)"
check_signatures "CDNSKEY" "dig.out.$DIR.test$n.cdnskey" "KSK"
response_has_cds_for_key KEY2 "dig.out.$DIR.test$n" || log_error "missing ${_qtype} record in response for key $(key_get KEY2 ID)"
check_signatures $_qtype "dig.out.$DIR.test$n" "KSK"
elif [ "$(key_get KEY2 EXPECT)" = "yes" ]; then
response_has_cds_for_key KEY2 "dig.out.$DIR.test$n.cds" && log_error "unexpected CDS record in response for key $(key_get KEY2 ID)"
# KEY2 should not have an associated CDNSKEY, but there may be
# one for another key. Since the CDNSKEY has no field for key
# id, it is hard to check what key the CDNSKEY may belong to
# so let's skip this check for now.
response_has_cds_for_key KEY2 "dig.out.$DIR.test$n" && log_error "unexpected ${_qtype} record in response for key $(key_get KEY2 ID)"
fi
if [ "$(key_get KEY3 STATE_DS)" = "rumoured" ] || [ "$(key_get KEY3 STATE_DS)" = "omnipresent" ]; then
response_has_cds_for_key KEY3 "dig.out.$DIR.test$n.cds" || log_error "missing CDS record in response for key $(key_get KEY3 ID)"
check_signatures "CDS" "dig.out.$DIR.test$n.cds" "KSK"
response_has_cdnskey_for_key KEY3 "dig.out.$DIR.test$n.cdnskey" || log_error "missing CDNSKEY record in response for key $(key_get KEY3 ID)"
check_signatures "CDNSKEY" "dig.out.$DIR.test$n.cdnskey" "KSK"
response_has_cds_for_key KEY3 "dig.out.$DIR.test$n" || log_error "missing ${_qtype} record in response for key $(key_get KEY3 ID)"
check_signatures $_qtype "dig.out.$DIR.test$n" "KSK"
elif [ "$(key_get KEY3 EXPECT)" = "yes" ]; then
response_has_cds_for_key KEY3 "dig.out.$DIR.test$n.cds" && log_error "unexpected CDS record in response for key $(key_get KEY3 ID)"
# KEY3 should not have an associated CDNSKEY, but there may be
# one for another key. Since the CDNSKEY has no field for key
# id, it is hard to check what key the CDNSKEY may belong to
# so let's skip this check for now.
response_has_cds_for_key KEY3 "dig.out.$DIR.test$n" && log_error "unexpected ${_qtype} record in response for key $(key_get KEY3 ID)"
fi
test "$ret" -eq 0 || echo_i "failed"
@@ -990,7 +957,7 @@ check_apex() {
test "$ret" -eq 0 || echo_i "failed"
status=$((status+ret))
# Test CDS and CDNSKEY publication.
# Test CDS publication.
check_cds
}
@@ -1089,17 +1056,6 @@ check_apex
check_subdomain
dnssec_verify
#
# Zone: rumoured.kasp.
#
# There are three keys in rumoured state.
zone_properties "ns3" "rumoured.kasp" "rsasha1" "1234" "3" "10.53.0.3"
# key_properties, key_timings and key_states same as above.
check_keys
check_apex
check_subdomain
dnssec_verify
#
# Zone: secondary.kasp.
#
+2 -12
View File
@@ -45,10 +45,9 @@ my $A = "ns.example 300 IN A $localaddr";
#
# Records to be TTL stretched
#
my $TXT = "data.example 2 IN TXT \"A text record with a 2 second ttl\"";
my $TXT = "data.example 1 IN TXT \"A text record with a 1 second ttl\"";
my $LONGTXT = "longttl.example 600 IN TXT \"A text record with a 600 second ttl\"";
my $CAA = "othertype.example 2 IN CAA 0 issue \"ca1.example.net\"";
my $negSOA = "example 2 IN SOA . . 0 0 0 0 300";
my $negSOA = "example 1 IN SOA . . 0 0 0 0 300";
sub reply_handler {
my ($qname, $qclass, $qtype) = @_;
@@ -130,15 +129,6 @@ sub reply_handler {
my $rr = new Net::DNS::RR($negSOA);
push @auth, $rr;
$rcode = "NXDOMAIN";
} elsif ($qname eq "othertype.example") {
if ($qtype eq "CAA") {
my $rr = new Net::DNS::RR($CAA);
push @ans, $rr;
} else {
my $rr = new Net::DNS::RR($negSOA);
push @auth, $rr;
}
$rcode = "NOERROR";
} else {
my $rr = new Net::DNS::RR($SOA);
push @auth, $rr;
@@ -27,7 +27,7 @@ options {
listen-on { 10.53.0.1; };
listen-on-v6 { none; };
recursion yes;
max-stale-ttl 45;
max-stale-ttl 35;
stale-answer-ttl 3;
stale-answer-enable yes;
};
+22 -175
View File
@@ -30,7 +30,6 @@ n=0
#$DIG -p ${PORT} @10.53.0.2 data.example TXT
#$DIG -p ${PORT} @10.53.0.2 nodata.example TXT
#$DIG -p ${PORT} @10.53.0.2 nxdomain.example TXT
#$DIG -p ${PORT} @10.53.0.2 othertype.example CAA
#
# First test server with serve-stale options set.
@@ -55,15 +54,6 @@ grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "prime cache othertype.example ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 othertype.example CAA > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "prime cache nodata.example ($n)"
ret=0
@@ -92,7 +82,6 @@ cp ns1/named.stats ns1/named.stats.$n
# Check first 10 lines of Cache DB statistics. After prime queries, we expect
# two active TXT one nxrrset TXT, and one NXDOMAIN.
grep -A 10 "++ Cache DB RRsets ++" ns1/named.stats.$n > ns1/named.stats.$n.cachedb || ret=1
grep "1 Others" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "2 TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 !TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 NXDOMAIN" ns1/named.stats.$n.cachedb > /dev/null || ret=1
@@ -108,7 +97,7 @@ grep "TXT.\"0\"" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
sleep 2
sleep 1
n=`expr $n + 1`
echo_i "check 'rndc serve-stale status' ($n)"
@@ -124,29 +113,19 @@ ret=0
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*2.*IN.*TXT.*A text record with a 2 second ttl" dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
# Run rndc dumpdb, test whether the stale data has correct comment printed.
# The max-stale-ttl is 3600 seconds, so the comment should say the data is
# stale for somewhere between 3500-3599 seconds.
rndc_dumpdb ns1 || ret=1
awk '/; stale/ { x=$0; getline; print x, $0}' ns1/named_dump.db.test$n |
grep "; stale (will be retained for 35.. more seconds) data\.example.*A text record with a 2 second ttl" > /dev/null 2>&1 || ret=1
grep "; stale (will be retained for 35.. more seconds) data\.example.*A text record with a 1 second ttl" > /dev/null 2>&1 || ret=1
# Also make sure the not expired data does not have a stale comment.
awk '/; answer/ { x=$0; getline; print x, $0}' ns1/named_dump.db.test$n |
grep "; answer longttl\.example.*A text record with a 600 second ttl" > /dev/null 2>&1 || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check stale othertype.example ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 othertype.example CAA > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "othertype\.example\..*2.*IN.*CAA.*0.*issue" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check stale nodata.example ($n)"
ret=0
@@ -179,7 +158,6 @@ cp ns1/named.stats ns1/named.stats.$n
# stale NXDOMAIN.
grep -A 10 "++ Cache DB RRsets ++" ns1/named.stats.$n > ns1/named.stats.$n.cachedb || ret=1
grep "1 TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #Others" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #!TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #NXDOMAIN" ns1/named.stats.$n.cachedb > /dev/null || ret=1
@@ -211,14 +189,6 @@ status=`expr $status + $ret`
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check stale othertype.example (serve-stale off) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 othertype.example CAA > dig.out.test$n
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check stale nodata.example (serve-stale off) ($n)"
ret=0
@@ -256,17 +226,7 @@ ret=0
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*2.*IN.*TXT.*A text record with a 2 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check stale othertype.example (serve-stale on) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 othertype.example CAA > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "othertype\.example\..*2.*IN.*CAA.*0.*issue" dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -313,14 +273,6 @@ grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check stale othertype.example (serve-stale no) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 othertype.example CAA > dig.out.test$n
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check stale nodata.example (serve-stale no) ($n)"
ret=0
@@ -358,17 +310,7 @@ ret=0
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*2.*IN.*TXT.*A text record with a 2 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check stale othertype.example (serve-stale yes) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 othertype.example CAA > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "othertype\.example\..*2.*IN.*CAA.*0.*issue" dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -420,17 +362,7 @@ ret=0
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*2.*IN.*TXT.*A text record with a 2 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check stale othertype.example (serve-stale reset) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 othertype.example CAA > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "othertype.example\..*2.*IN.*CAA.*0.*issue" dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*2.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -493,7 +425,7 @@ n=`expr $n + 1`
echo_i "check 'rndc serve-stale status' ($n)"
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
grep '_default: off (rndc) (stale-answer-ttl=3 max-stale-ttl=45)' rndc.out.test$n > /dev/null || ret=1
grep '_default: off (rndc) (stale-answer-ttl=3 max-stale-ttl=35)' rndc.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -512,7 +444,7 @@ n=`expr $n + 1`
echo_i "check 'rndc serve-stale status' ($n)"
ret=0
$RNDCCMD 10.53.0.1 serve-stale status > rndc.out.test$n 2>&1 || ret=1
grep '_default: on (rndc) (stale-answer-ttl=3 max-stale-ttl=45)' rndc.out.test$n > /dev/null || ret=1
grep '_default: on (rndc) (stale-answer-ttl=3 max-stale-ttl=35)' rndc.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -525,7 +457,7 @@ grep "TXT.\"1\"" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
sleep 2
sleep 1
n=`expr $n + 1`
echo_i "prime cache longttl.example (low max-stale-ttl) ($n)"
@@ -545,15 +477,6 @@ grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "prime cache othertype.example (low max-stale-ttl) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 othertype.example CAA > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "prime cache nodata.example (low max-stale-ttl) ($n)"
ret=0
@@ -583,7 +506,6 @@ cp ns1/named.stats ns1/named.stats.$n
# two active TXT RRsets, one nxrrset TXT, and one NXDOMAIN.
grep -A 10 "++ Cache DB RRsets ++" ns1/named.stats.$n > ns1/named.stats.$n.cachedb || ret=1
grep "2 TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 Others" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 !TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 NXDOMAIN" ns1/named.stats.$n.cachedb > /dev/null || ret=1
status=`expr $status + $ret`
@@ -598,7 +520,7 @@ grep "TXT.\"0\"" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
sleep 2
sleep 1
n=`expr $n + 1`
echo_i "check stale data.example (low max-stale-ttl) ($n)"
@@ -606,17 +528,7 @@ ret=0
$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*3.*IN.*TXT.*A text record with a 2 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check stale othertype.example (low max-stale-ttl) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 othertype.example CAA > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "othertype\.example\..*3.*IN.*CAA.*0.*issue" dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*3.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -653,14 +565,12 @@ cp ns1/named.stats ns1/named.stats.$n
grep -A 10 "++ Cache DB RRsets ++" ns1/named.stats.$n > ns1/named.stats.$n.cachedb || ret=1
grep "1 TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #Others" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #!TXT" ns1/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #NXDOMAIN" ns1/named.stats.$n.cachedb > /dev/null || ret=1
status=`expr $status + $ret`
if [ $ret != 0 ]; then echo_i "failed"; fi
sleep 2
sleep 1
n=`expr $n + 1`
echo_i "check ancient data.example (low max-stale-ttl) ($n)"
@@ -671,15 +581,6 @@ grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check ancient othertype.example (low max-stale-ttl) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.1 othertype.example CAA > dig.out.test$n
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check ancient nodata.example (low max-stale-ttl) ($n)"
ret=0
@@ -727,17 +628,7 @@ ret=0
$DIG -p ${PORT} @10.53.0.3 data.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*2.*IN.*TXT.*A text record with a 2 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "prime cache othertype.example (max-stale-ttl default) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.3 othertype.example CAA > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "othertype\.example\..*2.*IN.*CAA.*0.*issue" dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*1.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -747,7 +638,7 @@ ret=0
$DIG -p ${PORT} @10.53.0.3 nodata.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -757,7 +648,7 @@ ret=0
$DIG -p ${PORT} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -772,7 +663,6 @@ cp ns3/named.stats ns3/named.stats.$n
# two active TXT RRsets, one nxrrset TXT, and one NXDOMAIN.
grep -A 10 "++ Cache DB RRsets ++" ns3/named.stats.$n > ns3/named.stats.$n.cachedb || ret=1
grep "2 TXT" ns3/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 Others" ns3/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 !TXT" ns3/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 NXDOMAIN" ns3/named.stats.$n.cachedb > /dev/null || ret=1
status=`expr $status + $ret`
@@ -787,7 +677,7 @@ grep "TXT.\"0\"" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
sleep 2
sleep 1
n=`expr $n + 1`
echo_i "check 'rndc serve-stale status' ($n)"
@@ -806,15 +696,6 @@ grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check fail of othertype.example (max-stale-ttl default) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.3 othertype.example CAA > dig.out.test$n
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check fail of nodata.example (max-stale-ttl default) ($n)"
ret=0
@@ -846,10 +727,8 @@ cp ns3/named.stats ns3/named.stats.$n
grep -A 10 "++ Cache DB RRsets ++" ns3/named.stats.$n > ns3/named.stats.$n.cachedb || ret=1
grep "1 TXT" ns3/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #TXT" ns3/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #Others" ns3/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #!TXT" ns3/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #NXDOMAIN" ns3/named.stats.$n.cachedb > /dev/null || ret=1
status=`expr $status + $ret`
if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -874,17 +753,7 @@ ret=0
$DIG -p ${PORT} @10.53.0.3 data.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*1.*IN.*TXT.*A text record with a 2 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check othertype.example (max-stale-ttl default) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.3 othertype.example CAA > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "example\..*1.*IN.*CAA.*0.*issue" dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*1.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -937,17 +806,7 @@ ret=0
$DIG -p ${PORT} @10.53.0.4 data.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*2.*IN.*TXT.*A text record with a 2 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "prime cache othertype.example (serve-stale disabled) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.4 othertype.example CAA > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
grep "othertype\.example\..*2.*IN.*CAA.*0.*issue" dig.out.test$n > /dev/null || ret=1
grep "data\.example\..*1.*IN.*TXT.*A text record with a 1 second ttl" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -957,7 +816,7 @@ ret=0
$DIG -p ${PORT} @10.53.0.4 nodata.example TXT > dig.out.test$n
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -967,7 +826,7 @@ ret=0
$DIG -p ${PORT} @10.53.0.4 nxdomain.example TXT > dig.out.test$n
grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
grep "example\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@@ -982,7 +841,6 @@ cp ns4/named.stats ns4/named.stats.$n
# two active TXT RRsets, one nxrrset TXT, and one NXDOMAIN.
grep -A 10 "++ Cache DB RRsets ++" ns4/named.stats.$n > ns4/named.stats.$n.cachedb || ret=1
grep "2 TXT" ns4/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 Others" ns4/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 !TXT" ns4/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 NXDOMAIN" ns4/named.stats.$n.cachedb > /dev/null || ret=1
status=`expr $status + $ret`
@@ -997,7 +855,7 @@ grep "TXT.\"0\"" dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
sleep 2
sleep 1
n=`expr $n + 1`
echo_i "check 'rndc serve-stale status' ($n)"
@@ -1016,15 +874,6 @@ grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check fail of othertype.example (serve-stale disabled) ($n)"
ret=0
$DIG -p ${PORT} @10.53.0.4 othertype.example CAA > dig.out.test$n
grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check fail of nodata.example (serve-stale disabled) ($n)"
ret=0
@@ -1056,7 +905,6 @@ cp ns4/named.stats ns4/named.stats.$n
grep -A 10 "++ Cache DB RRsets ++" ns4/named.stats.$n > ns4/named.stats.$n.cachedb || ret=1
grep "1 TXT" ns4/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #TXT" ns4/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #Others" ns4/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #!TXT" ns4/named.stats.$n.cachedb > /dev/null || ret=1
grep "1 #NXDOMAIN" ns4/named.stats.$n.cachedb > /dev/null || ret=1
status=`expr $status + $ret`
@@ -1099,7 +947,7 @@ status=`expr $status + $ret`
echo_i "start ns4"
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} serve-stale ns4
sleep 2
sleep 1
n=`expr $n + 1`
echo_i "verify ancient cache statistics (serve-stale disabled) ($n)"
@@ -1112,7 +960,6 @@ cp ns4/named.stats ns4/named.stats.$n
# everything to be removed or scheduled to be removed.
grep -A 10 "++ Cache DB RRsets ++" ns4/named.stats.$n > ns4/named.stats.$n.cachedb || ret=1
grep "#TXT" ns4/named.stats.$n.cachedb > /dev/null && ret=1
grep "#Others" ns4/named.stats.$n.cachedb > /dev/null && ret=1
grep "#!TXT" ns4/named.stats.$n.cachedb > /dev/null && ret=1
grep "#NXDOMAIN" ns4/named.stats.$n.cachedb > /dev/null && ret=1
status=`expr $status + $ret`
+2 -1
View File
@@ -175,7 +175,8 @@ main(int argc, char *argv[]) {
} else
f = stdin;
isc_buffer_allocate(mctx, &input, 64 * 1024);
result = isc_buffer_allocate(mctx, &input, 64 * 1024);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
if (rawdata) {
while (fread(&c, 1, 1, f) != 0) {
+7 -3
View File
@@ -309,7 +309,8 @@ recvresponse(isc_task_t *task, isc_event_t *event) {
if (!display_comments)
flags |= DNS_MESSAGETEXTFLAG_NOCOMMENTS;
isc_buffer_allocate(mctx, &buf, len);
result = isc_buffer_allocate(mctx, &buf, len);
CHECK("isc_buffer_allocate", result);
if (yaml) {
char sockstr[ISC_SOCKADDR_FORMATSIZE];
@@ -415,8 +416,11 @@ repopulate_buffer:
buftoosmall:
len += OUTPUTBUF;
isc_buffer_free(&buf);
isc_buffer_allocate(mctx, &buf, len);
goto repopulate_buffer;
result = isc_buffer_allocate(mctx, &buf, len);
if (result == ISC_R_SUCCESS)
goto repopulate_buffer;
else
goto cleanup;
}
CHECK("dns_message_pseudosectiontotext", result);
}
@@ -1,84 +0,0 @@
@@
statement S;
expression V;
@@
- V =
isc_buffer_allocate(...);
- if (V != ISC_R_SUCCESS) S
@@
statement S1, S2;
expression V;
@@
- V =
isc_buffer_allocate(...);
- if (V == ISC_R_SUCCESS)
S1
- else S2
@@
expression V;
@@
- V =
isc_buffer_allocate(...);
- check_result(V, ...);
@@
@@
- CHECK(
isc_buffer_allocate(...)
- )
;
@@
@@
- DO(...,
isc_buffer_allocate(...)
- )
;
@@
@@
- RETERR(
isc_buffer_allocate(...)
- )
;
@@
expression V;
@@
- V =
isc_buffer_allocate(...);
- assert_int_equal(V, ISC_R_SUCCESS);
@@
expression V;
@@
- V =
isc_buffer_allocate(...);
- CHECK(..., V);
@@
expression V;
statement S;
@@
- V =
isc_buffer_allocate(...);
- if (ISC_UNLIKELY(V != ISC_R_SUCCESS)) S
@@
expression V;
@@
- V =
isc_buffer_allocate(...);
- RUNTIME_CHECK(V == ISC_R_SUCCESS);
@@ -1,49 +0,0 @@
@@
expression V;
@@
- V =
isc_mempool_create(...);
- assert_int_equal(V, ISC_R_SUCCESS);
@@
expression V;
@@
- V =
isc_mempool_create(...);
- check_result(V, ...);
@@
@@
- CHECK(
isc_mempool_create(...)
- )
;
@@
@@
- RUNTIME_CHECK(
isc_mempool_create(...)
- == ISC_R_SUCCESS)
;
@@
expression V;
statement S;
@@
- V =
isc_mempool_create(...);
- if (V != ISC_R_SUCCESS) S
@@
statement S;
@@
- if (
isc_mempool_create(...)
- != ISC_R_SUCCESS) S
+ ;
Vendored
+11 -19
View File
@@ -852,7 +852,6 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -1026,7 +1025,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1279,15 +1277,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1425,7 +1414,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir runstatedir
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1578,7 +1567,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -4023,7 +4011,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -4069,7 +4057,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -4093,7 +4081,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -4138,7 +4126,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -4162,7 +4150,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -16058,7 +16046,7 @@ esac
if test "${enable_pthread_rwlock+set}" = set; then :
enableval=$enable_pthread_rwlock;
else
enable_pthread_rwlock=yes
enable_pthread_rwlock=no
fi
@@ -16082,6 +16070,10 @@ $as_echo "#define USE_PTHREAD_RWLOCK 1" >>confdefs.h
fi
if test "$enable_pthread_rwlock" = "yes" -a "$enable_developer" != "yes"; then :
as_fn_error $? "pthread rwlock is not meant used in production and the developer mode must be enabled" "$LINENO" 5
fi
CRYPTO=OpenSSL
#
+4 -1
View File
@@ -721,7 +721,7 @@ AC_SUBST(INSTALL_LIBRARY)
AC_ARG_ENABLE([pthread_rwlock],
[AS_HELP_STRING([--enable-pthread-rwlock],
[use pthread rwlock instead of internal rwlock implementation (EXPERIMENTAL)])],
[], [enable_pthread_rwlock=yes])
[], [enable_pthread_rwlock=no])
AS_IF([test "$enable_pthread_rwlock" = "yes"],
[AC_CHECK_FUNCS([pthread_rwlock_rdlock], [],
@@ -729,6 +729,9 @@ AS_IF([test "$enable_pthread_rwlock" = "yes"],
AC_DEFINE([USE_PTHREAD_RWLOCK],[1],[Define if you want to use pthread rwlock implementation])
])
AS_IF([test "$enable_pthread_rwlock" = "yes" -a "$enable_developer" != "yes"],
[AC_MSG_ERROR([pthread rwlock is not meant used in production and the developer mode must be enabled])])
CRYPTO=OpenSSL
#
+33 -15
View File
@@ -157,7 +157,7 @@ is_safe(const char *input) {
return (true);
}
static void
static isc_result_t
create_path_helper(char *out, const char *in, config_data_t *cd) {
char *tmpString;
char *tmpPtr;
@@ -206,6 +206,7 @@ create_path_helper(char *out, const char *in, config_data_t *cd) {
}
isc_mem_free(named_g_mctx, tmpString);
return (ISC_R_SUCCESS);
}
/*%
@@ -222,6 +223,7 @@ create_path(const char *zone, const char *host, const char *client,
char *tmpPath;
int pathsize;
int len;
isc_result_t result;
bool isroot = false;
/* we require a zone & cd parameter */
@@ -283,7 +285,9 @@ create_path(const char *zone, const char *host, const char *client,
/* add zone name - parsed properly */
if (!isroot) {
create_path_helper(tmpPath, zone, cd);
result = create_path_helper(tmpPath, zone, cd);
if (result != ISC_R_SUCCESS)
goto cleanup_mem;
}
/*
@@ -318,13 +322,26 @@ create_path(const char *zone, const char *host, const char *client,
/* if host not null, add it. */
if (host != NULL) {
strncat(tmpPath, (char *) &cd->pathsep, 1);
create_path_helper(tmpPath, host, cd);
if ((result = create_path_helper(tmpPath, host,
cd)) != ISC_R_SUCCESS)
goto cleanup_mem;
}
/* return the path we built. */
*path = tmpPath;
return (ISC_R_SUCCESS);
/* return success */
result = ISC_R_SUCCESS;
cleanup_mem:
/* cleanup memory */
/* free tmpPath memory */
if (tmpPath != NULL && result != ISC_R_SUCCESS)
isc_mem_free(named_g_mctx, tmpPath);
/* free tmpPath memory */
return (result);
}
static isc_result_t
@@ -688,19 +705,20 @@ fs_allnodes(const char *zone, void *driverarg, void *dbdata,
} /* end while */
complete_allnds:
/* clean up entries from list. */
dir_entry = ISC_LIST_HEAD(*dir_list);
while (dir_entry != NULL) {
next_de = ISC_LIST_NEXT(dir_entry, link);
isc_mem_put(named_g_mctx, dir_entry, sizeof(dir_entry_t));
dir_entry = next_de;
} /* end while */
isc_mem_put(named_g_mctx, dir_list, sizeof(dlist_t));
if (basepath != NULL) {
isc_mem_free(named_g_mctx, basepath);
if (dir_list != NULL) {
/* clean up entries from list. */
dir_entry = ISC_LIST_HEAD(*dir_list);
while (dir_entry != NULL) {
next_de = ISC_LIST_NEXT(dir_entry, link);
isc_mem_put(named_g_mctx, dir_entry, sizeof(dir_entry_t));
dir_entry = next_de;
} /* end while */
isc_mem_put(named_g_mctx, dir_list, sizeof(dlist_t));
}
if (basepath != NULL)
isc_mem_free(named_g_mctx, basepath);
return (result);
}
+2 -1
View File
@@ -254,7 +254,8 @@ build_querylist(isc_mem_t *mctx, const char *query_str, char **zone,
flag_fail:
/* get rid of what was build of the query list */
destroy_querylist(mctx, &tql);
if (tql != NULL)
destroy_querylist(mctx, &tql);
return result;
}
-30
View File
@@ -1,30 +0,0 @@
#!/usr/bin/python
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
# catzhash.py: generate the SHA-1 hash of a domain name in wire format.
#
# This can be used to determine the label to use in a catalog zone to
# represent the specified zone. For example, the zone
# "domain.example" can be represented in a catalog zone called
# "catalog.example" by adding the following record:
#
# 5960775ba382e7a4e09263fc06e7c00569b6a05c.zones.catalog.example. IN PTR domain.example.
#
# The label "5960775ba382e7a4e09263fc06e7c00569b6a05c" is the output of
# this script when run with the argument "domain.example".
import sys
import dns.name
import hashlib
if len(sys.argv) < 2:
print("Usage: %s name" % sys.argv[0])
print (hashlib.sha1(dns.name.from_text(sys.argv[1]).to_wire()).hexdigest())
+3 -5
View File
@@ -6866,11 +6866,9 @@ options {
<term><command>forwarders</command></term>
<listitem>
<para>
Specifies a list of IP addresses to which queries shall be
forwarded. The default is the empty list (no forwarding).
Each address in the list can be associated with an optional
port number and/or DSCP value, and a default port number and
DSCP value can be set for the entire list.
Specifies the IP addresses to be used
for forwarding. The default is the empty list (no
forwarding).
</para>
</listitem>
</varlistentry>
+3 -1
View File
@@ -2646,7 +2646,9 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
* Memory pools
*/
#define MPINIT(t, p, n) do { \
isc_mempool_create(mem, sizeof(t), &(p)); \
result = isc_mempool_create(mem, sizeof(t), &(p)); \
if (result != ISC_R_SUCCESS) \
goto fail2; \
isc_mempool_setfreemax((p), FREE_ITEMS); \
isc_mempool_setfillcount((p), FILL_COUNT); \
isc_mempool_setname((p), n); \
+29 -40
View File
@@ -522,8 +522,8 @@ dns_catz_zones_merge(dns_catz_zone_t *target, dns_catz_zone_t *newzone) {
dns_name_format(&entry->name, zname, DNS_NAME_FORMATSIZE);
result = addzone(entry, target, target->catzs->view,
target->catzs->taskmgr,
target->catzs->zmm->udata);
target->catzs->taskmgr,
target->catzs->zmm->udata);
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
DNS_LOGMODULE_MASTER, ISC_LOG_INFO,
"catz: adding zone '%s' from catalog "
@@ -1239,8 +1239,10 @@ catz_process_apl(dns_catz_zone_t *zone, isc_buffer_t **aclbp,
result = dns_rdata_tostruct(&rdata, &rdata_apl, zone->catzs->mctx);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_allocate(zone->catzs->mctx, &aclb, 16);
result = isc_buffer_allocate(zone->catzs->mctx, &aclb, 16);
isc_buffer_setautorealloc(aclb, true);
if (result != ISC_R_SUCCESS)
goto cleanup;
for (result = dns_rdata_apl_first(&rdata_apl);
result == ISC_R_SUCCESS;
result = dns_rdata_apl_next(&rdata_apl)) {
@@ -1455,52 +1457,39 @@ dns_catz_generate_masterfilename(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
isc_region_t r;
isc_result_t result;
size_t rlen;
bool special = false;
REQUIRE(DNS_CATZ_ZONE_VALID(zone));
REQUIRE(entry != NULL);
REQUIRE(buffer != NULL && *buffer != NULL);
isc_buffer_allocate(zone->catzs->mctx, &tbuf,
strlen(zone->catzs->view->name) + 2 *
DNS_NAME_FORMATSIZE + 2);
result = isc_buffer_allocate(zone->catzs->mctx, &tbuf,
strlen(zone->catzs->view->name) +
2 * DNS_NAME_FORMATSIZE + 2);
if (result != ISC_R_SUCCESS)
return (result);
INSIST(tbuf != NULL);
isc_buffer_putstr(tbuf, zone->catzs->view->name);
isc_buffer_putstr(tbuf, "_");
result = dns_name_totext(&zone->name, true, tbuf);
if (result != ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
goto cleanup;
}
isc_buffer_putstr(tbuf, "_");
result = dns_name_totext(&entry->name, true, tbuf);
if (result != ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
goto cleanup;
}
/*
* Search for slash and other special characters in the view and
* zone names. Add a null terminator so we can use strpbrk(), then
* remove it.
*/
isc_buffer_putuint8(tbuf, 0);
if (strpbrk(isc_buffer_base(tbuf), "\\/:") != NULL) {
special = true;
}
isc_buffer_subtract(tbuf, 1);
/* __catz__<digest>.db */
rlen = (isc_md_type_get_size(ISC_MD_SHA256) * 2 + 1) + 12;
/* optionally prepend with <zonedir>/ */
if (entry->opts.zonedir != NULL) {
if (entry->opts.zonedir != NULL)
rlen += strlen(entry->opts.zonedir) + 1;
}
result = isc_buffer_reserve(buffer, (unsigned int)rlen);
if (result != ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
goto cleanup;
}
if (entry->opts.zonedir != NULL) {
isc_buffer_putstr(*buffer, entry->opts.zonedir);
@@ -1509,10 +1498,9 @@ dns_catz_generate_masterfilename(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
isc_buffer_usedregion(tbuf, &r);
isc_buffer_putstr(*buffer, "__catz__");
if (special || tbuf->used > ISC_SHA256_DIGESTLENGTH * 2 + 1) {
if (tbuf->used > ISC_SHA256_DIGESTLENGTH * 2 + 1) {
unsigned char digest[ISC_MAX_MD_SIZE];
unsigned int digestlen;
/* we can do that because digest string < 2 * DNS_NAME */
result = isc_md(ISC_MD_SHA256, r.base, r.length,
digest, &digestlen);
@@ -1543,7 +1531,7 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
{
/*
* We have to generate a text buffer with regular zone config:
* zone "foo.bar" {
* zone foo.bar {
* type slave;
* masters [ dscp X ] { ip1 port port1; ip2 port port2; };
* }
@@ -1564,12 +1552,16 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
* The buffer will be reallocated if something won't fit,
* ISC_BUFFER_INCR seems like a good start.
*/
isc_buffer_allocate(zone->catzs->mctx, &buffer, ISC_BUFFER_INCR);
result = isc_buffer_allocate(zone->catzs->mctx, &buffer,
ISC_BUFFER_INCR);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
isc_buffer_setautorealloc(buffer, true);
isc_buffer_putstr(buffer, "zone \"");
isc_buffer_putstr(buffer, "zone ");
dns_name_totext(&entry->name, true, buffer);
isc_buffer_putstr(buffer, "\" { type slave; masters");
isc_buffer_putstr(buffer, " { type slave; masters");
/*
* DSCP value has no default, but when it is specified, it is identical
@@ -1577,8 +1569,7 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
* use the DSCP value set for the first master
*/
if (entry->opts.masters.count > 0 &&
entry->opts.masters.dscps[0] >= 0)
{
entry->opts.masters.dscps[0] >= 0) {
isc_buffer_putstr(buffer, " dscp ");
snprintf(pbuf, sizeof(pbuf), "%hd",
entry->opts.masters.dscps[0]);
@@ -1620,9 +1611,8 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
isc_buffer_putstr(buffer, " key ");
result = dns_name_totext(entry->opts.masters.keys[i],
true, buffer);
if (result != ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
goto cleanup;
}
}
isc_buffer_putstr(buffer, "; ");
}
@@ -1630,9 +1620,8 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
if (entry->opts.in_memory == false) {
isc_buffer_putstr(buffer, "file \"");
result = dns_catz_generate_masterfilename(zone, entry, &buffer);
if (result != ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
goto cleanup;
}
isc_buffer_putstr(buffer, "\"; ");
}
@@ -1651,11 +1640,11 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
isc_buffer_putstr(buffer, "};");
*buf = buffer;
return (ISC_R_SUCCESS);
cleanup:
isc_buffer_free(&buffer);
if (buffer != NULL)
isc_buffer_free(&buffer);
return (result);
}
+15 -5
View File
@@ -1393,7 +1393,8 @@ dns_client_startresolve(dns_client_t *client, const dns_name_t *name,
isc_mutex_destroy(&rctx->lock);
isc_mem_put(mctx, rctx, sizeof(*rctx));
}
isc_event_free(ISC_EVENT_PTR(&event));
if (event != NULL)
isc_event_free(ISC_EVENT_PTR(&event));
isc_task_detach(&tclone);
dns_view_detach(&view);
@@ -1488,6 +1489,7 @@ dns_client_addtrustedkey(dns_client_t *client, dns_rdataclass_t rdclass,
{
isc_result_t result;
dns_view_t *view = NULL;
dst_key_t *dstkey = NULL;
dns_keytable_t *secroots = NULL;
dns_name_t *name = NULL;
char dsbuf[DNS_DS_BUFFERSIZE];
@@ -1532,6 +1534,9 @@ dns_client_addtrustedkey(dns_client_t *client, dns_rdataclass_t rdclass,
CHECK(dns_keytable_add(secroots, false, false, name, &ds));
cleanup:
if (dstkey != NULL) {
dst_key_free(&dstkey);
}
if (view != NULL) {
dns_view_detach(&view);
}
@@ -1775,8 +1780,8 @@ dns_client_startrequest(dns_client_t *client, dns_message_t *qmessage,
UNLOCK(&client->lock);
isc_mutex_destroy(&ctx->lock);
isc_mem_put(client->mctx, ctx, sizeof(*ctx));
isc_event_free(ISC_EVENT_PTR(&event));
if (event != NULL)
isc_event_free(ISC_EVENT_PTR(&event));
isc_task_detach(&tclone);
dns_view_detach(&view);
@@ -2536,7 +2541,9 @@ copy_name(isc_mem_t *mctx, dns_message_t *msg, const dns_name_t *name,
result = dns_message_gettempname(msg, &newname);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_allocate(mctx, &namebuf, DNS_NAME_MAXWIRE);
result = isc_buffer_allocate(mctx, &namebuf, DNS_NAME_MAXWIRE);
if (result != ISC_R_SUCCESS)
goto fail;
dns_name_init(newname, NULL);
dns_name_setbuffer(newname, namebuf);
dns_message_takebuffer(msg, &namebuf);
@@ -2565,7 +2572,10 @@ copy_name(isc_mem_t *mctx, dns_message_t *msg, const dns_name_t *name,
goto fail;
dns_rdata_toregion(&rdata, &r);
rdatabuf = NULL;
isc_buffer_allocate(mctx, &rdatabuf, r.length);
result = isc_buffer_allocate(mctx, &rdatabuf,
r.length);
if (result != ISC_R_SUCCESS)
goto fail;
isc_buffer_putmem(rdatabuf, r.base, r.length);
isc_buffer_usedregion(rdatabuf, &r);
dns_rdata_init(newrdata);
+41 -11
View File
@@ -1762,16 +1762,25 @@ dns_dispatchmgr_create(isc_mem_t *mctx, dns_dispatchmgr_t **mgrp)
isc_mutex_init(&mgr->spool_lock);
mgr->depool = NULL;
isc_mempool_create(mgr->mctx, sizeof(dns_dispatchevent_t),
&mgr->depool);
if (isc_mempool_create(mgr->mctx, sizeof(dns_dispatchevent_t),
&mgr->depool) != ISC_R_SUCCESS) {
result = ISC_R_NOMEMORY;
goto kill_locks;
}
mgr->rpool = NULL;
isc_mempool_create(mgr->mctx, sizeof(dns_dispentry_t),
&mgr->rpool);
if (isc_mempool_create(mgr->mctx, sizeof(dns_dispentry_t),
&mgr->rpool) != ISC_R_SUCCESS) {
result = ISC_R_NOMEMORY;
goto kill_depool;
}
mgr->dpool = NULL;
isc_mempool_create(mgr->mctx, sizeof(dns_dispatch_t),
&mgr->dpool);
if (isc_mempool_create(mgr->mctx, sizeof(dns_dispatch_t),
&mgr->dpool) != ISC_R_SUCCESS) {
result = ISC_R_NOMEMORY;
goto kill_rpool;
}
isc_mempool_setname(mgr->depool, "dispmgr_depool");
isc_mempool_setmaxalloc(mgr->depool, 32768);
@@ -1826,8 +1835,11 @@ dns_dispatchmgr_create(isc_mem_t *mctx, dns_dispatchmgr_t **mgrp)
kill_dpool:
isc_mempool_destroy(&mgr->dpool);
kill_rpool:
isc_mempool_destroy(&mgr->rpool);
kill_depool:
isc_mempool_destroy(&mgr->depool);
kill_locks:
isc_mutex_destroy(&mgr->spool_lock);
isc_mutex_destroy(&mgr->bpool_lock);
isc_mutex_destroy(&mgr->dpool_lock);
@@ -1974,7 +1986,11 @@ dns_dispatchmgr_setudp(dns_dispatchmgr_t *mgr,
mgr->maxbuffers = maxbuffers;
}
} else {
isc_mempool_create(mgr->mctx, buffersize, &mgr->bpool);
result = isc_mempool_create(mgr->mctx, buffersize, &mgr->bpool);
if (result != ISC_R_SUCCESS) {
UNLOCK(&mgr->buffer_lock);
return (result);
}
isc_mempool_setname(mgr->bpool, "dispmgr_bpool");
isc_mempool_setmaxalloc(mgr->bpool, maxbuffers);
isc_mempool_setfreemax(mgr->bpool, maxbuffers);
@@ -1993,8 +2009,10 @@ dns_dispatchmgr_setudp(dns_dispatchmgr_t *mgr,
UNLOCK(&mgr->buffer_lock);
return (ISC_R_SUCCESS);
}
isc_mempool_create(mgr->mctx, sizeof(dispsocket_t),
result = isc_mempool_create(mgr->mctx, sizeof(dispsocket_t),
&mgr->spool);
if (result != ISC_R_SUCCESS)
goto cleanup;
isc_mempool_setname(mgr->spool, "dispmgr_spool");
isc_mempool_setmaxalloc(mgr->spool, maxrequests);
@@ -2839,8 +2857,11 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
ISC_LIST_INIT(disp->port_table[i]);
}
isc_mempool_create(mgr->mctx, sizeof(dispportentry_t),
result = isc_mempool_create(mgr->mctx, sizeof(dispportentry_t),
&disp->portpool);
if (result != ISC_R_SUCCESS) {
goto deallocate_dispatch;
}
isc_mempool_setname(disp->portpool, "disp_portpool");
isc_mempool_setfreemax(disp->portpool, 128);
}
@@ -2871,8 +2892,12 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
sizeof(isc_event_t));
disp->sepool = NULL;
isc_mempool_create(mgr->mctx, sizeof(isc_socketevent_t),
&disp->sepool);
if (isc_mempool_create(mgr->mctx, sizeof(isc_socketevent_t),
&disp->sepool) != ISC_R_SUCCESS)
{
result = ISC_R_NOMEMORY;
goto kill_ctlevent;
}
isc_mutex_init(&disp->sepool_lock);
@@ -2904,6 +2929,11 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
/*
* Error returns.
*/
kill_ctlevent:
isc_event_free(&disp->ctlevent);
for (i = 0; i < disp->ntasks; i++) {
isc_task_detach(&disp->task[i]);
}
kill_socket:
if (disp->socket != NULL) {
isc_socket_detach(&disp->socket);
+6 -3
View File
@@ -257,7 +257,9 @@ dns_dnssec_sign(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
*/
sig.signature = isc_mem_get(mctx, sig.siglen);
isc_buffer_allocate(mctx, &databuf, sigsize + 256 + 18);
ret = isc_buffer_allocate(mctx, &databuf, sigsize + 256 + 18);
if (ret != ISC_R_SUCCESS)
goto cleanup_signature;
dns_rdata_init(&tmpsigrdata);
ret = dns_rdata_fromstruct(&tmpsigrdata, sig.common.rdclass,
@@ -353,6 +355,7 @@ cleanup_context:
dst_context_destroy(&ctx);
cleanup_databuf:
isc_buffer_free(&databuf);
cleanup_signature:
isc_mem_put(mctx, sig.signature, sig.siglen);
return (ret);
@@ -994,7 +997,7 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
rdata = NULL;
RETERR(dns_message_gettemprdata(msg, &rdata));
isc_buffer_allocate(msg->mctx, &dynbuf, 1024);
RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 1024));
RETERR(dns_rdata_fromstruct(rdata, dns_rdataclass_any,
dns_rdatatype_sig /* SIG(0) */,
&sig, dynbuf));
@@ -1978,7 +1981,7 @@ dns_dnssec_syncupdate(dns_dnsseckeylist_t *keys, dns_dnsseckeylist_t *rmkeys,
}
/*
* Unconditionally remove CDS/DNSKEY records for removed keys.
* Unconditionaly remove CDS/DNSKEY records for removed keys.
*/
for (key = ISC_LIST_HEAD(*rmkeys);
key != NULL;
+12 -24
View File
@@ -865,8 +865,8 @@ dst_key_fromgssapi(const dns_name_t *name, gss_ctx_id_t gssctx,
* Keep the token for use by external ssu rules. They may need
* to examine the PAC in the kerberos ticket.
*/
isc_buffer_allocate(key->mctx, &key->key_tkeytoken,
intoken->length);
RETERR(isc_buffer_allocate(key->mctx, &key->key_tkeytoken,
intoken->length));
RETERR(isc_buffer_copyregion(key->key_tkeytoken, intoken));
}
@@ -2336,7 +2336,7 @@ dst_key_is_unused(dst_key_t* key)
* This key is used.
*/
if (!state_type_set) {
return (false);
return false;
}
/*
* If the state is not HIDDEN, the key is in use.
@@ -2346,11 +2346,11 @@ dst_key_is_unused(dst_key_t* key)
st = DST_KEY_STATE_NA;
}
if (st != DST_KEY_STATE_HIDDEN) {
return (false);
return false;
}
}
/* This key is unused. */
return (true);
return true;
}
@@ -2405,7 +2405,7 @@ dst_key_is_published(dst_key_t *key, isc_stdtime_t now,
time_ok = true;
}
return (state_ok && time_ok);
return state_ok && time_ok;
}
bool
@@ -2465,9 +2465,10 @@ dst_key_is_active(dst_key_t *key, isc_stdtime_t now)
inactive = false;
}
}
return (ds_ok && zrrsig_ok && time_ok && !inactive);
return ds_ok && zrrsig_ok && time_ok && !inactive;
}
bool
dst_key_is_signing(dst_key_t *key, int role, isc_stdtime_t now, isc_stdtime_t *active)
{
@@ -2521,7 +2522,7 @@ dst_key_is_signing(dst_key_t *key, int role, isc_stdtime_t now, isc_stdtime_t *a
inactive = false;
}
}
return (krrsig_ok && zrrsig_ok && time_ok && !inactive);
return krrsig_ok && zrrsig_ok && time_ok && !inactive;
}
bool
@@ -2539,7 +2540,7 @@ dst_key_is_revoked(dst_key_t *key, isc_stdtime_t now, isc_stdtime_t *revoke)
time_ok = (when <= now);
}
return (time_ok);
return time_ok;
}
bool
@@ -2554,7 +2555,7 @@ dst_key_is_removed(dst_key_t *key, isc_stdtime_t now, isc_stdtime_t *remove)
if (dst_key_is_unused(key)) {
/* This key was never used. */
return (false);
return false;
}
result = dst_key_gettime(key, DST_TIME_DELETE, &when);
@@ -2578,20 +2579,7 @@ dst_key_is_removed(dst_key_t *key, isc_stdtime_t now, isc_stdtime_t *remove)
time_ok = true;
}
return (state_ok && time_ok);
}
dst_key_state_t
dst_key_goal(dst_key_t *key)
{
dst_key_state_t state;
isc_result_t result;
result = dst_key_getstate(key, DST_KEY_GOAL, &state);
if (result == ISC_R_SUCCESS) {
return (state);
}
return (DST_KEY_STATE_HIDDEN);
return state_ok && time_ok;
}
void
+13 -3
View File
@@ -54,12 +54,18 @@ struct dst_gssapi_signverifyctx {
static isc_result_t
gssapi_create_signverify_ctx(dst_key_t *key, dst_context_t *dctx) {
dst_gssapi_signverifyctx_t *ctx;
isc_result_t result;
UNUSED(key);
ctx = isc_mem_get(dctx->mctx, sizeof(dst_gssapi_signverifyctx_t));
ctx->buffer = NULL;
isc_buffer_allocate(dctx->mctx, &ctx->buffer, INITIAL_BUFFER_SIZE);
result = isc_buffer_allocate(dctx->mctx, &ctx->buffer,
INITIAL_BUFFER_SIZE);
if (result != ISC_R_SUCCESS) {
isc_mem_put(dctx->mctx, ctx, sizeof(dst_gssapi_signverifyctx_t));
return (result);
}
dctx->ctxdata.gssctx = ctx;
@@ -101,7 +107,9 @@ gssapi_adddata(dst_context_t *dctx, const isc_region_t *data) {
length = isc_buffer_length(ctx->buffer) + data->length + BUFFER_EXTRA;
isc_buffer_allocate(dctx->mctx, &newbuffer, length);
result = isc_buffer_allocate(dctx->mctx, &newbuffer, length);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_usedregion(ctx->buffer, &r);
(void)isc_buffer_copyregion(newbuffer, &r);
@@ -268,7 +276,9 @@ gssapi_restore(dst_key_t *key, const char *keystr) {
len = (len / 4) * 3;
isc_buffer_allocate(key->mctx, &b, len);
result = isc_buffer_allocate(key->mctx, &b, len);
if (result != ISC_R_SUCCESS)
return (result);
result = isc_base64_decodestring(keystr, b);
if (result != ISC_R_SUCCESS) {
+2 -2
View File
@@ -752,8 +752,8 @@ dst_gssapi_acceptctx(gss_cred_id_t cred,
}
if (gouttoken.length > 0U) {
isc_buffer_allocate(mctx, outtoken,
(unsigned int)gouttoken.length);
RETERR(isc_buffer_allocate(mctx, outtoken,
(unsigned int)gouttoken.length));
GBUFFER_TO_REGION(gouttoken, r);
RETERR(isc_buffer_copyregion(*outtoken, &r));
(void)gss_release_buffer(&minor, &gouttoken);
+3 -5
View File
@@ -323,15 +323,13 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
/* Methods provided by named to dynamically modify the member zones */
/* xxxwpk TODO config! */
typedef isc_result_t (*dns_catz_zoneop_fn_t)(dns_catz_entry_t *entry,
dns_catz_zone_t *origin,
dns_view_t *view,
isc_taskmgr_t *taskmgr,
void *udata);
dns_catz_zone_t *origin, dns_view_t *view,
isc_taskmgr_t *taskmgr, void *udata);
struct dns_catz_zonemodmethods {
dns_catz_zoneop_fn_t addzone;
dns_catz_zoneop_fn_t modzone;
dns_catz_zoneop_fn_t delzone;
void *udata;
void * udata;
};
-12
View File
@@ -1166,18 +1166,6 @@ dst_key_is_removed(dst_key_t *key, isc_stdtime_t now, isc_stdtime_t *remove);
* 'key' to be valid.
*/
dst_key_state_t
dst_key_goal(dst_key_t *key);
/*%<
* Get the key goal. Should be OMNIPRESENT or HIDDEN.
* This can be used to determine if the key is being introduced or
* is on its way out.
*
* Requires:
* 'key' to be valid.
*/
void
dst_key_copy_metadata(dst_key_t *to, dst_key_t *from);
/*%<
+20
View File
@@ -126,6 +126,26 @@ dns_ipkeylist_copy(isc_mem_t *mctx, const dns_ipkeylist_t *src,
}
dst->count = src->count;
return (ISC_R_SUCCESS);
do {
if (dst->labels[i] != NULL) {
if (dns_name_dynamic(dst->labels[i]))
dns_name_free(dst->labels[i], mctx);
isc_mem_put(mctx, dst->labels[i], sizeof(dns_name_t));
dst->labels[i] = NULL;
}
} while (i-- > 0);
do {
if (dst->keys[i] != NULL) {
if (dns_name_dynamic(dst->keys[i]))
dns_name_free(dst->keys[i], mctx);
isc_mem_put(mctx, dst->keys[i], sizeof(dns_name_t));
dst->keys[i] = NULL;
}
} while (i-- > 0);
return (result);
}
isc_result_t
+2 -2
View File
@@ -89,7 +89,7 @@ keymgr_keyrole(dst_key_t* key)
return ("CSK");
} else if (ksk) {
return ("KSK");
} else if (zsk) {
} else {
return ("ZSK");
}
return ("NOSIGN");
@@ -1358,7 +1358,7 @@ dns_keymgr_run(const dns_name_t *origin, dns_rdataclass_t rdclass,
lifetime);
}
if (dst_key_goal(dkey->key) == OMNIPRESENT) {
if (dst_key_is_active(dkey->key, now)) {
if (active_key != NULL) {
/*
* Multiple signing keys match
+3 -1
View File
@@ -592,7 +592,9 @@ dns_keytable_dump(dns_keytable_t *keytable, FILE *fp) {
REQUIRE(VALID_KEYTABLE(keytable));
REQUIRE(fp != NULL);
isc_buffer_allocate(keytable->mctx, &text, 4096);
result = isc_buffer_allocate(keytable->mctx, &text, 4096);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_keytable_totext(keytable, &text);
+5 -6
View File
@@ -400,7 +400,7 @@ totext_ctx_init(const dns_master_style_t *style, const dns_indent_t *indentctx,
ctx->current_ttl = 0;
ctx->current_ttl_valid = false;
ctx->serve_stale_ttl = 0;
ctx->indent = *indentctx;
ctx->indent = indentctx ? *indentctx : default_indent;
return (ISC_R_SUCCESS);
}
@@ -1547,13 +1547,12 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
return (ISC_R_SUCCESS);
cleanup:
if (dctx->dbiter != NULL) {
if (dctx->dbiter != NULL)
dns_dbiterator_destroy(&dctx->dbiter);
}
if (dctx->db != NULL) {
if (dctx->db != NULL)
dns_db_detach(&dctx->db);
}
isc_mem_put(mctx, dctx, sizeof(*dctx));
if (dctx != NULL)
isc_mem_put(mctx, dctx, sizeof(*dctx));
return (result);
}
+44 -8
View File
@@ -243,10 +243,13 @@ msgblock_free(isc_mem_t *mctx, dns_msgblock_t *block, unsigned int sizeof_type)
*/
static inline isc_result_t
newbuffer(dns_message_t *msg, unsigned int size) {
isc_result_t result;
isc_buffer_t *dynbuf;
dynbuf = NULL;
isc_buffer_allocate(msg->mctx, &dynbuf, size);
result = isc_buffer_allocate(msg->mctx, &dynbuf, size);
if (result != ISC_R_SUCCESS)
return (ISC_R_NOMEMORY);
ISC_LIST_APPEND(msg->scratchpad, dynbuf, link);
return (ISC_R_SUCCESS);
@@ -699,6 +702,7 @@ isc_result_t
dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp)
{
dns_message_t *m;
isc_result_t result;
isc_buffer_t *dynbuf;
unsigned int i;
@@ -739,25 +743,49 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp)
* Ok, it is safe to allocate (and then "goto cleanup" if failure)
*/
isc_mempool_create(m->mctx, sizeof(dns_name_t), &m->namepool);
result = isc_mempool_create(m->mctx, sizeof(dns_name_t), &m->namepool);
if (result != ISC_R_SUCCESS)
goto cleanup;
isc_mempool_setfillcount(m->namepool, NAME_COUNT);
isc_mempool_setfreemax(m->namepool, NAME_COUNT);
isc_mempool_setname(m->namepool, "msg:names");
isc_mempool_create(m->mctx, sizeof(dns_rdataset_t),
result = isc_mempool_create(m->mctx, sizeof(dns_rdataset_t),
&m->rdspool);
if (result != ISC_R_SUCCESS)
goto cleanup;
isc_mempool_setfillcount(m->rdspool, RDATASET_COUNT);
isc_mempool_setfreemax(m->rdspool, RDATASET_COUNT);
isc_mempool_setname(m->rdspool, "msg:rdataset");
dynbuf = NULL;
isc_buffer_allocate(mctx, &dynbuf, SCRATCHPAD_SIZE);
result = isc_buffer_allocate(mctx, &dynbuf, SCRATCHPAD_SIZE);
if (result != ISC_R_SUCCESS)
goto cleanup;
ISC_LIST_APPEND(m->scratchpad, dynbuf, link);
m->cctx = NULL;
*msgp = m;
return (ISC_R_SUCCESS);
/*
* Cleanup for error returns.
*/
cleanup:
dynbuf = ISC_LIST_HEAD(m->scratchpad);
if (dynbuf != NULL) {
ISC_LIST_UNLINK(m->scratchpad, dynbuf, link);
isc_buffer_free(&dynbuf);
}
if (m->namepool != NULL)
isc_mempool_destroy(&m->namepool);
if (m->rdspool != NULL)
isc_mempool_destroy(&m->rdspool);
m->magic = 0;
isc_mem_putanddetach(&mctx, m, sizeof(dns_message_t));
return (ISC_R_NOMEMORY);
}
void
@@ -2837,7 +2865,9 @@ dns_message_setquerytsig(dns_message_t *msg, isc_buffer_t *querytsig) {
goto cleanup;
isc_buffer_usedregion(querytsig, &r);
isc_buffer_allocate(msg->mctx, &buf, r.length);
result = isc_buffer_allocate(msg->mctx, &buf, r.length);
if (result != ISC_R_SUCCESS)
goto cleanup;
isc_buffer_putmem(buf, r.base, r.length);
isc_buffer_usedregion(buf, &r);
dns_rdata_init(rdata);
@@ -2882,7 +2912,9 @@ dns_message_getquerytsig(dns_message_t *msg, isc_mem_t *mctx,
dns_rdataset_current(msg->tsig, &rdata);
dns_rdata_toregion(&rdata, &r);
isc_buffer_allocate(mctx, querytsig, r.length);
result = isc_buffer_allocate(mctx, querytsig, r.length);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_putmem(*querytsig, r.base, r.length);
return (ISC_R_SUCCESS);
}
@@ -3001,7 +3033,9 @@ dns_message_signer(dns_message_t *msg, dns_name_t *signer) {
if (!dns_name_hasbuffer(signer)) {
isc_buffer_t *dynbuf = NULL;
isc_buffer_allocate(msg->mctx, &dynbuf, 512);
result = isc_buffer_allocate(msg->mctx, &dynbuf, 512);
if (result != ISC_R_SUCCESS)
return (result);
dns_name_setbuffer(signer, dynbuf);
dns_message_takebuffer(msg, &dynbuf);
}
@@ -4445,7 +4479,9 @@ dns_message_buildopt(dns_message_t *message, dns_rdataset_t **rdatasetp,
goto cleanup;
}
isc_buffer_allocate(message->mctx, &buf, len);
result = isc_buffer_allocate(message->mctx, &buf, len);
if (result != ISC_R_SUCCESS)
goto cleanup;
for (i = 0; i < count; i++) {
if (ednsopts[i].code == DNS_OPT_PAD &&
+3 -1
View File
@@ -568,7 +568,9 @@ dns_ntatable_dump(dns_ntatable_t *ntatable, FILE *fp) {
isc_buffer_t *text = NULL;
int len = 4096;
isc_buffer_allocate(ntatable->view->mctx, &text, len);
result = isc_buffer_allocate(ntatable->view->mctx, &text, len);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_ntatable_totext(ntatable, NULL, &text);
+6 -3
View File
@@ -273,15 +273,16 @@ static isc_result_t openssleddsa_todns(const dst_key_t *key,
static isc_result_t
openssleddsa_createctx(dst_key_t *key, dst_context_t *dctx) {
isc_buffer_t *buf = NULL;
isc_result_t result;
UNUSED(key);
REQUIRE(dctx->key->key_alg == DST_ALG_ED25519 ||
dctx->key->key_alg == DST_ALG_ED448);
isc_buffer_allocate(dctx->mctx, &buf, 64);
result = isc_buffer_allocate(dctx->mctx, &buf, 64);
dctx->ctxdata.generic = buf;
return (ISC_R_SUCCESS);
return (result);
}
static void
@@ -311,7 +312,9 @@ openssleddsa_adddata(dst_context_t *dctx, const isc_region_t *data) {
return (ISC_R_SUCCESS);
length = isc_buffer_length(buf) + data->length + 64;
isc_buffer_allocate(dctx->mctx, &nbuf, length);
result = isc_buffer_allocate(dctx->mctx, &nbuf, length);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_usedregion(buf, &r);
(void) isc_buffer_copyregion(nbuf, &r);
(void) isc_buffer_copyregion(nbuf, data);
+3 -1
View File
@@ -108,7 +108,9 @@ pkcs11eddsa_adddata(dst_context_t *dctx, const isc_region_t *data) {
return (ISC_R_SUCCESS);
length = isc_buffer_length(buf) + data->length + 64;
isc_buffer_allocate(dctx->mctx, &nbuf, length);
result = isc_buffer_allocate(dctx->mctx, &nbuf, length);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_usedregion(buf, &r);
(void) isc_buffer_copyregion(nbuf, &r);
(void) isc_buffer_copyregion(nbuf, data);
+14 -13
View File
@@ -172,12 +172,9 @@ typedef isc_rwlock_t nodelock_t;
* to be 0 by default either with or without threads.
*/
#ifndef DNS_RBTDB_LIMITLRUUPDATE
#define DNS_RBTDB_LIMITLRUUPDATE 1
#define DNS_RBTDB_LIMITLRUUPDATE 0
#endif
#define DNS_RBTDB_LRUUPDATE_GLUE 300
#define DNS_RBTDB_LRUUPDATE_REGULAR 600
/*
* Allow clients with a virtual time of up to 5 minutes in the past to see
* records that would have otherwise have expired.
@@ -312,7 +309,7 @@ typedef ISC_LIST(dns_rbtnode_t) rbtnodelist_t;
(((header)->rdh_ttl > (now)) || \
((header)->rdh_ttl == (now) && ZEROTTL(header)))
#define DEFAULT_NODE_LOCK_COUNT 53 /*%< Should be prime. */
#define DEFAULT_NODE_LOCK_COUNT 7 /*%< Should be prime. */
#define RBTDB_GLUE_TABLE_INIT_SIZE 2U
/*%
@@ -332,7 +329,7 @@ typedef ISC_LIST(dns_rbtnode_t) rbtnodelist_t;
#define DEFAULT_CACHE_NODE_LOCK_COUNT DNS_RBTDB_CACHE_NODE_LOCK_COUNT
#endif
#else
#define DEFAULT_CACHE_NODE_LOCK_COUNT 97
#define DEFAULT_CACHE_NODE_LOCK_COUNT 16
#endif /* DNS_RBTDB_CACHE_NODE_LOCK_COUNT */
typedef struct {
@@ -1588,8 +1585,7 @@ clean_cache_node(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node) {
top_next = current->next;
clean_stale_headers(rbtdb, mctx, current);
/*
* If current is nonexistent, ancient, or stale and
* we are not keeping stale, we can clean it up.
* If current is nonexistent or stale, we can clean it up.
*/
if (NONEXISTENT(current) || ANCIENT(current) ||
(STALE(current) && ! KEEPSTALE(rbtdb))) {
@@ -6371,7 +6367,8 @@ addnoqname(dns_rbtdb_t *rbtdb, rdatasetheader_t *newheader,
cleanup:
dns_rdataset_disassociate(&neg);
dns_rdataset_disassociate(&negsig);
free_noqname(mctx, &noqname);
if (noqname != NULL)
free_noqname(mctx, &noqname);
return(result);
}
@@ -6415,7 +6412,8 @@ addclosest(dns_rbtdb_t *rbtdb, rdatasetheader_t *newheader,
cleanup:
dns_rdataset_disassociate(&neg);
dns_rdataset_disassociate(&negsig);
free_noqname(mctx, &closest);
if (closest != NULL)
free_noqname(mctx, &closest);
return(result);
}
@@ -9886,7 +9884,10 @@ restart:
dns_rdataset_t *sigrdataset_aaaa = NULL;
dns_name_t *gluename = dns_fixedname_name(&ge->fixedname);
isc_buffer_allocate(msg->mctx, &buffer, 512);
result = isc_buffer_allocate(msg->mctx, &buffer, 512);
if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
goto no_glue;
}
result = dns_message_gettempname(msg, &name);
if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
@@ -10091,11 +10092,11 @@ need_headerupdate(rdatasetheader_t *header, isc_stdtime_t now) {
* Glue records are updated if at least 60 seconds have passed
* since the previous update time.
*/
return (header->last_used + DNS_RBTDB_LRUUPDATE_GLUE <= now);
return (header->last_used + 60 <= now);
}
/* Other records are updated if 5 minutes have passed. */
return (header->last_used + DNS_RBTDB_LRUUPDATE_REGULAR <= now);
return (header->last_used + 300 <= now);
#else
UNUSED(now);
+3 -1
View File
@@ -857,7 +857,9 @@ unknown_fromtext(dns_rdataclass_t rdclass, dns_rdatatype_t type,
false));
if (token.value.as_ulong > 65535U)
return (ISC_R_RANGE);
isc_buffer_allocate(mctx, &buf, token.value.as_ulong);
result = isc_buffer_allocate(mctx, &buf, token.value.as_ulong);
if (result != ISC_R_SUCCESS)
return (result);
if (token.value.as_ulong != 0U) {
result = isc_hex_tobuffer(lexer, buf,
+14 -4
View File
@@ -780,7 +780,10 @@ dns_request_createraw(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
sock = req_getsocket(request);
INSIST(sock != NULL);
isc_buffer_allocate(mctx, &request->query, r.length + (tcp ? 2 : 0));
result = isc_buffer_allocate(mctx, &request->query,
r.length + (tcp ? 2 : 0));
if (result != ISC_R_SUCCESS)
goto cleanup;
if (tcp)
isc_buffer_putuint16(request->query, (uint16_t)r.length);
result = isc_buffer_copyregion(request->query, &r);
@@ -1037,7 +1040,9 @@ req_render(dns_message_t *message, isc_buffer_t **bufferp,
/*
* Create buffer able to hold largest possible message.
*/
isc_buffer_allocate(mctx, &buf1, 65535);
result = isc_buffer_allocate(mctx, &buf1, 65535);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_compress_init(&cctx, -1, mctx);
if (result != ISC_R_SUCCESS)
@@ -1082,7 +1087,9 @@ req_render(dns_message_t *message, isc_buffer_t **bufferp,
result = DNS_R_USETCP;
goto cleanup;
}
isc_buffer_allocate(mctx, &buf2, r.length + (tcp ? 2 : 0));
result = isc_buffer_allocate(mctx, &buf2, r.length + (tcp ? 2 : 0));
if (result != ISC_R_SUCCESS)
goto cleanup;
if (tcp)
isc_buffer_putuint16(buf2, (uint16_t)r.length);
result = isc_buffer_copyregion(buf2, &r);
@@ -1341,7 +1348,10 @@ req_response(isc_task_t *task, isc_event_t *event) {
* Copy buffer to request.
*/
isc_buffer_usedregion(&devent->buffer, &r);
isc_buffer_allocate(request->mctx, &request->answer, r.length);
result = isc_buffer_allocate(request->mctx, &request->answer,
r.length);
if (result != ISC_R_SUCCESS)
goto done;
result = isc_buffer_copyregion(request->answer, &r);
if (result != ISC_R_SUCCESS)
isc_buffer_free(&request->answer);
+12 -9
View File
@@ -7220,21 +7220,19 @@ log_nsid(isc_buffer_t *opt, size_t nsid_len, resquery_t *query,
{
static const char hex[17] = "0123456789abcdef";
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
size_t buflen;
uint16_t buflen, i;
unsigned char *p, *nsid;
unsigned char *buf = NULL, *pbuf = NULL;
REQUIRE(nsid_len <= UINT16_MAX);
/* Allocate buffer for storing hex version of the NSID */
buflen = nsid_len * 2 + 1;
buflen = (uint16_t)nsid_len * 2 + 1;
buf = isc_mem_get(mctx, buflen);
pbuf = isc_mem_get(mctx, nsid_len + 1);
/* Convert to hex */
p = buf;
nsid = isc_buffer_current(opt);
for (size_t i = 0; i < nsid_len; i++) {
for (i = 0; i < nsid_len; i++) {
*p++ = hex[(nsid[i] >> 4) & 0xf];
*p++ = hex[nsid[i] & 0xf];
}
@@ -7242,8 +7240,11 @@ log_nsid(isc_buffer_t *opt, size_t nsid_len, resquery_t *query,
/* Make printable version */
p = pbuf;
for (size_t i = 0; i < nsid_len; i++) {
*p++ = isprint(nsid[i]) ? nsid[i] : '.';
for (i = 0; i < nsid_len; i++) {
if (isprint(nsid[i]))
*p++ = nsid[i];
else
*p++ = '.';
}
*p = '\0';
@@ -7253,8 +7254,10 @@ log_nsid(isc_buffer_t *opt, size_t nsid_len, resquery_t *query,
DNS_LOGMODULE_RESOLVER, level,
"received NSID %s (\"%s\") from %s", buf, pbuf, addrbuf);
isc_mem_put(mctx, pbuf, nsid_len + 1);
isc_mem_put(mctx, buf, buflen);
if (pbuf != NULL)
isc_mem_put(mctx, pbuf, nsid_len + 1);
if (buf != NULL)
isc_mem_put(mctx, buf, buflen);
}
static bool
+9 -2
View File
@@ -273,6 +273,7 @@ dns_sdb_putrdata(dns_sdblookup_t *lookup, dns_rdatatype_t typeval,
dns_rdatalist_t *rdatalist;
dns_rdata_t *rdata;
isc_buffer_t *rdatabuf = NULL;
isc_result_t result;
isc_mem_t *mctx;
isc_region_t region;
@@ -298,7 +299,9 @@ dns_sdb_putrdata(dns_sdblookup_t *lookup, dns_rdatatype_t typeval,
rdata = isc_mem_get(mctx, sizeof(dns_rdata_t));
isc_buffer_allocate(mctx, &rdatabuf, rdlen);
result = isc_buffer_allocate(mctx, &rdatabuf, rdlen);
if (result != ISC_R_SUCCESS)
goto failure;
DE_CONST(rdatap, region.base);
region.length = rdlen;
isc_buffer_copyregion(rdatabuf, &region);
@@ -308,8 +311,12 @@ dns_sdb_putrdata(dns_sdblookup_t *lookup, dns_rdatatype_t typeval,
&region);
ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
ISC_LIST_APPEND(lookup->buffers, rdatabuf, link);
rdata = NULL;
return (ISC_R_SUCCESS);
failure:
if (rdata != NULL)
isc_mem_put(mctx, rdata, sizeof(dns_rdata_t));
return (result);
}
isc_result_t
+6 -2
View File
@@ -1076,7 +1076,9 @@ modrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
mctx = sdlz->common.mctx;
isc_buffer_allocate(mctx, &buffer, 1024);
result = isc_buffer_allocate(mctx, &buffer, 1024);
if (result != ISC_R_SUCCESS)
return (result);
result = dns_master_stylecreate(&style, 0, 0, 0, 0, 0, 0, 1,
0xffffffff, mctx);
@@ -1867,7 +1869,9 @@ dns_sdlz_putrr(dns_sdlzlookup_t *lookup, const char *type, dns_ttl_t ttl,
goto failure;
rdatabuf = NULL;
isc_buffer_allocate(mctx, &rdatabuf, size);
result = isc_buffer_allocate(mctx, &rdatabuf, size);
if (result != ISC_R_SUCCESS)
goto failure;
result = dns_rdata_fromtext(rdata, rdatalist->rdclass,
rdatalist->type, lex,
+103 -124
View File
@@ -42,57 +42,38 @@ typedef enum {
/*%
* It doesn't make sense to have 2^16 counters for all possible types since
* most of them won't be used. We have counters for the first 256 types.
*
* A rdtypecounter is now 8 bits for RRtypes and 3 bits for flags:
*
* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | | | | | | S |NX| RRType |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
*
* If the 8 bits for RRtype are all zero, this is an Other RRtype.
* most of them won't be used. We have counters for the first 256 types and
* those explicitly supported in the rdata implementation.
* XXXJT: this introduces tight coupling with the rdata implementation.
* Ideally, we should have rdata handle this type of details.
*/
#define RDTYPECOUNTER_MAXTYPE 0x00ff
/*
*
* Bit 7 is the NXRRSET (NX) flag and indicates whether this is a
* positive (0) or a negative (1) RRset.
* types, !types, nxdomain, stale types, stale !types, stale nxdomain,
* ancient types, ancient !types, ancient nxdomain
*/
#define RDTYPECOUNTER_NXRRSET 0x0100
/*
* Then bit 5 and 6 mostly tell you if this counter is for an active,
* stale, or ancient RRtype:
*
* S = 0 (0b00) means Active
* S = 1 (0b01) means Stale
* S = 2 (0b10) means Ancient
*
* Since a counter cannot be stale and ancient at the same time, we
* treat S = 0x11 as a special case to deal with NXDOMAIN counters.
*/
#define RDTYPECOUNTER_STALE (1 << 9)
#define RDTYPECOUNTER_ANCIENT (1 << 10)
#define RDTYPECOUNTER_NXDOMAIN ((1 << 9) | (1 << 10))
/*
* S = 0x11 indicates an NXDOMAIN counter and in this case the RRtype
* field signals the expiry of this cached item:
*
* RRType = 0 (0b00) means Active
* RRType = 1 (0b01) means Stale
* RRType = 2 (0b02) means Ancient
*
*/
#define RDTYPECOUNTER_NXDOMAIN_STALE 1
#define RDTYPECOUNTER_NXDOMAIN_ANCIENT 2
/*
* The maximum value for rdtypecounter is for an ancient NXDOMAIN.
*/
#define RDTYPECOUNTER_MAXVAL 0x0602
enum {
/* For 0-255, we use the rdtype value as counter indices */
rdtypecounter_dlv = 256, /* for dns_rdatatype_dlv */
rdtypecounter_others = 257, /* anything else */
rdtypecounter_max = 258,
/* The following are used for nxrrset rdataset */
rdtypenxcounter_max = rdtypecounter_max * 2,
/* nxdomain counter */
rdtypecounter_nxdomain = rdtypenxcounter_max,
/* stale counters offset */
rdtypecounter_stale = rdtypecounter_nxdomain + 1,
rdtypecounter_stale_max = rdtypecounter_stale + rdtypecounter_max,
rdtypenxcounter_stale_max = rdtypecounter_stale_max + rdtypecounter_max,
rdtypecounter_stale_nxdomain = rdtypenxcounter_stale_max,
/* ancient counters offset */
rdtypecounter_ancient = rdtypecounter_stale_nxdomain + 1,
rdtypecounter_ancient_max = rdtypecounter_ancient + rdtypecounter_max,
rdtypenxcounter_ancient_max = rdtypecounter_ancient_max +
rdtypecounter_max,
rdtypecounter_ancient_nxdomain = rdtypenxcounter_ancient_max,
/* limit of number counter types */
rdatasettypecounter_max = rdtypecounter_ancient_nxdomain + 1,
};
/* dnssec maximum key id */
static int dnssec_keyid_max = 65535;
@@ -194,12 +175,8 @@ isc_result_t
dns_rdatatypestats_create(isc_mem_t *mctx, dns_stats_t **statsp) {
REQUIRE(statsp != NULL && *statsp == NULL);
/*
* Create rdtype statistics for the first 255 RRtypes,
* plus one additional for other RRtypes.
*/
return (create_stats(mctx, dns_statstype_rdtype,
(RDTYPECOUNTER_MAXTYPE+1), statsp));
return (create_stats(mctx, dns_statstype_rdtype, rdtypecounter_max,
statsp));
}
isc_result_t
@@ -207,7 +184,7 @@ dns_rdatasetstats_create(isc_mem_t *mctx, dns_stats_t **statsp) {
REQUIRE(statsp != NULL && *statsp == NULL);
return (create_stats(mctx, dns_statstype_rdataset,
(RDTYPECOUNTER_MAXVAL+1), statsp));
rdatasettypecounter_max, statsp));
}
isc_result_t
@@ -243,62 +220,52 @@ dns_generalstats_increment(dns_stats_t *stats, isc_statscounter_t counter) {
isc_stats_increment(stats->counters, counter);
}
inline static
isc_statscounter_t rdatatype2counter(dns_rdatatype_t type) {
if (type > (dns_rdatatype_t)RDTYPECOUNTER_MAXTYPE) {
return 0;
}
return (isc_statscounter_t)type;
}
void
dns_rdatatypestats_increment(dns_stats_t *stats, dns_rdatatype_t type) {
isc_statscounter_t counter;
int counter;
REQUIRE(DNS_STATS_VALID(stats) && stats->type == dns_statstype_rdtype);
counter = rdatatype2counter(type);
isc_stats_increment(stats->counters, counter);
if (type == dns_rdatatype_dlv)
counter = rdtypecounter_dlv;
else if (type > dns_rdatatype_any)
counter = rdtypecounter_others;
else
counter = (int)type;
isc_stats_increment(stats->counters, (isc_statscounter_t)counter);
}
static inline void
update_rdatasetstats(dns_stats_t *stats, dns_rdatastatstype_t rrsettype,
bool increment)
{
isc_statscounter_t counter;
int counter;
dns_rdatatype_t rdtype;
if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) &
DNS_RDATASTATSTYPE_ATTR_NXDOMAIN) != 0) {
counter = RDTYPECOUNTER_NXDOMAIN;
/*
* This is an NXDOMAIN counter, save the expiry value
* (active, stale, or ancient) value in the RRtype part.
*/
if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) &
DNS_RDATASTATSTYPE_ATTR_ANCIENT) != 0) {
counter |= RDTYPECOUNTER_NXDOMAIN_ANCIENT;
}
else if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) &
DNS_RDATASTATSTYPE_ATTR_STALE) != 0) {
counter += RDTYPECOUNTER_NXDOMAIN_STALE;
}
counter = rdtypecounter_nxdomain;
} else {
counter = rdatatype2counter(DNS_RDATASTATSTYPE_BASE(rrsettype));
rdtype = DNS_RDATASTATSTYPE_BASE(rrsettype);
if (rdtype == dns_rdatatype_dlv)
counter = (int)rdtypecounter_dlv;
else if (rdtype > dns_rdatatype_any)
counter = (int)rdtypecounter_others;
else
counter = (int)rdtype;
if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) &
DNS_RDATASTATSTYPE_ATTR_NXRRSET) != 0) {
counter |= RDTYPECOUNTER_NXRRSET;
}
DNS_RDATASTATSTYPE_ATTR_NXRRSET) != 0)
counter += rdtypecounter_max;
}
if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) &
DNS_RDATASTATSTYPE_ATTR_ANCIENT) != 0) {
counter |= RDTYPECOUNTER_ANCIENT;
}
else if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) &
DNS_RDATASTATSTYPE_ATTR_STALE) != 0) {
counter |= RDTYPECOUNTER_STALE;
}
if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) &
DNS_RDATASTATSTYPE_ATTR_ANCIENT) != 0) {
counter += rdtypecounter_ancient;
} else if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) &
DNS_RDATASTATSTYPE_ATTR_STALE) != 0) {
counter += rdtypecounter_stale;
}
if (increment) {
@@ -368,10 +335,13 @@ dump_rdentry(int rdcounter, uint64_t value, dns_rdatastatstype_t attributes,
dns_rdatatype_t rdtype = dns_rdatatype_none; /* sentinel */
dns_rdatastatstype_t type;
if ((rdcounter & RDTYPECOUNTER_MAXTYPE) == 0) {
if (rdcounter == rdtypecounter_others)
attributes |= DNS_RDATASTATSTYPE_ATTR_OTHERTYPE;
} else {
rdtype = (dns_rdatatype_t)(rdcounter & RDTYPECOUNTER_MAXTYPE);
else {
if (rdcounter == rdtypecounter_dlv)
rdtype = dns_rdatatype_dlv;
else
rdtype = (dns_rdatatype_t)rdcounter;
}
type = DNS_RDATASTATSTYPE_VALUE((dns_rdatastatstype_t)rdtype,
attributes);
@@ -400,39 +370,48 @@ dns_rdatatypestats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn,
static void
rdataset_dumpcb(isc_statscounter_t counter, uint64_t value, void *arg) {
rdatadumparg_t *rdatadumparg = arg;
unsigned int attributes = 0;
unsigned int attributes;
bool dump = true;
if ((counter & RDTYPECOUNTER_NXDOMAIN) == RDTYPECOUNTER_NXDOMAIN) {
attributes |= DNS_RDATASTATSTYPE_ATTR_NXDOMAIN;
/*
* This is an NXDOMAIN counter, check the RRtype part for the
* expiry value (active, stale, or ancient).
*/
if ((counter & RDTYPECOUNTER_MAXTYPE) ==
RDTYPECOUNTER_NXDOMAIN_STALE) {
attributes |= DNS_RDATASTATSTYPE_ATTR_STALE;
} else if ((counter & RDTYPECOUNTER_MAXTYPE) ==
RDTYPECOUNTER_NXDOMAIN_ANCIENT) {
attributes |= DNS_RDATASTATSTYPE_ATTR_ANCIENT;
}
if (counter < rdtypecounter_max) {
attributes = 0;
} else if (counter < rdtypenxcounter_max) {
counter -= rdtypecounter_max;
attributes = DNS_RDATASTATSTYPE_ATTR_NXRRSET;
} else if (counter == rdtypecounter_nxdomain) {
counter = 0;
attributes = DNS_RDATASTATSTYPE_ATTR_NXDOMAIN;
} else if (counter < rdtypecounter_stale_max) {
counter -= rdtypecounter_stale;
attributes = DNS_RDATASTATSTYPE_ATTR_STALE;
} else if (counter < rdtypenxcounter_stale_max) {
counter -= rdtypecounter_stale_max;
attributes = DNS_RDATASTATSTYPE_ATTR_NXRRSET |
DNS_RDATASTATSTYPE_ATTR_STALE;
} else if (counter == rdtypecounter_stale_nxdomain) {
counter = 0;
attributes = DNS_RDATASTATSTYPE_ATTR_NXDOMAIN |
DNS_RDATASTATSTYPE_ATTR_STALE;
} else if (counter < rdtypecounter_ancient_max) {
counter -= rdtypecounter_ancient;
attributes = DNS_RDATASTATSTYPE_ATTR_ANCIENT;
} else if (counter < rdtypenxcounter_ancient_max) {
counter -= rdtypecounter_ancient_max;
attributes = DNS_RDATASTATSTYPE_ATTR_NXRRSET |
DNS_RDATASTATSTYPE_ATTR_ANCIENT;
} else if (counter == rdtypecounter_ancient_nxdomain) {
counter = 0;
attributes = DNS_RDATASTATSTYPE_ATTR_NXDOMAIN |
DNS_RDATASTATSTYPE_ATTR_ANCIENT;
} else {
if ((counter & RDTYPECOUNTER_MAXTYPE) == 0) {
attributes |= DNS_RDATASTATSTYPE_ATTR_OTHERTYPE;
}
if ((counter & RDTYPECOUNTER_NXRRSET) != 0) {
attributes |= DNS_RDATASTATSTYPE_ATTR_NXRRSET;
}
if ((counter & RDTYPECOUNTER_STALE) != 0) {
attributes |= DNS_RDATASTATSTYPE_ATTR_STALE;
} else if ((counter & RDTYPECOUNTER_ANCIENT) != 0) {
attributes |= DNS_RDATASTATSTYPE_ATTR_ANCIENT;
}
/* Out of bounds, do not dump entry. */
dump = false;
}
dump_rdentry(counter, value, attributes, rdatadumparg->fn,
if (dump) {
dump_rdentry(counter, value, attributes, rdatadumparg->fn,
rdatadumparg->arg);
}
}
void
+2 -1
View File
@@ -571,7 +571,8 @@ dns_test_namefromstring(const char *namestr, dns_fixedname_t *fname) {
name = dns_fixedname_initname(fname);
isc_buffer_allocate(dt_mctx, &b, length);
result = isc_buffer_allocate(dt_mctx, &b, length);
assert_int_equal(result, ISC_R_SUCCESS);
isc_buffer_putmem(b, (const unsigned char *) namestr, length);
result = dns_name_fromtext(name, b, dns_rootname, 0, NULL);
-2
View File
@@ -403,9 +403,7 @@ deserialize_corrupt_test(void **state) {
close(fd);
/* Randomly fuzz a portion of the memory */
/* cppcheck-suppress nullPointerArithmeticRedundantCheck */
p = base + (isc_random_uniform(filesize));
/* cppcheck-suppress nullPointerArithmeticRedundantCheck */
q = base + filesize;
q -= (isc_random_uniform(q - p));
while (p++ < q) {
+9 -4
View File
@@ -223,11 +223,12 @@ rdatasetstats(void **state, bool servestale) {
result = dns_rdatasetstats_create(dt_mctx, &stats);
assert_int_equal(result, ISC_R_SUCCESS);
/* First 255 types. */
for (i = 1; i <= 255; i++) {
/* First 256 types. */
for (i = 0; i <= 255; i++) {
set_typestats(stats, (dns_rdatatype_t)i);
}
/* Specials */
set_typestats(stats, dns_rdatatype_dlv);
set_typestats(stats, (dns_rdatatype_t)1000);
set_nxdomainstats(stats);
@@ -236,10 +237,12 @@ rdatasetstats(void **state, bool servestale) {
if (servestale) {
/* Mark stale */
for (i = 1; i <= 255; i++) {
for (i = 0; i <= 255; i++) {
mark_stale(stats, (dns_rdatatype_t)i, 0,
DNS_RDATASTATSTYPE_ATTR_STALE);
}
mark_stale(stats, dns_rdatatype_dlv, 0,
DNS_RDATASTATSTYPE_ATTR_STALE);
mark_stale(stats, (dns_rdatatype_t)1000, 0,
DNS_RDATASTATSTYPE_ATTR_STALE);
mark_nxdomain_stale(stats, 0, DNS_RDATASTATSTYPE_ATTR_STALE);
@@ -252,10 +255,12 @@ rdatasetstats(void **state, bool servestale) {
}
/* Mark ancient */
for (i = 1; i <= 255; i++) {
for (i = 0; i <= 255; i++) {
mark_stale(stats, (dns_rdatatype_t)i, from,
DNS_RDATASTATSTYPE_ATTR_ANCIENT);
}
mark_stale(stats, dns_rdatatype_dlv, from,
DNS_RDATASTATSTYPE_ATTR_ANCIENT);
mark_stale(stats, (dns_rdatatype_t)1000, from,
DNS_RDATASTATSTYPE_ATTR_ANCIENT);
mark_nxdomain_stale(stats, from, DNS_RDATASTATSTYPE_ATTR_ANCIENT);
+9 -5
View File
@@ -141,7 +141,7 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target) {
tsig.siglen = isc_buffer_usedlength(&sigbuf);
assert_int_equal(sigsize, tsig.siglen);
isc_buffer_allocate(dt_mctx, &dynbuf, 512);
CHECK(isc_buffer_allocate(dt_mctx, &dynbuf, 512));
CHECK(dns_rdata_fromstruct(&rdata, dns_rdataclass_any,
dns_rdatatype_tsig, &tsig, dynbuf));
dns_rdatalist_init(&rdatalist);
@@ -312,14 +312,16 @@ tsig_tcp_test(void **state) {
/*
* Create request.
*/
isc_buffer_allocate(dt_mctx, &buf, 65535);
result = isc_buffer_allocate(dt_mctx, &buf, 65535);
assert_int_equal(result, ISC_R_SUCCESS);
render(buf, 0, key, &tsigout, &querytsig, NULL);
isc_buffer_free(&buf);
/*
* Create response message 1.
*/
isc_buffer_allocate(dt_mctx, &buf, 65535);
result = isc_buffer_allocate(dt_mctx, &buf, 65535);
assert_int_equal(result, ISC_R_SUCCESS);
render(buf, DNS_MESSAGEFLAG_QR, key, &querytsig, &tsigout, NULL);
/*
@@ -372,7 +374,8 @@ tsig_tcp_test(void **state) {
/*
* Create response message 2.
*/
isc_buffer_allocate(dt_mctx, &buf, 65535);
result = isc_buffer_allocate(dt_mctx, &buf, 65535);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(result, ISC_R_SUCCESS);
render(buf, DNS_MESSAGEFLAG_QR, key, &tsigout, &tsigout, outctx);
@@ -418,7 +421,8 @@ tsig_tcp_test(void **state) {
/*
* Create response message 3.
*/
isc_buffer_allocate(dt_mctx, &buf, 65535);
result = isc_buffer_allocate(dt_mctx, &buf, 65535);
assert_int_equal(result, ISC_R_SUCCESS);
render(buf, DNS_MESSAGEFLAG_QR, key, &tsigout, &tsigout, outctx);
result = add_tsig(outctx, key, buf);
+7 -7
View File
@@ -164,7 +164,7 @@ add_rdata_to_list(dns_message_t *msg, dns_name_t *name, dns_rdata_t *rdata,
RETERR(dns_message_gettemprdata(msg, &newrdata));
dns_rdata_toregion(rdata, &r);
isc_buffer_allocate(msg->mctx, &tmprdatabuf, r.length);
RETERR(isc_buffer_allocate(msg->mctx, &tmprdatabuf, r.length));
isc_buffer_availableregion(tmprdatabuf, &newr);
memmove(newr.base, r.base, r.length);
dns_rdata_fromregion(newrdata, rdata->rdclass, rdata->type, &newr);
@@ -438,7 +438,7 @@ process_dhtkey(dns_message_t *msg, dns_name_t *signer, dns_name_t *name,
RETERR(add_rdata_to_list(msg, &ourname, &ourkeyrdata, 0, namelist));
RETERR(dst_key_secretsize(tctx->dhkey, &sharedsize));
isc_buffer_allocate(msg->mctx, &shared, sharedsize);
RETERR(isc_buffer_allocate(msg->mctx, &shared, sharedsize));
result = dst_key_computesecret(pubkey, tctx->dhkey, shared);
if (result != ISC_R_SUCCESS) {
@@ -940,9 +940,9 @@ buildquery(dns_message_t *msg, const dns_name_t *name,
dns_rdatatype_tkey);
len = 16 + tkey->algorithm.length + tkey->keylen + tkey->otherlen;
isc_buffer_allocate(msg->mctx, &dynbuf, len);
isc_buffer_allocate(msg->mctx, &anamebuf, name->length);
isc_buffer_allocate(msg->mctx, &qnamebuf, name->length);
RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, len));
RETERR(isc_buffer_allocate(msg->mctx, &anamebuf, name->length));
RETERR(isc_buffer_allocate(msg->mctx, &qnamebuf, name->length));
RETERR(dns_message_gettemprdata(msg, &rdata));
RETERR(dns_rdata_fromstruct(rdata, dns_rdataclass_any,
@@ -1046,7 +1046,7 @@ dns_tkey_builddhquery(dns_message_t *msg, dst_key_t *key,
RETERR(buildquery(msg, name, &tkey, false));
RETERR(dns_message_gettemprdata(msg, &rdata));
isc_buffer_allocate(msg->mctx, &dynbuf, 1024);
RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 1024));
RETERR(dst_key_todns(key, dynbuf));
isc_buffer_usedregion(dynbuf, &r);
dns_rdata_fromregion(rdata, dns_rdataclass_any,
@@ -1265,7 +1265,7 @@ dns_tkey_processdhresponse(dns_message_t *qmsg, dns_message_t *rmsg,
rmsg->mctx, &theirkey));
RETERR(dst_key_secretsize(key, &sharedsize));
isc_buffer_allocate(rmsg->mctx, &shared, sharedsize);
RETERR(isc_buffer_allocate(rmsg->mctx, &shared, sharedsize));
RETERR(dst_key_computesecret(theirkey, key, shared));
+3 -1
View File
@@ -975,7 +975,9 @@ dns_tsig_sign(dns_message_t *msg) {
ret = dns_message_gettemprdata(msg, &rdata);
if (ret != ISC_R_SUCCESS)
goto cleanup_signature;
isc_buffer_allocate(msg->mctx, &dynbuf, 512);
ret = isc_buffer_allocate(msg->mctx, &dynbuf, 512);
if (ret != ISC_R_SUCCESS)
goto cleanup_rdata;
ret = dns_rdata_fromstruct(rdata, dns_rdataclass_any,
dns_rdatatype_tsig, &tsig, dynbuf);
if (ret != ISC_R_SUCCESS)
-1
View File
@@ -1432,7 +1432,6 @@ dst_key_getprivateformat
dst_key_getstate
dst_key_gettime
dst_key_getttl
dst_key_goal
dst_key_id
dst_key_is_active
dst_key_is_published
+44 -96
View File
@@ -13428,18 +13428,17 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) {
cleanup:
cancel_refresh(zone);
stub->magic = 0;
if (stub->version != NULL) {
dns_db_closeversion(stub->db, &stub->version,
false);
if (stub != NULL) {
stub->magic = 0;
if (stub->version != NULL)
dns_db_closeversion(stub->db, &stub->version,
false);
if (stub->db != NULL)
dns_db_detach(&stub->db);
if (stub->zone != NULL)
zone_idetach(&stub->zone);
isc_mem_put(stub->mctx, stub, sizeof(*stub));
}
if (stub->db != NULL) {
dns_db_detach(&stub->db);
}
if (stub->zone != NULL) {
zone_idetach(&stub->zone);
}
isc_mem_put(stub->mctx, stub, sizeof(*stub));
if (message != NULL)
dns_message_destroy(&message);
unlock:
@@ -13823,7 +13822,9 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags,
goto soa_cleanup;
dns_rdataset_current(&rdataset, &rdata);
dns_rdata_toregion(&rdata, &r);
isc_buffer_allocate(zone->mctx, &b, r.length);
result = isc_buffer_allocate(zone->mctx, &b, r.length);
if (result != ISC_R_SUCCESS)
goto soa_cleanup;
isc_buffer_putmem(b, r.base, r.length);
isc_buffer_usedregion(b, &r);
dns_rdata_init(temprdata);
@@ -16711,7 +16712,9 @@ dns_zone_forwardupdate(dns_zone_t *zone, dns_message_t *msg,
goto cleanup;
}
isc_buffer_allocate(zone->mctx, &forward->msgbuf, mr->length);
result = isc_buffer_allocate(zone->mctx, &forward->msgbuf, mr->length);
if (result != ISC_R_SUCCESS)
goto cleanup;
result = isc_buffer_copyregion(forward->msgbuf, mr);
if (result != ISC_R_SUCCESS)
goto cleanup;
@@ -19134,14 +19137,11 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) {
unsigned char algorithms[256];
unsigned int i;
enum { notexpected = 0, expected = 1, found = 2 };
REQUIRE(DNS_ZONE_VALID(zone));
result = dns_db_getoriginnode(db, &node);
if (result != ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
return (result);
}
dns_rdataset_init(&cds);
dns_rdataset_init(&dnskey);
@@ -19149,19 +19149,16 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) {
result = dns_db_findrdataset(db, node, version, dns_rdatatype_cds,
dns_rdatatype_none, 0, &cds, NULL);
if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND) {
if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND)
goto failure;
}
result = dns_db_findrdataset(db, node, version, dns_rdatatype_cdnskey,
dns_rdatatype_none, 0, &cdnskey, NULL);
if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND) {
if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND)
goto failure;
}
if (!dns_rdataset_isassociated(&cds) &&
!dns_rdataset_isassociated(&cdnskey))
{
!dns_rdataset_isassociated(&cdnskey)) {
result = ISC_R_SUCCESS;
goto failure;
}
@@ -19169,25 +19166,21 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) {
result = dns_db_findrdataset(db, node, version, dns_rdatatype_dnskey,
dns_rdatatype_none, 0, &dnskey, NULL);
if (result == ISC_R_NOTFOUND) {
if (dns_rdataset_isassociated(&cds)) {
if (dns_rdataset_isassociated(&cds))
result = DNS_R_BADCDS;
} else {
else
result = DNS_R_BADCDNSKEY;
}
goto failure;
}
if (result != ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
goto failure;
}
/*
* For each DNSSEC algorithm in the CDS RRset there must be
* a matching DNSKEY record with the exception of a CDS deletion
* record which must be by itself.
* a matching DNSKEY record.
*/
if (dns_rdataset_isassociated(&cds)) {
bool delete = false;
memset(algorithms, notexpected, sizeof(algorithms));
memset(algorithms, 0, sizeof(algorithms));
for (result = dns_rdataset_first(&cds);
result == ISC_R_SUCCESS;
result = dns_rdataset_next(&cds)) {
@@ -19195,21 +19188,9 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) {
dns_rdata_cds_t structcds;
dns_rdataset_current(&cds, &crdata);
/*
* CDS deletion record has this form "0 0 0 00" which
* is 5 zero octets.
*/
if (crdata.length == 5U &&
memcmp(crdata.data,
(unsigned char[5]){ 0, 0, 0, 0, 0 }, 5) == 0)
{
delete = true;
continue;
}
CHECK(dns_rdata_tostruct(&crdata, &structcds, NULL));
if (algorithms[structcds.algorithm] == 0) {
algorithms[structcds.algorithm] = expected;
}
if (algorithms[structcds.algorithm] == 0)
algorithms[structcds.algorithm] = 1;
for (result = dns_rdataset_first(&dnskey);
result == ISC_R_SUCCESS;
result = dns_rdataset_next(&dnskey)) {
@@ -19222,23 +19203,16 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) {
buffer, &dsrdata));
if (crdata.length == dsrdata.length &&
memcmp(crdata.data, dsrdata.data,
dsrdata.length) == 0)
{
algorithms[structcds.algorithm] = found;
dsrdata.length) == 0) {
algorithms[structcds.algorithm] = 2;
}
}
if (result != ISC_R_NOMORE) {
if (result != ISC_R_NOMORE)
goto failure;
}
}
for (i = 0; i < sizeof(algorithms); i++) {
if (delete) {
if (algorithms[i] != notexpected) {
result = DNS_R_BADCDS;
goto failure;
}
} else if (algorithms[i] == expected) {
result = DNS_R_BADCDS;
if (algorithms[i] == 1) {
result = DNS_R_BADCDNSKEY;
goto failure;
}
}
@@ -19246,12 +19220,10 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) {
/*
* For each DNSSEC algorithm in the CDNSKEY RRset there must be
* a matching DNSKEY record with the exception of a CDNSKEY deletion
* record which must be by itself.
* a matching DNSKEY record.
*/
if (dns_rdataset_isassociated(&cdnskey)) {
bool delete = false;
memset(algorithms, notexpected, sizeof(algorithms));
memset(algorithms, 0, sizeof(algorithms));
for (result = dns_rdataset_first(&cdnskey);
result == ISC_R_SUCCESS;
result = dns_rdataset_next(&cdnskey)) {
@@ -19259,23 +19231,10 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) {
dns_rdata_cdnskey_t structcdnskey;
dns_rdataset_current(&cdnskey, &crdata);
/*
* CDNSKEY deletion record has this form
* "0 3 0 AA==" which is 2 zero octets, a 3,
* and 2 zero octets.
*/
if (crdata.length == 5U &&
memcmp(crdata.data,
(unsigned char[5]){ 0, 0, 3, 0, 0 }, 5) == 0)
{
delete = true;
continue;
}
CHECK(dns_rdata_tostruct(&crdata, &structcdnskey,
NULL));
if (algorithms[structcdnskey.algorithm] == 0) {
algorithms[structcdnskey.algorithm] = expected;
}
if (algorithms[structcdnskey.algorithm] == 0)
algorithms[structcdnskey.algorithm] = 1;
for (result = dns_rdataset_first(&dnskey);
result == ISC_R_SUCCESS;
result = dns_rdataset_next(&dnskey)) {
@@ -19284,24 +19243,16 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) {
dns_rdataset_current(&dnskey, &rdata);
if (crdata.length == rdata.length &&
memcmp(crdata.data, rdata.data,
rdata.length) == 0)
{
algorithms[structcdnskey.algorithm] =
found;
rdata.length) == 0) {
algorithms[structcdnskey.algorithm] = 2;
}
}
if (result != ISC_R_NOMORE) {
if (result != ISC_R_NOMORE)
goto failure;
}
}
for (i = 0; i < sizeof(algorithms); i++) {
if (delete) {
if (algorithms[i] != notexpected) {
result = DNS_R_BADCDNSKEY;
goto failure;
}
} else if (algorithms[i] == expected) {
result = DNS_R_BADCDNSKEY;
if (algorithms[i] == 1) {
result = DNS_R_BADCDS;
goto failure;
}
}
@@ -19309,15 +19260,12 @@ dns_zone_cdscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version) {
result = ISC_R_SUCCESS;
failure:
if (dns_rdataset_isassociated(&cds)) {
if (dns_rdataset_isassociated(&cds))
dns_rdataset_disassociate(&cds);
}
if (dns_rdataset_isassociated(&dnskey)) {
if (dns_rdataset_isassociated(&dnskey))
dns_rdataset_disassociate(&dnskey);
}
if (dns_rdataset_isassociated(&cdnskey)) {
if (dns_rdataset_isassociated(&cdnskey))
dns_rdataset_disassociate(&cdnskey);
}
dns_db_detachnode(db, &node);
return (result);
}
+29 -48
View File
@@ -1122,7 +1122,7 @@ free_element_heap(void *element, void *uap) {
}
static bool
_checknext(const vctx_t *vctx, const struct nsec3_chain_fixed *first,
checknext(const vctx_t *vctx, const struct nsec3_chain_fixed *first,
const struct nsec3_chain_fixed *e)
{
char buf[512];
@@ -1162,37 +1162,6 @@ _checknext(const vctx_t *vctx, const struct nsec3_chain_fixed *first,
return (false);
}
static inline bool
checknext(isc_mem_t *mctx,
const vctx_t *vctx,
const struct nsec3_chain_fixed *first,
struct nsec3_chain_fixed *prev,
const struct nsec3_chain_fixed *cur)
{
bool result = _checknext(vctx, prev, cur);
if (prev != first) {
free_element(mctx, prev);
}
return (result);
}
static inline bool
checklast(isc_mem_t *mctx,
const vctx_t *vctx,
struct nsec3_chain_fixed *first,
struct nsec3_chain_fixed *prev)
{
bool result = _checknext(vctx, prev, first);
if (prev != first) {
free_element(mctx, prev);
}
free_element(mctx, first);
return (result);
}
static isc_result_t
verify_nsec3_chains(const vctx_t *vctx, isc_mem_t *mctx) {
isc_result_t result = ISC_R_SUCCESS;
@@ -1245,27 +1214,39 @@ verify_nsec3_chains(const vctx_t *vctx, isc_mem_t *mctx) {
"not equal");
result = ISC_R_FAILURE;
}
if (first == NULL) {
prev = first = e;
} else if (newchain(first, e)) {
if (!checklast(mctx, vctx, first, prev)) {
result = ISC_R_FAILURE;
if (first == NULL || newchain(first, e)) {
if (first != NULL) {
if (prev != NULL) {
if (!checknext(vctx, prev, first)) {
result = ISC_R_FAILURE;
}
if (prev != first) {
free_element(mctx, prev);
}
}
free_element(mctx, first);
}
prev = first = e;
} else {
if (!checknext(mctx, vctx, first, prev, e)) {
result = ISC_R_FAILURE;
}
prev = e;
continue;
}
}
if (prev != NULL) {
if (!checklast(mctx, vctx, first, prev)) {
if (!checknext(vctx, prev, e)) {
result = ISC_R_FAILURE;
}
if (prev != first) {
free_element(mctx, prev);
}
prev = e;
}
if (prev != NULL) {
if (!checknext(vctx, prev, first)) {
result = ISC_R_FAILURE;
}
if (prev != first) {
free_element(mctx, prev);
}
}
if (first != NULL) {
free_element(mctx, first);
}
do {
if (f != NULL) {
+5 -1
View File
@@ -109,7 +109,11 @@ configure_key(isc_mem_t *mctx, const cfg_obj_t *key, irs_dnsconf_t *conf,
return (result);
}
isc_buffer_usedregion(&rrdatabuf, &r);
isc_buffer_allocate(mctx, &keydatabuf, r.length);
result = isc_buffer_allocate(mctx, &keydatabuf,
r.length);
if (result != ISC_R_SUCCESS) {
return (result);
}
result = isc_buffer_copyregion(keydatabuf, &r);
if (result != ISC_R_SUCCESS) {
goto cleanup;
+13 -5
View File
@@ -500,7 +500,9 @@ isc_buffer_dup(isc_mem_t *mctx, isc_buffer_t **dstp, const isc_buffer_t *src) {
isc_buffer_usedregion(src, &region);
isc_buffer_allocate(mctx, &dst, region.length);
result = isc_buffer_allocate(mctx, &dst, region.length);
if (result != ISC_R_SUCCESS)
return (result);
result = isc_buffer_copyregion(dst, &region);
RUNTIME_CHECK(result == ISC_R_SUCCESS); /* NOSPACE is impossible */
@@ -534,14 +536,18 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r) {
return (ISC_R_SUCCESS);
}
void
isc_result_t
isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
unsigned int length)
{
REQUIRE(dynbuffer != NULL && *dynbuffer == NULL);
isc_buffer_t *dbuf;
unsigned char * bdata;
REQUIRE(dynbuffer != NULL);
REQUIRE(*dynbuffer == NULL);
isc_buffer_t *dbuf = isc_mem_get(mctx, sizeof(isc_buffer_t));
unsigned char *bdata = isc_mem_get(mctx, length);
dbuf = isc_mem_get(mctx, sizeof(isc_buffer_t));
bdata = isc_mem_get(mctx, length);
isc_buffer_init(dbuf, bdata, length);
@@ -550,6 +556,8 @@ isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
dbuf->mctx = mctx;
*dynbuffer = dbuf;
return (ISC_R_SUCCESS);
}
isc_result_t
+5 -1
View File
@@ -192,7 +192,7 @@ struct isc_buffer {
*** Functions
***/
void
isc_result_t
isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
unsigned int length);
/*!<
@@ -204,6 +204,10 @@ isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
*
*\li "dynbuffer" is non-NULL, and "*dynbuffer" is NULL.
*
* Returns:
*\li ISC_R_SUCCESS - success
*\li ISC_R_NOMEMORY - no memory available
*
* Note:
*\li Changing the buffer's length field is not permitted.
*/
+1 -1
View File
@@ -451,7 +451,7 @@ isc_mem_renderjson(void *memobj0);
* Memory pools
*/
void
isc_result_t
isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp);
/*%<
* Create a memory pool.
+11 -3
View File
@@ -181,6 +181,7 @@ new_source(isc_lex_t *lex, bool is_file, bool need_close,
void *input, const char *name)
{
inputsource *source;
isc_result_t result;
source = isc_mem_get(lex->mctx, sizeof(*source));
source->result = ISC_R_SUCCESS;
@@ -191,8 +192,13 @@ new_source(isc_lex_t *lex, bool is_file, bool need_close,
source->input = input;
source->name = isc_mem_strdup(lex->mctx, name);
source->pushback = NULL;
isc_buffer_allocate(lex->mctx, &source->pushback,
(unsigned int)lex->max_token);
result = isc_buffer_allocate(lex->mctx, &source->pushback,
(unsigned int)lex->max_token);
if (result != ISC_R_SUCCESS) {
isc_mem_free(lex->mctx, source->name);
isc_mem_put(lex->mctx, source, sizeof(*source));
return (result);
}
source->ignored = 0;
source->line = 1;
ISC_LIST_INITANDPREPEND(lex->sources, source, link);
@@ -314,7 +320,9 @@ pushandgrow(isc_lex_t *lex, inputsource *source, int c) {
isc_result_t result;
oldlen = isc_buffer_length(source->pushback);
isc_buffer_allocate(lex->mctx, &tbuf, oldlen * 2);
result = isc_buffer_allocate(lex->mctx, &tbuf, oldlen * 2);
if (result != ISC_R_SUCCESS)
return (result);
isc_buffer_usedregion(source->pushback, &used);
result = isc_buffer_copyregion(tbuf, &used);
INSIST(result == ISC_R_SUCCESS);
+17 -15
View File
@@ -321,15 +321,17 @@ isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp) {
lcfg = isc_mem_get(lctx->mctx, sizeof(*lcfg));
lcfg->lctx = lctx;
lcfg->channellists = NULL;
lcfg->channellist_count = 0;
lcfg->duplicate_interval = 0;
lcfg->highest_level = level;
lcfg->tag = NULL;
lcfg->dynamic = false;
ISC_LIST_INIT(lcfg->channels);
lcfg->magic = LCFG_MAGIC;
{
lcfg->lctx = lctx;
lcfg->channellists = NULL;
lcfg->channellist_count = 0;
lcfg->duplicate_interval = 0;
lcfg->highest_level = level;
lcfg->tag = NULL;
lcfg->dynamic = false;
ISC_LIST_INIT(lcfg->channels);
lcfg->magic = LCFG_MAGIC;
}
/*
* Create the default channels:
@@ -375,18 +377,18 @@ isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp) {
ISC_LOG_PRINTTIME);
}
if (result == ISC_R_SUCCESS) {
if (result == ISC_R_SUCCESS)
result = isc_log_createchannel(lcfg, "null",
ISC_LOG_TONULL,
ISC_LOG_DYNAMIC,
NULL, 0);
}
if (result == ISC_R_SUCCESS) {
if (result == ISC_R_SUCCESS)
*lcfgp = lcfg;
} else {
isc_logconfig_destroy(&lcfg);
}
else
if (lcfg != NULL)
isc_logconfig_destroy(&lcfg);
return (result);
}
+98 -98
View File
@@ -126,11 +126,6 @@ static isc_mutex_t contextslock;
*/
static uint64_t totallost;
/*%
* Memory allocation and free function definitions.
* isc__memalloc_t must deal with memory allocation failure
* and must never return NULL.
*/
typedef void * (*isc__memalloc_t)(size_t);
typedef void (*isc__memfree_t)(void *);
@@ -368,6 +363,7 @@ more_basic_blocks(isc__mem_t *ctx) {
if (ctx->basic_table_count == ctx->basic_table_size) {
table_size = ctx->basic_table_size + TABLE_INCREMENT;
table = (ctx->memalloc)(table_size * sizeof(unsigned char *));
RUNTIME_CHECK(table != NULL);
ctx->malloced += table_size * sizeof(unsigned char *);
if (ctx->malloced > ctx->maxmalloced)
ctx->maxmalloced = ctx->malloced;
@@ -384,6 +380,7 @@ more_basic_blocks(isc__mem_t *ctx) {
}
tmp = (ctx->memalloc)(NUM_BASIC_BLOCKS * ctx->mem_target);
RUNTIME_CHECK(tmp != NULL);
ctx->total += NUM_BASIC_BLOCKS * ctx->mem_target;;
ctx->basic_table[ctx->basic_table_count] = tmp;
ctx->basic_table_count++;
@@ -476,6 +473,7 @@ mem_getunlocked(isc__mem_t *ctx, size_t size) {
* memget() was called on something beyond our upper limit.
*/
ret = (ctx->memalloc)(size);
RUNTIME_CHECK(ret != NULL);
ctx->total += size;
ctx->inuse += size;
ctx->stats[ctx->max_size].gets++;
@@ -598,6 +596,7 @@ mem_get(isc__mem_t *ctx, size_t size) {
size += 1;
#endif
ret = (ctx->memalloc)(size);
RUNTIME_CHECK(ret != NULL);
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) {
if (ISC_LIKELY(ret != NULL))
@@ -724,10 +723,10 @@ initialize_action(void) {
static void
mem_create(isc_mem_t **ctxp, unsigned int flags)
{
REQUIRE(ctxp != NULL && *ctxp == NULL);
isc__mem_t *ctx;
REQUIRE(ctxp != NULL && *ctxp == NULL);
STATIC_ASSERT((ALIGNMENT_SIZE & (ALIGNMENT_SIZE - 1)) == 0,
"wrong alignment size");
@@ -775,6 +774,7 @@ mem_create(isc_mem_t **ctxp, unsigned int flags)
ctx->highest = NULL;
ctx->stats = (ctx->memalloc)((ctx->max_size+1) * sizeof(struct stats));
RUNTIME_CHECK(ctx->stats != NULL);
memset(ctx->stats, 0, (ctx->max_size + 1) * sizeof(struct stats));
ctx->malloced += (ctx->max_size+1) * sizeof(struct stats);
@@ -784,6 +784,7 @@ mem_create(isc_mem_t **ctxp, unsigned int flags)
ctx->mem_target = DEF_MEM_TARGET;
ctx->freelists = (ctx->memalloc)(ctx->max_size *
sizeof(element *));
RUNTIME_CHECK(ctx->freelists != NULL);
memset(ctx->freelists, 0,
ctx->max_size * sizeof(element *));
ctx->malloced += ctx->max_size * sizeof(element *);
@@ -796,6 +797,7 @@ mem_create(isc_mem_t **ctxp, unsigned int flags)
ctx->debuglist = (ctx->memalloc)((DEBUG_TABLE_COUNT *
sizeof(debuglist_t)));
RUNTIME_CHECK(ctx->debuglist != NULL);
for (i = 0; i < DEBUG_TABLE_COUNT; i++)
ISC_LIST_INIT(ctx->debuglist[i]);
ctx->malloced += DEBUG_TABLE_COUNT * sizeof(debuglist_t);
@@ -893,11 +895,11 @@ destroy(isc__mem_t *ctx) {
void
isc_mem_attach(isc_mem_t *source0, isc_mem_t **targetp) {
REQUIRE(VALID_CONTEXT(source0));
REQUIRE(targetp != NULL && *targetp == NULL);
isc__mem_t *source = (isc__mem_t *)source0;
REQUIRE(VALID_CONTEXT(source));
REQUIRE(targetp != NULL && *targetp == NULL);
isc_refcount_increment(&source->references);
*targetp = (isc_mem_t *)source;
@@ -906,7 +908,6 @@ isc_mem_attach(isc_mem_t *source0, isc_mem_t **targetp) {
void
isc_mem_detach(isc_mem_t **ctxp) {
REQUIRE(ctxp != NULL && VALID_CONTEXT(*ctxp));
isc__mem_t *ctx = (isc__mem_t *)*ctxp;
*ctxp = NULL;
@@ -930,7 +931,6 @@ void
isc___mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size FLARG) {
REQUIRE(ctxp != NULL && VALID_CONTEXT(*ctxp));
REQUIRE(ptr != NULL);
isc__mem_t *ctx = (isc__mem_t *)*ctxp;
*ctxp = NULL;
@@ -970,14 +970,16 @@ destroy:
void
isc_mem_destroy(isc_mem_t **ctxp) {
isc__mem_t *ctx;
/*
* This routine provides legacy support for callers who use mctxs
* without attaching/detaching.
*/
REQUIRE(ctxp != NULL && VALID_CONTEXT(*ctxp));
isc__mem_t *ctx = (isc__mem_t *)*ctxp;
REQUIRE(ctxp != NULL);
ctx = (isc__mem_t *)*ctxp;
REQUIRE(VALID_CONTEXT(ctx));
#if ISC_MEM_TRACKLINES
if (isc_refcount_decrement(&ctx->references) > 1) {
@@ -994,12 +996,12 @@ isc_mem_destroy(isc_mem_t **ctxp) {
void *
isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
void *ptr;
bool call_water = false;
REQUIRE(VALID_CONTEXT(ctx));
if (ISC_UNLIKELY((isc_mem_debugging &
(ISC_MEM_DEBUGSIZE|ISC_MEM_DEBUGCTX)) != 0))
return (isc__mem_allocate(ctx0, size FLARG_PASS));
@@ -1038,14 +1040,14 @@ isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) {
void
isc___mem_put(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
REQUIRE(VALID_CONTEXT(ctx0));
REQUIRE(ptr != NULL);
isc__mem_t *ctx = (isc__mem_t *)ctx0;
bool call_water = false;
size_info *si;
size_t oldsize;
REQUIRE(VALID_CONTEXT(ctx));
REQUIRE(ptr != NULL);
if (ISC_UNLIKELY((isc_mem_debugging &
(ISC_MEM_DEBUGSIZE|ISC_MEM_DEBUGCTX)) != 0))
{
@@ -1090,10 +1092,10 @@ isc___mem_put(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
void
isc_mem_waterack(isc_mem_t *ctx0, int flag) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
REQUIRE(VALID_CONTEXT(ctx));
MCTXLOCK(ctx);
if (flag == ISC_MEM_LOWATER)
ctx->hi_called = false;
@@ -1142,13 +1144,12 @@ print_active(isc__mem_t *mctx, FILE *out) {
*/
void
isc_mem_stats(isc_mem_t *ctx0, FILE *out) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_t i;
const struct stats *s;
const isc__mempool_t *pool;
REQUIRE(VALID_CONTEXT(ctx));
MCTXLOCK(ctx);
for (i = 0; i <= ctx->max_size; i++) {
@@ -1231,12 +1232,12 @@ mem_allocateunlocked(isc_mem_t *ctx0, size_t size) {
void *
isc___mem_allocate(isc_mem_t *ctx0, size_t size FLARG) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_info *si;
bool call_water = false;
REQUIRE(VALID_CONTEXT(ctx));
MCTXLOCK(ctx);
si = mem_allocateunlocked((isc_mem_t *)ctx, size);
if (((ctx->flags & ISC_MEMFLAG_INTERNAL) == 0)) {
@@ -1273,11 +1274,12 @@ isc___mem_allocate(isc_mem_t *ctx0, size_t size FLARG) {
void *
isc___mem_reallocate(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
void *new_ptr = NULL;
size_t oldsize, copysize;
REQUIRE(VALID_CONTEXT(ctx));
/*
* This function emulates the realloc(3) standard library function:
* - if size > 0, allocate new memory; and if ptr is non NULL, copy
@@ -1313,14 +1315,14 @@ isc___mem_reallocate(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
void
isc___mem_free(isc_mem_t *ctx0, void *ptr FLARG) {
REQUIRE(VALID_CONTEXT(ctx0));
REQUIRE(ptr != NULL);
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_info *si;
size_t size;
bool call_water= false;
REQUIRE(VALID_CONTEXT(ctx));
REQUIRE(ptr != NULL);
if (ISC_UNLIKELY((isc_mem_debugging & ISC_MEM_DEBUGCTX) != 0)) {
si = &(((size_info *)ptr)[-2]);
REQUIRE(si->u.ctx == ctx);
@@ -1371,13 +1373,13 @@ isc___mem_free(isc_mem_t *ctx0, void *ptr FLARG) {
char *
isc___mem_strdup(isc_mem_t *mctx0, const char *s FLARG) {
REQUIRE(VALID_CONTEXT(mctx0));
REQUIRE(s != NULL);
isc__mem_t *mctx = (isc__mem_t *)mctx0;
size_t len;
char *ns;
REQUIRE(VALID_CONTEXT(mctx));
REQUIRE(s != NULL);
len = strlen(s) + 1;
ns = isc__mem_allocate((isc_mem_t *)mctx, len FLARG_PASS);
@@ -1390,10 +1392,9 @@ isc___mem_strdup(isc_mem_t *mctx0, const char *s FLARG) {
void
isc_mem_setdestroycheck(isc_mem_t *ctx0, bool flag) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
REQUIRE(VALID_CONTEXT(ctx));
MCTXLOCK(ctx);
ctx->checkfree = flag;
@@ -1403,11 +1404,10 @@ isc_mem_setdestroycheck(isc_mem_t *ctx0, bool flag) {
size_t
isc_mem_inuse(isc_mem_t *ctx0) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_t inuse;
REQUIRE(VALID_CONTEXT(ctx));
MCTXLOCK(ctx);
inuse = ctx->inuse;
@@ -1419,11 +1419,10 @@ isc_mem_inuse(isc_mem_t *ctx0) {
size_t
isc_mem_maxinuse(isc_mem_t *ctx0) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_t maxinuse;
REQUIRE(VALID_CONTEXT(ctx));
MCTXLOCK(ctx);
maxinuse = ctx->maxinuse;
@@ -1435,11 +1434,10 @@ isc_mem_maxinuse(isc_mem_t *ctx0) {
size_t
isc_mem_total(isc_mem_t *ctx0) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_t total;
REQUIRE(VALID_CONTEXT(ctx));
MCTXLOCK(ctx);
total = ctx->total;
@@ -1453,14 +1451,14 @@ void
isc_mem_setwater(isc_mem_t *ctx0, isc_mem_water_t water, void *water_arg,
size_t hiwater, size_t lowater)
{
REQUIRE(VALID_CONTEXT(ctx0));
REQUIRE(hiwater >= lowater);
isc__mem_t *ctx = (isc__mem_t *)ctx0;
bool callwater = false;
isc_mem_water_t oldwater;
void *oldwater_arg;
REQUIRE(VALID_CONTEXT(ctx));
REQUIRE(hiwater >= lowater);
MCTXLOCK(ctx);
oldwater = ctx->water;
oldwater_arg = ctx->water_arg;
@@ -1488,10 +1486,10 @@ isc_mem_setwater(isc_mem_t *ctx0, isc_mem_water_t water, void *water_arg,
bool
isc_mem_isovermem(isc_mem_t *ctx0) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
REQUIRE(VALID_CONTEXT(ctx));
/*
* We don't bother to lock the context because 100% accuracy isn't
* necessary (and even if we locked the context the returned value
@@ -1502,10 +1500,10 @@ isc_mem_isovermem(isc_mem_t *ctx0) {
void
isc_mem_setname(isc_mem_t *ctx0, const char *name, void *tag) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
REQUIRE(VALID_CONTEXT(ctx));
LOCK(&ctx->lock);
strlcpy(ctx->name, name, sizeof(ctx->name));
ctx->tag = tag;
@@ -1514,10 +1512,10 @@ isc_mem_setname(isc_mem_t *ctx0, const char *name, void *tag) {
const char *
isc_mem_getname(isc_mem_t *ctx0) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
REQUIRE(VALID_CONTEXT(ctx));
if (ctx->name[0] == 0)
return ("");
@@ -1526,10 +1524,10 @@ isc_mem_getname(isc_mem_t *ctx0) {
void *
isc_mem_gettag(isc_mem_t *ctx0) {
REQUIRE(VALID_CONTEXT(ctx0));
isc__mem_t *ctx = (isc__mem_t *)ctx0;
REQUIRE(VALID_CONTEXT(ctx));
return (ctx->tag);
}
@@ -1537,20 +1535,21 @@ isc_mem_gettag(isc_mem_t *ctx0) {
* Memory pool stuff
*/
void
isc_result_t
isc_mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
REQUIRE(VALID_CONTEXT(mctx0));
REQUIRE(size > 0U);
REQUIRE(mpctxp != NULL && *mpctxp == NULL);
isc__mem_t *mctx = (isc__mem_t *)mctx0;
isc__mempool_t *mpctx;
REQUIRE(VALID_CONTEXT(mctx));
REQUIRE(size > 0U);
REQUIRE(mpctxp != NULL && *mpctxp == NULL);
/*
* Allocate space for this pool, initialize values, and if all works
* well, attach to the memory context.
*/
mpctx = isc_mem_get((isc_mem_t *)mctx, sizeof(isc__mempool_t));
RUNTIME_CHECK(mpctx != NULL);
mpctx->common.impmagic = MEMPOOL_MAGIC;
mpctx->common.magic = ISCAPI_MPOOL_MAGIC;
@@ -1580,15 +1579,17 @@ isc_mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
ISC_LIST_INITANDAPPEND(mctx->pools, mpctx, link);
mctx->poolcnt++;
MCTXUNLOCK(mctx);
return (ISC_R_SUCCESS);
}
void
isc_mempool_setname(isc_mempool_t *mpctx0, const char *name) {
REQUIRE(VALID_MEMPOOL(mpctx0));
REQUIRE(name != NULL);
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
REQUIRE(name != NULL);
REQUIRE(VALID_MEMPOOL(mpctx));
#if ISC_MEMPOOL_NAMES
if (mpctx->lock != NULL)
LOCK(mpctx->lock);
@@ -1605,15 +1606,14 @@ isc_mempool_setname(isc_mempool_t *mpctx0, const char *name) {
void
isc_mempool_destroy(isc_mempool_t **mpctxp) {
REQUIRE(mpctxp != NULL);
REQUIRE(VALID_MEMPOOL(*mpctxp));
isc__mempool_t *mpctx;
isc__mem_t *mctx;
isc_mutex_t *lock;
element *item;
REQUIRE(mpctxp != NULL);
mpctx = (isc__mempool_t *)*mpctxp;
REQUIRE(VALID_MEMPOOL(mpctx));
#if ISC_MEMPOOL_NAMES
if (mpctx->allocated > 0)
UNEXPECTED_ERROR(__FILE__, __LINE__,
@@ -1670,25 +1670,24 @@ isc_mempool_destroy(isc_mempool_t **mpctxp) {
void
isc_mempool_associatelock(isc_mempool_t *mpctx0, isc_mutex_t *lock) {
REQUIRE(VALID_MEMPOOL(mpctx0));
REQUIRE(lock != NULL);
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
REQUIRE(VALID_MEMPOOL(mpctx));
REQUIRE(mpctx->lock == NULL);
REQUIRE(lock != NULL);
mpctx->lock = lock;
}
void *
isc__mempool_get(isc_mempool_t *mpctx0 FLARG) {
REQUIRE(VALID_MEMPOOL(mpctx0));
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
element *item;
isc__mem_t *mctx;
unsigned int i;
REQUIRE(VALID_MEMPOOL(mpctx));
mctx = mpctx->mctx;
if (mpctx->lock != NULL)
@@ -1758,12 +1757,14 @@ isc__mempool_get(isc_mempool_t *mpctx0 FLARG) {
/* coverity[+free : arg-1] */
void
isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
REQUIRE(VALID_MEMPOOL(mpctx0));
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
isc__mem_t *mctx;
element *item;
REQUIRE(VALID_MEMPOOL(mpctx));
REQUIRE(mem != NULL);
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
isc__mem_t *mctx = mpctx->mctx;
element *item;
mctx = mpctx->mctx;
if (mpctx->lock != NULL)
LOCK(mpctx->lock);
@@ -1814,10 +1815,10 @@ isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
void
isc_mempool_setfreemax(isc_mempool_t *mpctx0, unsigned int limit) {
REQUIRE(VALID_MEMPOOL(mpctx0));
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
REQUIRE(VALID_MEMPOOL(mpctx));
if (mpctx->lock != NULL)
LOCK(mpctx->lock);
@@ -1829,11 +1830,11 @@ isc_mempool_setfreemax(isc_mempool_t *mpctx0, unsigned int limit) {
unsigned int
isc_mempool_getfreemax(isc_mempool_t *mpctx0) {
REQUIRE(VALID_MEMPOOL(mpctx0));
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
unsigned int freemax;
REQUIRE(VALID_MEMPOOL(mpctx));
if (mpctx->lock != NULL)
LOCK(mpctx->lock);
@@ -1847,11 +1848,10 @@ isc_mempool_getfreemax(isc_mempool_t *mpctx0) {
unsigned int
isc_mempool_getfreecount(isc_mempool_t *mpctx0) {
REQUIRE(VALID_MEMPOOL(mpctx0));
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
unsigned int freecount;
REQUIRE(VALID_MEMPOOL(mpctx));
if (mpctx->lock != NULL)
LOCK(mpctx->lock);
@@ -1866,10 +1866,11 @@ isc_mempool_getfreecount(isc_mempool_t *mpctx0) {
void
isc_mempool_setmaxalloc(isc_mempool_t *mpctx0, unsigned int limit) {
REQUIRE(VALID_MEMPOOL(mpctx0));
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
REQUIRE(limit > 0);
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
REQUIRE(VALID_MEMPOOL(mpctx));
if (mpctx->lock != NULL)
LOCK(mpctx->lock);
@@ -1882,11 +1883,11 @@ isc_mempool_setmaxalloc(isc_mempool_t *mpctx0, unsigned int limit) {
unsigned int
isc_mempool_getmaxalloc(isc_mempool_t *mpctx0) {
REQUIRE(VALID_MEMPOOL(mpctx0));
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
unsigned int maxalloc;
REQUIRE(VALID_MEMPOOL(mpctx));
if (mpctx->lock != NULL)
LOCK(mpctx->lock);
@@ -1900,11 +1901,10 @@ isc_mempool_getmaxalloc(isc_mempool_t *mpctx0) {
unsigned int
isc_mempool_getallocated(isc_mempool_t *mpctx0) {
REQUIRE(VALID_MEMPOOL(mpctx0));
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
unsigned int allocated;
REQUIRE(VALID_MEMPOOL(mpctx));
if (mpctx->lock != NULL)
LOCK(mpctx->lock);
@@ -1919,11 +1919,11 @@ isc_mempool_getallocated(isc_mempool_t *mpctx0) {
void
isc_mempool_setfillcount(isc_mempool_t *mpctx0, unsigned int limit) {
REQUIRE(VALID_MEMPOOL(mpctx0));
REQUIRE(limit > 0);
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
REQUIRE(limit > 0);
REQUIRE(VALID_MEMPOOL(mpctx));
if (mpctx->lock != NULL)
LOCK(mpctx->lock);
@@ -1935,12 +1935,12 @@ isc_mempool_setfillcount(isc_mempool_t *mpctx0, unsigned int limit) {
unsigned int
isc_mempool_getfillcount(isc_mempool_t *mpctx0) {
REQUIRE(VALID_MEMPOOL(mpctx0));
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
unsigned int fillcount;
REQUIRE(VALID_MEMPOOL(mpctx));
if (mpctx->lock != NULL)
LOCK(mpctx->lock);
@@ -2013,10 +2013,10 @@ static int
xml_renderctx(isc__mem_t *ctx, summarystat_t *summary,
xmlTextWriterPtr writer)
{
REQUIRE(VALID_CONTEXT(ctx));
int xmlrc;
REQUIRE(VALID_CONTEXT(ctx));
MCTXLOCK(ctx);
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "context"));
@@ -2198,13 +2198,13 @@ isc_mem_renderxml(void *writer0) {
static isc_result_t
json_renderctx(isc__mem_t *ctx, summarystat_t *summary, json_object *array) {
json_object *ctxobj, *obj;
char buf[1024];
REQUIRE(VALID_CONTEXT(ctx));
REQUIRE(summary != NULL);
REQUIRE(array != NULL);
json_object *ctxobj, *obj;
char buf[1024];
MCTXLOCK(ctx);
summary->contextsize += sizeof(*ctx) +
@@ -2411,11 +2411,11 @@ isc__mem_free(isc_mem_t *mctx, void *ptr FLARG) {
void
isc__mem_printactive(isc_mem_t *ctx0, FILE *file) {
#if ISC_MEM_TRACKLINES
REQUIRE(VALID_CONTEXT(ctx0));
REQUIRE(file != NULL);
isc__mem_t *ctx = (isc__mem_t *)ctx0;
REQUIRE(VALID_CONTEXT(ctx));
REQUIRE(file != NULL);
print_active(ctx, file);
#else
UNUSED(ctx0);
+2 -2
View File
@@ -33,7 +33,7 @@
#include "uv-compat.h"
#define ISC_NETMGR_TID_UNKNOWN -1
#define ISC_NETMGR_RECVBUF_SIZE (20*65536)
/*
* Single network event loop worker.
*/
@@ -55,7 +55,7 @@ typedef struct isc__networker {
* worker is paused */
isc_refcount_t references;
atomic_int_fast64_t pktcount;
char * recvbuf;
char recvbuf[65536];
bool recvbuf_inuse;
} isc__networker_t;
+4 -9
View File
@@ -210,7 +210,6 @@ isc_nm_start(isc_mem_t *mctx, uint32_t workers) {
worker->ievents = isc_queue_new(mgr->mctx, 128);
worker->ievents_prio = isc_queue_new(mgr->mctx, 128);
worker->recvbuf = isc_mem_get(mctx, ISC_NETMGR_RECVBUF_SIZE);
/*
* We need to do this here and not in nm_thread to avoid a
@@ -282,7 +281,6 @@ nm_destroy(isc_nm_t **mgr0) {
isc_queue_destroy(worker->ievents);
isc_queue_destroy(worker->ievents_prio);
isc_mem_put(mgr->mctx, worker->recvbuf, ISC_NETMGR_RECVBUF_SIZE);
isc_thread_join(worker->thread, NULL);
}
@@ -958,8 +956,8 @@ isc__nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr,
} else {
sock->statsindex = tcp6statsindex;
}
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_ACTIVE]);
break;
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_ACTIVE]);
default:
break;
}
@@ -984,14 +982,14 @@ isc__nm_alloc_cb(uv_handle_t *handle, size_t size, uv_buf_t *buf) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(isc__nm_in_netthread());
REQUIRE(size <= ISC_NETMGR_RECVBUF_SIZE);
REQUIRE(size <= 65536);
worker = &sock->mgr->workers[sock->tid];
INSIST(!worker->recvbuf_inuse);
buf->base = worker->recvbuf;
worker->recvbuf_inuse = true;
buf->len = ISC_NETMGR_RECVBUF_SIZE;
buf->len = size;
}
void
@@ -1006,11 +1004,8 @@ isc__nm_free_uvbuf(isc_nmsocket_t *sock, const uv_buf_t *buf) {
worker = &sock->mgr->workers[sock->tid];
REQUIRE(worker->recvbuf_inuse);
if (buf->base > worker->recvbuf && buf->base <= worker->recvbuf + ISC_NETMGR_RECVBUF_SIZE) {
/* Can happen in case of recvmmsg */
return;
}
REQUIRE(buf->base == worker->recvbuf);
worker->recvbuf_inuse = false;
}
+5 -5
View File
@@ -291,8 +291,8 @@ udp_recv_cb(uv_udp_t *handle, ssize_t nrecv, const uv_buf_t *buf,
isc_result_t result;
isc_nmhandle_t *nmhandle = NULL;
isc_sockaddr_t sockaddr;
/* isc_sockaddr_t localaddr;
struct sockaddr_storage laddr; */
isc_sockaddr_t localaddr;
struct sockaddr_storage laddr;
isc_nmsocket_t *sock = uv_handle_get_data((uv_handle_t *)handle);
isc_region_t region;
uint32_t maxudp;
@@ -326,13 +326,13 @@ udp_recv_cb(uv_udp_t *handle, ssize_t nrecv, const uv_buf_t *buf,
result = isc_sockaddr_fromsockaddr(&sockaddr, addr);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
/* uv_udp_getsockname(handle, (struct sockaddr *) &laddr,
uv_udp_getsockname(handle, (struct sockaddr *) &laddr,
&(int){sizeof(struct sockaddr_storage)});
result = isc_sockaddr_fromsockaddr(&localaddr,
(struct sockaddr *) &laddr);
RUNTIME_CHECK(result == ISC_R_SUCCESS); */
RUNTIME_CHECK(result == ISC_R_SUCCESS);
nmhandle = isc__nmhandle_get(sock, &sockaddr, NULL);
nmhandle = isc__nmhandle_get(sock, &sockaddr, &localaddr);
region.base = (unsigned char *) buf->base;
region.length = nrecv;
+6 -8
View File
@@ -14,7 +14,6 @@
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <isc/log.h>
#include <isc/mem.h>
@@ -22,7 +21,6 @@
#include <isc/platform.h>
#include <isc/print.h>
#include <isc/stdio.h>
#include <isc/strerr.h>
#include <isc/string.h>
#include <isc/thread.h>
#include <isc/util.h>
@@ -153,12 +151,8 @@ pk11_mem_get(size_t size) {
ptr = isc_mem_get(pk11_mctx, size);
else {
ptr = malloc(size);
if (ptr == NULL && size != 0) {
char strbuf[ISC_STRERRORSIZE];
strerror_r(errno, strbuf, sizeof(strbuf));
isc_error_fatal(__FILE__, __LINE__, "malloc failed: %s",
strbuf);
}
if (ptr != NULL)
allocsize += (int)size;
}
UNLOCK(&alloclock);
@@ -329,6 +323,8 @@ pk11_get_session(pk11_context_t *ctx, pk11_optype_t optype,
UNLOCK(&sessionlock);
sp = pk11_mem_get(sizeof(*sp));
if (sp == NULL)
return (ISC_R_NOMEMORY);
sp->magic = SES_MAGIC;
sp->token = token;
sp->session = CK_INVALID_HANDLE;
@@ -483,6 +479,7 @@ scan_slots(void) {
if (slotCount == 0)
return;
slotList = pk11_mem_get(sizeof(CK_SLOT_ID) * slotCount);
RUNTIME_CHECK(slotList != NULL);
PK11_FATALCHECK(pkcs_C_GetSlotList, (CK_FALSE, slotList, &slotCount));
for (i = 0; i < slotCount; i++) {
@@ -493,6 +490,7 @@ scan_slots(void) {
if (rv != CKR_OK)
continue;
token = pk11_mem_get(sizeof(*token));
RUNTIME_CHECK(token != NULL);
token->magic = TOK_MAGIC;
token->slotid = slot;
ISC_LINK_INIT(token, link);
+7 -7
View File
@@ -15,9 +15,9 @@
#include <stdlib.h>
#include <isc/lib.h>
#include <isc/mutex.h>
#include <isc/once.h>
#include <isc/resultclass.h>
#include <isc/rwlock.h>
#include <isc/util.h>
typedef struct resulttable {
@@ -182,7 +182,7 @@ static const char *identifier[ISC_R_NRESULTS] = {
static isc_once_t once = ISC_ONCE_INIT;
static resulttable_list_t description_tables;
static resulttable_list_t identifier_tables;
static isc_rwlock_t lock;
static isc_mutex_t lock;
static isc_result_t
register_table(resulttable_list_t *tables, unsigned int base,
@@ -208,11 +208,11 @@ register_table(resulttable_list_t *tables, unsigned int base,
table->set = set;
ISC_LINK_INIT(table, link);
RWLOCK(&lock, isc_rwlocktype_write);
LOCK(&lock);
ISC_LIST_APPEND(*tables, table, link);
RWUNLOCK(&lock, isc_rwlocktype_write);
UNLOCK(&lock);
return (ISC_R_SUCCESS);
}
@@ -221,7 +221,7 @@ static void
initialize_action(void) {
isc_result_t result;
isc_rwlock_init(&lock, 0, 0);
isc_mutex_init(&lock);
ISC_LIST_INIT(description_tables);
ISC_LIST_INIT(identifier_tables);
@@ -257,7 +257,7 @@ isc_result_tomany_helper(resulttable_list_t *tables, isc_result_t result) {
initialize();
RWLOCK(&lock, isc_rwlocktype_read);
LOCK(&lock);
text = NULL;
for (table = ISC_LIST_HEAD(*tables);
@@ -273,7 +273,7 @@ isc_result_tomany_helper(resulttable_list_t *tables, isc_result_t result) {
text = "(result code text not available)";
}
RWUNLOCK(&lock, isc_rwlocktype_read);
UNLOCK(&lock);
return (text);
}
+11 -44
View File
@@ -23,14 +23,11 @@
#include <isc/print.h>
#include <isc/refcount.h>
#include <isc/stats.h>
#include <isc/thread.h>
#include <isc/util.h>
#define ISC_STATS_MAGIC ISC_MAGIC('S', 't', 'a', 't')
#define ISC_STATS_VALID(x) ISC_MAGIC_VALID(x, ISC_STATS_MAGIC)
#define STATS_BUCKETS 64
#if defined(_WIN32) && !defined(_WIN64)
typedef atomic_int_fast32_t isc__atomic_statcounter_t;
#else
@@ -45,17 +42,6 @@ struct isc_stats {
isc__atomic_statcounter_t *counters;
};
ISC_THREAD_LOCAL int isc__stats_thread_v = -1;
static atomic_uint_fast32_t isc__stats_thread_n = 0;
static int
threadhash() {
if (isc__stats_thread_v < 0) {
isc__stats_thread_v = atomic_fetch_add_relaxed(&isc__stats_thread_n, 1) % STATS_BUCKETS;
}
return (isc__stats_thread_v);
}
static isc_result_t
create_stats(isc_mem_t *mctx, int ncounters, isc_stats_t **statsp) {
isc_stats_t *stats;
@@ -64,7 +50,7 @@ create_stats(isc_mem_t *mctx, int ncounters, isc_stats_t **statsp) {
REQUIRE(statsp != NULL && *statsp == NULL);
stats = isc_mem_get(mctx, sizeof(*stats));
counters_alloc_size = sizeof(isc__atomic_statcounter_t) * ncounters * STATS_BUCKETS;
counters_alloc_size = sizeof(isc__atomic_statcounter_t) * ncounters;
stats->counters = isc_mem_get(mctx, counters_alloc_size);
isc_refcount_init(&stats->references, 1);
memset(stats->counters, 0, counters_alloc_size);
@@ -99,8 +85,7 @@ isc_stats_detach(isc_stats_t **statsp) {
isc_refcount_destroy(&stats->references);
isc_mem_put(stats->mctx, stats->counters,
sizeof(isc__atomic_statcounter_t) *
stats->ncounters *
STATS_BUCKETS);
stats->ncounters);
isc_mem_putanddetach(&stats->mctx, stats, sizeof(*stats));
}
}
@@ -123,8 +108,8 @@ void
isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter) {
REQUIRE(ISC_STATS_VALID(stats));
REQUIRE(counter < stats->ncounters);
int idx = threadhash() * stats->ncounters + counter;
atomic_fetch_add_explicit(&stats->counters[idx], 1,
atomic_fetch_add_explicit(&stats->counters[counter], 1,
memory_order_relaxed);
}
@@ -133,8 +118,7 @@ isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter) {
REQUIRE(ISC_STATS_VALID(stats));
REQUIRE(counter < stats->ncounters);
int idx = threadhash() * stats->ncounters + counter;
atomic_fetch_sub_explicit(&stats->counters[idx], 1,
atomic_fetch_sub_explicit(&stats->counters[counter], 1,
memory_order_relaxed);
}
@@ -147,13 +131,8 @@ isc_stats_dump(isc_stats_t *stats, isc_stats_dumper_t dump_fn,
REQUIRE(ISC_STATS_VALID(stats));
for (i = 0; i < stats->ncounters; i++) {
uint32_t counter = 0;
int b;
for (b = 0; b < STATS_BUCKETS; b++) {
int idx = stats->ncounters * b + i;
counter += atomic_load_explicit(&stats->counters[idx],
uint32_t counter = atomic_load_explicit(&stats->counters[i],
memory_order_relaxed);
}
if ((options & ISC_STATSDUMP_VERBOSE) == 0 && counter == 0) {
continue;
}
@@ -165,17 +144,11 @@ void
isc_stats_set(isc_stats_t *stats, uint64_t val,
isc_statscounter_t counter)
{
int i;
REQUIRE(ISC_STATS_VALID(stats));
REQUIRE(counter < stats->ncounters);
atomic_store_explicit(&stats->counters[counter], val,
memory_order_relaxed);
for (i = 1; i < STATS_BUCKETS; i++) {
int idx = stats->ncounters * i + counter;
atomic_store_explicit(&stats->counters[idx], val,
memory_order_relaxed);
}
}
void isc_stats_update_if_greater(isc_stats_t *stats,
@@ -185,9 +158,9 @@ void isc_stats_update_if_greater(isc_stats_t *stats,
REQUIRE(ISC_STATS_VALID(stats));
REQUIRE(counter < stats->ncounters);
isc_statscounter_t curr_value;
isc_statscounter_t curr_value =
atomic_load_relaxed(&stats->counters[counter]);
do {
curr_value = atomic_load_relaxed(&stats->counters[counter]);
if (curr_value >= value) {
break;
}
@@ -199,15 +172,9 @@ void isc_stats_update_if_greater(isc_stats_t *stats,
isc_statscounter_t
isc_stats_get_counter(isc_stats_t *stats, isc_statscounter_t counter)
{
uint32_t value = 0;
int i;
REQUIRE(ISC_STATS_VALID(stats));
REQUIRE(counter < stats->ncounters);
for (i = 0; i < STATS_BUCKETS; i++) {
int idx = i * stats->ncounters + counter;
value += atomic_load_explicit(&stats->counters[idx],
memory_order_relaxed);
}
return (value);
return (atomic_load_explicit(&stats->counters[counter],
memory_order_relaxed));
}
+29 -54
View File
@@ -106,7 +106,6 @@ struct isc__task {
isc_mutex_t lock;
/* Locked by task lock. */
task_state_t state;
int pause_cnt;
isc_refcount_t references;
isc_eventlist_t events;
isc_eventlist_t on_shutdown;
@@ -153,7 +152,6 @@ struct isc__taskqueue {
isc_thread_t thread;
unsigned int threadid;
isc__taskmgr_t *manager;
uint64_t eprocessed;
};
struct isc__taskmgr {
@@ -310,7 +308,6 @@ isc_task_create_bound(isc_taskmgr_t *manager0, unsigned int quantum,
isc_mutex_init(&task->lock);
task->state = task_state_idle;
task->pause_cnt = 0;
isc_refcount_init(&task->references, 1);
INIT_LIST(task->events);
@@ -410,7 +407,7 @@ task_shutdown(isc__task_t *task) {
/*
* Moves a task onto the appropriate run queue.
*
* Caller must NOT hold queue lock.
* Caller must NOT hold manager lock.
*/
static inline void
task_ready(isc__task_t *task) {
@@ -418,6 +415,7 @@ task_ready(isc__task_t *task) {
bool has_privilege = isc_task_privilege((isc_task_t *) task);
REQUIRE(VALID_MANAGER(manager));
REQUIRE(task->state == task_state_ready);
XTRACE("task_ready");
LOCK(&manager->queues[task->threadid].lock);
@@ -969,13 +967,10 @@ pop_readyq(isc__taskmgr_t *manager, int c) {
* Push 'task' onto the ready_tasks queue. If 'task' has the privilege
* flag set, then also push it onto the ready_priority_tasks queue.
*
* Caller must hold the task queue lock.
* Caller must hold the task manager lock.
*/
static inline void
push_readyq(isc__taskmgr_t *manager, isc__task_t *task, int c) {
if (ISC_LINK_LINKED(task, ready_link)) {
return;
}
ENQUEUE(manager->queues[c].ready_tasks, task, ready_link);
if (TASK_PRIVILEGED(task)) {
ENQUEUE(manager->queues[c].ready_priority_tasks, task,
@@ -1133,17 +1128,6 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
memory_order_acquire);
LOCK(&task->lock);
/*
* It is possible because that we have a paused task
* in the queue - it might have been paused in the
* meantime and we never hold both queue and task lock
* to avoid deadlocks, just bail then.
*/
if (task->state != task_state_ready) {
UNLOCK(&task->lock);
LOCK(&manager->queues[threadid].lock);
continue;
}
INSIST(task->state == task_state_ready);
task->state = task_state_running;
XTRACE("running");
@@ -1161,7 +1145,6 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
*/
XTRACE("execute action");
XTRACE(task->name);
manager->queues[threadid].eprocessed++;
if (event->ev_action != NULL) {
UNLOCK(&task->lock);
(event->ev_action)(
@@ -1232,15 +1215,6 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
}
}
done = true;
} else if (task->state == task_state_pausing) {
/*
* We got a pause request on this task,
* stop working on it and switch the state
* to paused.
*/
XTRACE("pausing");
task->state = task_state_paused;
done = true;
} else if (dispatch_count >= task->quantum) {
/*
* Our quantum has expired, but
@@ -1253,8 +1227,17 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
* so the minimum quantum is one.
*/
XTRACE("quantum");
task->state = task_state_ready;
requeue = true;
if (task->state == task_state_running) {
/*
* We requeue only if it's
* not paused.
*/
task->state = task_state_ready;
requeue = true;
} else if (task->state ==
task_state_pausing) {
task->state = task_state_paused;
}
done = true;
}
} while (!done);
@@ -1445,7 +1428,6 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
manager->queues[i].manager = manager;
manager->queues[i].threadid = i;
manager->queues[i].eprocessed = 0;
isc_thread_create(run, &manager->queues[i],
&manager->queues[i].thread);
char name[21];
@@ -1541,11 +1523,7 @@ isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
*/
wake_all_queues(manager);
UNLOCK(&manager->lock);
FILE * f = fopen("/tmp/foobar","w");
for (i=0; i< manager->workers; i++) {
fprintf(f, "%d: %lu\n", i, manager->queues[i].eprocessed);
}
fclose(f);
/*
* Wait for all the worker threads to exit.
*/
@@ -1708,27 +1686,31 @@ void
isc_task_pause(isc_task_t *task0) {
REQUIRE(ISCAPI_TASK_VALID(task0));
isc__task_t *task = (isc__task_t *)task0;
isc__taskmgr_t *manager = task->manager;
bool running = false;
LOCK(&task->lock);
task->pause_cnt++;
if (task->pause_cnt > 1) {
/*
* Someone already paused this thread, just increase
* the number of pausing clients.
*/
UNLOCK(&task->lock);
return;
}
INSIST(task->state == task_state_idle ||
task->state == task_state_ready ||
task->state == task_state_running);
if (task->state == task_state_running) {
running = true;
task->state = task_state_pausing;
} else {
task->state = task_state_paused;
}
UNLOCK(&task->lock);
if (running) {
return;
}
LOCK(&manager->queues[task->threadid].lock);
if (ISC_LINK_LINKED(task, ready_link)) {
DEQUEUE(manager->queues[task->threadid].ready_tasks,
task, ready_link);
}
UNLOCK(&manager->queues[task->threadid].lock);
}
void
@@ -1739,13 +1721,6 @@ isc_task_unpause(isc_task_t *task0) {
REQUIRE(ISCAPI_TASK_VALID(task0));
LOCK(&task->lock);
task->pause_cnt--;
INSIST(task->pause_cnt >= 0);
if (task->pause_cnt > 0) {
UNLOCK(&task->lock);
return;
}
INSIST(task->state == task_state_paused ||
task->state == task_state_pausing);
/* If the task was pausing we can't reschedule it */
+9 -4
View File
@@ -65,7 +65,8 @@ isc_buffer_reserve_test(void **state) {
UNUSED(state);
b = NULL;
isc_buffer_allocate(test_mctx, &b, 1024);
result = isc_buffer_allocate(test_mctx, &b, 1024);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(b->length, 1024);
/*
@@ -126,6 +127,7 @@ isc_buffer_reserve_test(void **state) {
/* dynamic buffer automatic reallocation */
static void
isc_buffer_dynamic_test(void **state) {
isc_result_t result;
isc_buffer_t *b;
size_t last_length = 10;
int i;
@@ -133,7 +135,8 @@ isc_buffer_dynamic_test(void **state) {
UNUSED(state);
b = NULL;
isc_buffer_allocate(test_mctx, &b, last_length);
result = isc_buffer_allocate(test_mctx, &b, last_length);
assert_int_equal(result, ISC_R_SUCCESS);
assert_non_null(b);
assert_int_equal(b->length, last_length);
@@ -191,7 +194,8 @@ isc_buffer_copyregion_test(void **state) {
UNUSED(state);
isc_buffer_allocate(test_mctx, &b, sizeof(data));
result = isc_buffer_allocate(test_mctx, &b, sizeof(data));
assert_int_equal(result, ISC_R_SUCCESS);
/*
* Fill originally allocated buffer space.
@@ -230,7 +234,8 @@ isc_buffer_printf_test(void **state) {
* Prepare a buffer with auto-reallocation enabled.
*/
b = NULL;
isc_buffer_allocate(test_mctx, &b, 0);
result = isc_buffer_allocate(test_mctx, &b, 0);
assert_int_equal(result, ISC_R_SUCCESS);
isc_buffer_setautorealloc(b, true);
/*
+10 -4
View File
@@ -69,6 +69,7 @@ _teardown(void **state) {
/* general memory system tests */
static void
isc_mem_test(void **state) {
isc_result_t result;
void *items1[50];
void *items2[50];
void *tmp;
@@ -78,8 +79,11 @@ isc_mem_test(void **state) {
UNUSED(state);
isc_mempool_create(test_mctx, 24, &mp1);
isc_mempool_create(test_mctx, 31, &mp2);
result = isc_mempool_create(test_mctx, 24, &mp1);
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_mempool_create(test_mctx, 31, &mp2);
assert_int_equal(result, ISC_R_SUCCESS);
isc_mempool_setfreemax(mp1, MP1_FREEMAX);
isc_mempool_setfillcount(mp1, MP1_FILLCNT);
@@ -144,7 +148,8 @@ isc_mem_test(void **state) {
isc_mempool_destroy(&mp1);
isc_mempool_destroy(&mp2);
isc_mempool_create(test_mctx, 2, &mp1);
result = isc_mempool_create(test_mctx, 2, &mp1);
assert_int_equal(result, ISC_R_SUCCESS);
tmp = isc_mempool_get(mp1);
assert_non_null(tmp);
@@ -455,7 +460,8 @@ isc_mempool_benchmark(void **state) {
isc_mutex_init(&mplock);
isc_mempool_create(test_mctx, ITEM_SIZE, &mp);
result = isc_mempool_create(test_mctx, ITEM_SIZE, &mp);
assert_int_equal(result, ISC_R_SUCCESS);
isc_mempool_associatelock(mp, &mplock);
+4 -4
View File
@@ -239,10 +239,6 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
isc_task_t *task, isc_taskaction_t action, void *arg,
isc_timer_t **timerp)
{
REQUIRE(VALID_MANAGER(manager0));
REQUIRE(task != NULL);
REQUIRE(action != NULL);
isc__timermgr_t *manager;
isc__timer_t *timer;
isc_result_t result;
@@ -255,7 +251,11 @@ isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
* called with 'arg' as the arg value. The new timer is returned
* in 'timerp'.
*/
REQUIRE(VALID_MANAGER(manager0));
manager = (isc__timermgr_t *)manager0;
REQUIRE(task != NULL);
REQUIRE(action != NULL);
if (expires == NULL)
expires = isc_time_epoch;
if (interval == NULL)
+1 -1
View File
@@ -30,7 +30,7 @@
* The last resort defaults: use all non well known port space
*/
#ifndef ISC_NET_PORTRANGELOW
#define ISC_NET_PORTRANGELOW 32768
#define ISC_NET_PORTRANGELOW 1024
#endif /* ISC_NET_PORTRANGELOW */
#ifndef ISC_NET_PORTRANGEHIGH
#define ISC_NET_PORTRANGEHIGH 65535
+57 -62
View File
@@ -132,8 +132,6 @@ static void compute_cookie(ns_client_t *client, uint32_t when,
isc_buffer_t *buf);
static void
get_clientmctx(ns_clientmgr_t *manager, isc_mem_t **mctxp);
static void
get_clienttask(ns_clientmgr_t *manager, isc_task_t **taskp);
void
ns_client_recursing(ns_client_t *client) {
@@ -1662,7 +1660,6 @@ ns__client_request(isc_nmhandle_t *handle, isc_region_t *region, void *arg) {
return;
}
}
atomic_fetch_add_relaxed(&mgr->tbuckets[isc_nm_tid()], 1);
client->state = NS_CLIENTSTATE_READY;
client->dscp = ifp->dscp;
@@ -2215,34 +2212,38 @@ ns__client_tcpconn(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
static void
get_clientmctx(ns_clientmgr_t *manager, isc_mem_t **mctxp) {
isc_mem_t *clientmctx;
#if CLIENT_NMCTXS > 0
unsigned int nextmctx;
#endif
MTRACE("clientmctx");
int tid = isc_nm_tid();
if (tid < 0) {
tid = isc_random_uniform(manager->ncpus);
#if CLIENT_NMCTXS > 0
LOCK(&manager->lock);
if (isc_nm_tid() >= 0) {
nextmctx = isc_nm_tid();
} else {
nextmctx = manager->nextmctx++;
if (manager->nextmctx == CLIENT_NMCTXS)
manager->nextmctx = 0;
INSIST(nextmctx < CLIENT_NMCTXS);
}
int rand = isc_random_uniform(CLIENT_NMCTXS_PERCPU);
int nextmctx = (rand * manager->ncpus) + tid;
clientmctx = manager->mctxpool[nextmctx];
if (clientmctx == NULL) {
isc_mem_create(&clientmctx);
isc_mem_setname(clientmctx, "client", NULL);
manager->mctxpool[nextmctx] = clientmctx;
}
UNLOCK(&manager->lock);
#else
clientmctx = manager->mctx;
#endif
isc_mem_attach(clientmctx, mctxp);
}
static void
get_clienttask(ns_clientmgr_t *manager, isc_task_t **taskp) {
MTRACE("clienttask");
int tid = isc_nm_tid();
if (tid < 0) {
tid = isc_random_uniform(manager->ncpus);
}
int rand = isc_random_uniform(CLIENT_NTASKS_PERCPU);
int nexttask = (rand * manager->ncpus) + tid;
atomic_fetch_add_relaxed(&manager->xbuckets[nexttask], 1);
isc_task_attach(manager->taskpool[nexttask], taskp);
}
isc_result_t
ns__client_setup(ns_client_t *client, ns_clientmgr_t *mgr, bool new) {
isc_result_t result;
@@ -2266,8 +2267,10 @@ ns__client_setup(ns_client_t *client, ns_clientmgr_t *mgr, bool new) {
get_clientmctx(mgr, &client->mctx);
clientmgr_attach(mgr, &client->manager);
ns_server_attach(mgr->sctx, &client->sctx);
get_clienttask(mgr, &client->task);
result = isc_task_create(mgr->taskmgr, 20, &client->task);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
result = dns_message_create(client->mctx,
DNS_MESSAGE_INTENTPARSE,
&client->message);
@@ -2394,18 +2397,21 @@ clientmgr_detach(ns_clientmgr_t **mp) {
static void
clientmgr_destroy(ns_clientmgr_t *manager) {
#if CLIENT_NMCTXS > 0
int i;
#endif
MTRACE("clientmgr_destroy");
isc_refcount_destroy(&manager->references);
manager->magic = 0;
for (i = 0; i < manager->ncpus * CLIENT_NMCTXS_PERCPU; i++) {
isc_mem_detach(&manager->mctxpool[i]);
#if CLIENT_NMCTXS > 0
for (i = 0; i < CLIENT_NMCTXS; i++) {
if (manager->mctxpool[i] != NULL)
isc_mem_detach(&manager->mctxpool[i]);
}
isc_mem_put(manager->mctx, manager->mctxpool,
manager->ncpus * CLIENT_NMCTXS_PERCPU * sizeof(isc_mem_t*));
#endif
if (manager->interface != NULL) {
ns_interface_detach(&manager->interface);
@@ -2416,22 +2422,14 @@ clientmgr_destroy(ns_clientmgr_t *manager) {
if (manager->excl != NULL)
isc_task_detach(&manager->excl);
char x[1024];
snprintf(x, 1024, "/tmp/foo.%p", manager);
FILE * f = fopen(x,"w");
for (i = 0; i < manager->ncpus * CLIENT_NTASKS_PERCPU; i++) {
fprintf(f, "%d: %ld\n", i, manager->xbuckets[i]);
for (i = 0; i < CLIENT_NTASKS; i++) {
if (manager->taskpool[i] != NULL) {
isc_task_detach(&manager->taskpool[i]);
}
}
for (i = 0; i < manager->ncpus; i++) {
fprintf(f, "T%d: %ld\n", i, manager->tbuckets[i]);
}
fclose(f);
isc_mem_put(manager->mctx, manager->taskpool,
manager->ncpus * CLIENT_NTASKS_PERCPU *
sizeof(isc_task_t *));
CLIENT_NTASKS * sizeof(isc_task_t *));
ns_server_detach(&manager->sctx);
isc_mem_put(manager->mctx, manager, sizeof(*manager));
@@ -2440,12 +2438,13 @@ clientmgr_destroy(ns_clientmgr_t *manager) {
isc_result_t
ns_clientmgr_create(isc_mem_t *mctx, ns_server_t *sctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, ns_interface_t *interface,
int ncpus, ns_clientmgr_t **managerp)
ns_clientmgr_t **managerp)
{
ns_clientmgr_t *manager;
isc_result_t result;
#if CLIENT_NMCTXS > 0
int i;
int npools;
#endif
manager = isc_mem_get(mctx, sizeof(*manager));
*manager = (ns_clientmgr_t) { .magic = 0 };
@@ -2462,36 +2461,26 @@ ns_clientmgr_create(isc_mem_t *mctx, ns_server_t *sctx, isc_taskmgr_t *taskmgr,
manager->mctx = mctx;
manager->taskmgr = taskmgr;
manager->timermgr = timermgr;
manager->ncpus = ncpus;
ns_interface_attach(interface, &manager->interface);
manager->exiting = false;
int ntasks = CLIENT_NTASKS_PERCPU * manager->ncpus;
manager->taskpool = isc_mem_get(mctx, ntasks * sizeof(isc_task_t *));
for (i = 0; i < ntasks; i++) {
atomic_init(&manager->xbuckets[i], 0);
manager->taskpool =
isc_mem_get(mctx, CLIENT_NTASKS*sizeof(isc_task_t *));
for (i = 0; i < CLIENT_NTASKS; i++) {
manager->taskpool[i] = NULL;
result = isc_task_create_bound(manager->taskmgr, 20,
&manager->taskpool[i],
i % manager->ncpus);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
isc_task_create(manager->taskmgr, 20, &manager->taskpool[i]);
}
isc_refcount_init(&manager->references, 1);
manager->sctx = NULL;
ns_server_attach(sctx, &manager->sctx);
ISC_LIST_INIT(manager->recursing);
npools = CLIENT_NMCTXS_PERCPU * manager->ncpus;
manager->mctxpool = isc_mem_get(manager->mctx,
npools * sizeof(isc_mem_t*));
for (i = 0; i < npools; i++) {
manager->mctxpool[i] = NULL;
isc_mem_create(&manager->mctxpool[i]);
isc_mem_setname(manager->mctxpool[i], "client", NULL);
}
#if CLIENT_NMCTXS > 0
manager->nextmctx = 0;
for (i = 0; i < CLIENT_NMCTXS; i++)
manager->mctxpool[i] = NULL; /* will be created on-demand */
#endif
manager->magic = MANAGER_MAGIC;
MTRACE("create");
@@ -2869,11 +2858,17 @@ ns_client_putrdataset(ns_client_t *client, dns_rdataset_t **rdatasetp) {
isc_result_t
ns_client_newnamebuf(ns_client_t *client) {
isc_buffer_t *dbuf;
isc_result_t result;
CTRACE("ns_client_newnamebuf");
dbuf = NULL;
isc_buffer_allocate(client->mctx, &dbuf, 1024);
result = isc_buffer_allocate(client->mctx, &dbuf, 1024);
if (result != ISC_R_SUCCESS) {
CTRACE("ns_client_newnamebuf: "
"isc_buffer_allocate failed: done");
return (result);
}
ISC_LIST_APPEND(client->query.namebufs, dbuf, link);
CTRACE("ns_client_newnamebuf: done");
+8 -8
View File
@@ -85,7 +85,7 @@
#define NS_CLIENT_SEND_BUFFER_SIZE 4096
#define NS_CLIENT_RECV_BUFFER_SIZE 4096
#define CLIENT_NMCTXS_PERCPU 8
#define CLIENT_NMCTXS 100
/*%<
* Number of 'mctx pools' for clients. (Should this be configurable?)
* When enabling threads, we use a pool of memory contexts shared by
@@ -95,7 +95,7 @@
* server.
*/
#define CLIENT_NTASKS_PERCPU 16
#define CLIENT_NTASKS 100
/*%<
* Number of tasks to be used by clients - those are used only when recursing
*/
@@ -166,13 +166,10 @@ struct ns_clientmgr {
isc_timermgr_t * timermgr;
isc_task_t * excl;
isc_refcount_t references;
int ncpus;
/* Attached by clients, needed for e.g. recursion */
isc_task_t ** taskpool;
atomic_uint_fast32_t xbuckets[1000];
atomic_uint_fast32_t tbuckets[1000];
ns_interface_t *interface;
/* Lock covers manager state. */
@@ -183,8 +180,11 @@ struct ns_clientmgr {
isc_mutex_t reclock;
client_list_t recursing; /*%< Recursing clients */
#if CLIENT_NMCTXS > 0
/*%< mctx pool for clients. */
isc_mem_t ** mctxpool;
unsigned int nextmctx;
isc_mem_t * mctxpool[CLIENT_NMCTXS];
#endif
};
/*% nameserver client structure */
@@ -364,7 +364,7 @@ ns_client_settimeout(ns_client_t *client, unsigned int seconds);
isc_result_t
ns_clientmgr_create(isc_mem_t *mctx, ns_server_t *sctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, ns_interface_t *ifp, int ncpus,
isc_timermgr_t *timermgr, ns_interface_t *ifp,
ns_clientmgr_t **managerp);
/*%<
* Create a client manager.
+1 -1
View File
@@ -103,7 +103,7 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx,
isc_socketmgr_t *socketmgr, isc_nm_t *nm,
dns_dispatchmgr_t *dispatchmgr, isc_task_t *task,
unsigned int udpdisp, dns_geoip_databases_t *geoip,
int ncpus, ns_interfacemgr_t **mgrp);
ns_interfacemgr_t **mgrp);
/*%<
* Create a new interface manager.
*
+1 -4
View File
@@ -75,7 +75,6 @@ struct ns_interfacemgr {
isc_timermgr_t * timermgr; /*%< Timer manager. */
isc_socketmgr_t * socketmgr; /*%< Socket manager. */
isc_nm_t * nm; /*%< Net manager. */
int ncpus; /*%< Number of workers . */
dns_dispatchmgr_t * dispatchmgr;
unsigned int generation; /*%< Current generation no. */
ns_listenlist_t * listenon4;
@@ -182,7 +181,6 @@ ns_interfacemgr_create(isc_mem_t *mctx,
isc_task_t *task,
unsigned int udpdisp,
dns_geoip_databases_t *geoip,
int ncpus,
ns_interfacemgr_t **mgrp)
{
isc_result_t result;
@@ -221,7 +219,6 @@ ns_interfacemgr_create(isc_mem_t *mctx,
mgr->listenon4 = NULL;
mgr->listenon6 = NULL;
mgr->udpdisp = udpdisp;
mgr->ncpus = ncpus;
atomic_init(&mgr->shuttingdown, false);
ISC_LIST_INIT(mgr->interfaces);
@@ -428,7 +425,7 @@ ns_interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
result = ns_clientmgr_create(mgr->mctx, mgr->sctx,
mgr->taskmgr, mgr->timermgr, ifp,
mgr->ncpus, &ifp->clientmgr);
&ifp->clientmgr);
if (result != ISC_R_SUCCESS) {
isc_log_write(IFMGR_COMMON_LOGARGS, ISC_LOG_ERROR,
"ns_clientmgr_create() failed: %s",
+9 -5
View File
@@ -7458,9 +7458,11 @@ query_dns64(query_ctx_t *qctx) {
isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr);
isc_buffer_allocate(client->mctx, &buffer,
view->dns64cnt * 16 *
dns_rdataset_count(qctx->rdataset));
result = isc_buffer_allocate(client->mctx, &buffer,
view->dns64cnt * 16 *
dns_rdataset_count(qctx->rdataset));
if (result != ISC_R_SUCCESS)
goto cleanup;
result = dns_message_gettemprdataset(client->message,
&dns64_rdataset);
if (result != ISC_R_SUCCESS)
@@ -7626,8 +7628,10 @@ query_filter64(query_ctx_t *qctx) {
client->query.attributes &= ~NS_QUERYATTR_SECURE;
}
isc_buffer_allocate(client->mctx, &buffer,
16 * dns_rdataset_count(qctx->rdataset));
result = isc_buffer_allocate(client->mctx, &buffer,
16 * dns_rdataset_count(qctx->rdataset));
if (result != ISC_R_SUCCESS)
goto cleanup;
result = dns_message_gettemprdataset(client->message, &myrdataset);
if (result != ISC_R_SUCCESS)
goto cleanup;
+1 -1
View File
@@ -237,7 +237,7 @@ create_managers(void) {
CHECK(ns_interfacemgr_create(mctx, sctx, taskmgr, timermgr,
socketmgr, nm, dispatchmgr, maintask,
ncpus, NULL, 1, &interfacemgr));
ncpus, NULL, &interfacemgr));
CHECK(ns_listenlist_default(mctx, port, -1, true, &listenon));
ns_interfacemgr_setlistenon4(interfacemgr, listenon);
+5 -1
View File
@@ -236,7 +236,11 @@ main(int argc, char *argv[]) {
/* Dump the response */
outputbuf = NULL;
isc_buffer_allocate(mctx, &outputbuf, 65535);
result = isc_buffer_allocate(mctx, &outputbuf, 65535);
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "failed to allocate a result buffer\n");
exit(1);
}
for (i = 0; i < DNS_SECTION_MAX; i++) {
print_section(rmessage, i, outputbuf);
isc_buffer_clear(outputbuf);
+4 -2
View File
@@ -443,14 +443,16 @@ parse_rdata(isc_mem_t *mctx, char **cmdlinep, dns_rdataclass_t rdataclass,
isc_buffer_add(&source, strlen(cmdline));
result = isc_lex_openbuffer(lex, &source);
check_result(result, "isc_lex_openbuffer");
isc_buffer_allocate(mctx, &buf, MAXWIRE);
result = isc_buffer_allocate(mctx, &buf, MAXWIRE);
check_result(result, "isc_buffer_allocate");
result = dns_rdata_fromtext(rdata, rdataclass, rdatatype, lex,
dns_rootname, 0, mctx, buf,
&callbacks);
isc_lex_destroy(&lex);
if (result == ISC_R_SUCCESS) {
isc_buffer_usedregion(buf, &r);
isc_buffer_allocate(mctx, &newbuf, r.length);
result = isc_buffer_allocate(mctx, &newbuf, r.length);
check_result(result, "isc_buffer_allocate");
isc_buffer_putmem(newbuf, r.base, r.length);
isc_buffer_usedregion(newbuf, &r);
dns_rdata_reset(rdata);
+1 -1
View File
@@ -9,7 +9,7 @@ export CMOCKA_MESSAGE_OUTPUT
GDB="$(command -v gdb)"
kyua_report() {
${KYUA} --logfile /dev/null report --results-file "${KYUA_RESULT:-LATEST}"
${KYUA} --logfile /dev/null report --verbose --results-file "${KYUA_RESULT:-LATEST}"
}
status=0

Some files were not shown because too many files have changed in this diff Show More