Compare commits
108
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92eb269a7d | ||
|
|
9a4e4fde31 | ||
|
|
b6c25c0f00 | ||
|
|
3f19388210 | ||
|
|
30bdd05727 | ||
|
|
b7aac20168 | ||
|
|
b1db9d5325 | ||
|
|
7f4a8bf853 | ||
|
|
2f9e77b2ee | ||
|
|
9fb6709515 | ||
|
|
a628172de2 | ||
|
|
650900f2e9 | ||
|
|
3fc5214464 | ||
|
|
b2d93928af | ||
|
|
e610325783 | ||
|
|
fe24b48e9f | ||
|
|
ded06dc3c5 | ||
|
|
1d802a23a1 | ||
|
|
39645122da | ||
|
|
3d9763b968 | ||
|
|
b6d9add750 | ||
|
|
f71e673751 | ||
|
|
2873ad7f46 | ||
|
|
41cec3a619 | ||
|
|
8a7bfc8850 | ||
|
|
ecb619b71c | ||
|
|
c0bf9b9e26 | ||
|
|
7fae1ef12b | ||
|
|
2f694f0b77 | ||
|
|
67d245d965 | ||
|
|
e6c5ecd698 | ||
|
|
aea824f16e | ||
|
|
a9a9aa7fd8 | ||
|
|
b378d0371f | ||
|
|
a787bc0b14 | ||
|
|
be3a11029a | ||
|
|
5214f24d7b | ||
|
|
7f0fcb8a3e | ||
|
|
dd6598f391 | ||
|
|
891f24fa57 | ||
|
|
fccf65a585 | ||
|
|
bf7a99a3c1 | ||
|
|
7ba1af0280 | ||
|
|
714594d468 | ||
|
|
44b08521ef | ||
|
|
0312e73e16 | ||
|
|
d64921848d | ||
|
|
2e189bb053 | ||
|
|
1b1a94ea6d | ||
|
|
8456b5627d | ||
|
|
e4d08c0232 | ||
|
|
b6c3a2f172 | ||
|
|
1efc7550a3 | ||
|
|
5fc9efba30 | ||
|
|
aa101260d9 | ||
|
|
0be2dc9f22 | ||
|
|
331b74d6bf | ||
|
|
a038f77d92 | ||
|
|
d162bbcceb | ||
|
|
a9bd6f6ea6 | ||
|
|
9943c5dce5 | ||
|
|
2c0c333d16 | ||
|
|
830d40b36e | ||
|
|
7135ef78ee | ||
|
|
37b41ff693 | ||
|
|
3079956ff7 | ||
|
|
59a1e5564d | ||
|
|
99ed3a0e13 | ||
|
|
a9c1fffba0 | ||
|
|
b8be29fee6 | ||
|
|
2868eafc46 | ||
|
|
c00def343f | ||
|
|
05ae2e48ab | ||
|
|
478e4ac201 | ||
|
|
bb65e57297 | ||
|
|
d6de520bd1 | ||
|
|
704b9ee9d0 | ||
|
|
c65c06301c | ||
|
|
f17b9b8dd1 | ||
|
|
7b948c7335 | ||
|
|
6c2e138d7a | ||
|
|
668a972d1e | ||
|
|
dfd96e1aa5 | ||
|
|
7a002c7ece | ||
|
|
fc4e44bd37 | ||
|
|
8745043a86 | ||
|
|
dba0163dac | ||
|
|
9f6e0dc945 | ||
|
|
c73e5866c4 | ||
|
|
d5f682a00b | ||
|
|
4459745ff2 | ||
|
|
9286548c7e | ||
|
|
5eb3f71a3e | ||
|
|
33328871a7 | ||
|
|
de123a67d6 | ||
|
|
1248f05ae8 | ||
|
|
8ceaf28442 | ||
|
|
2ec5b852df | ||
|
|
02c2fc5ad3 | ||
|
|
7c0d9dac9f | ||
|
|
d159fdf25d | ||
|
|
68a360772f | ||
|
|
379949cce4 | ||
|
|
272a31f758 | ||
|
|
279f6b01de | ||
|
|
a09c464a20 | ||
|
|
f91b3a69ce | ||
|
|
0adb4b25d3 |
+9
-6
@@ -60,7 +60,7 @@ stages:
|
||||
|
||||
.openbsd-amd64: &openbsd_amd64
|
||||
tags:
|
||||
- openbsd
|
||||
- libvirt
|
||||
- amd64
|
||||
|
||||
### Docker Image Templates
|
||||
@@ -1071,20 +1071,23 @@ unit:clang:freebsd12.0:amd64:
|
||||
- clang:freebsd12.0:amd64
|
||||
needs: ["clang:freebsd12.0:amd64"]
|
||||
|
||||
# Jobs for Clang builds on OpenBSD 6.5 (amd64)
|
||||
# Jobs for Clang builds on OpenBSD 6.6 (amd64)
|
||||
|
||||
clang:openbsd6.5:amd64:
|
||||
clang:openbsd6.6:amd64:
|
||||
variables:
|
||||
CC: clang
|
||||
USER: gitlab-runner
|
||||
<<: *openbsd_amd64
|
||||
<<: *build_job
|
||||
|
||||
system:clang:openbsd6.5:amd64:
|
||||
system:clang:openbsd6.6:amd64:
|
||||
<<: *openbsd_amd64
|
||||
<<: *system_test_job
|
||||
variables:
|
||||
USER: gitlab-runner
|
||||
dependencies:
|
||||
- clang:openbsd6.5:amd64
|
||||
needs: ["clang:openbsd6.5:amd64"]
|
||||
- clang:openbsd6.6:amd64
|
||||
needs: ["clang:openbsd6.6:amd64"]
|
||||
only:
|
||||
- schedules
|
||||
- tags
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
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]
|
||||
|
||||
@@ -34,7 +34,7 @@ offer support on a "best effort" basis for some.
|
||||
|
||||
Regularly tested platforms
|
||||
|
||||
As of Dec 2019, BIND 9.15 is fully supported and regularly tested on the
|
||||
As of Feb 2020, 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.5
|
||||
* OpenBSD 6.6
|
||||
* Alpine Linux
|
||||
|
||||
The amd64, i386, armhf and arm64 CPU architectures are all fully
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ offer support on a "best effort" basis for some.
|
||||
|
||||
### Regularly tested platforms
|
||||
|
||||
As of Dec 2019, BIND 9.15 is fully supported and regularly tested on the
|
||||
As of Feb 2020, 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.5
|
||||
* OpenBSD 6.6
|
||||
* Alpine Linux
|
||||
|
||||
The amd64, i386, armhf and arm64 CPU architectures are all fully supported.
|
||||
|
||||
+3
-8
@@ -568,8 +568,7 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
||||
if (!query->lookup->comments)
|
||||
flags |= DNS_MESSAGETEXTFLAG_NOCOMMENTS;
|
||||
|
||||
result = isc_buffer_allocate(mctx, &buf, len);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
isc_buffer_allocate(mctx, &buf, len);
|
||||
|
||||
if (yaml) {
|
||||
enum { Q = 0x1, R = 0x2 }; /* Q:query; R:ecursive */
|
||||
@@ -742,11 +741,8 @@ repopulate_buffer:
|
||||
buftoosmall:
|
||||
len += OUTPUTBUF;
|
||||
isc_buffer_free(&buf);
|
||||
result = isc_buffer_allocate(mctx, &buf, len);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
goto repopulate_buffer;
|
||||
else
|
||||
goto cleanup;
|
||||
isc_buffer_allocate(mctx, &buf, len);
|
||||
goto repopulate_buffer;
|
||||
}
|
||||
check_result(result,
|
||||
"dns_message_pseudosectiontotext");
|
||||
@@ -827,7 +823,6 @@ buftoosmall:
|
||||
(char *)isc_buffer_base(buf));
|
||||
isc_buffer_free(&buf);
|
||||
|
||||
cleanup:
|
||||
if (style != NULL)
|
||||
dns_master_styledestroy(&style, mctx);
|
||||
return (result);
|
||||
|
||||
+2
-5
@@ -883,10 +883,8 @@ setup_text_key(void) {
|
||||
unsigned char *secretstore;
|
||||
|
||||
debug("setup_text_key()");
|
||||
result = isc_buffer_allocate(mctx, &namebuf, MXNAME);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
isc_buffer_allocate(mctx, &namebuf, MXNAME);
|
||||
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);
|
||||
@@ -1396,8 +1394,7 @@ setup_libs(void) {
|
||||
check_result(result, "dst_lib_init");
|
||||
is_dst_up = true;
|
||||
|
||||
result = isc_mempool_create(mctx, COMMSIZE, &commctx);
|
||||
check_result(result, "isc_mempool_create");
|
||||
isc_mempool_create(mctx, COMMSIZE, &commctx);
|
||||
isc_mempool_setname(commctx, "COMMPOOL");
|
||||
/*
|
||||
* 6 and 2 set as reasonable parameters for 3 or 4 nameserver
|
||||
|
||||
+1
-2
@@ -199,8 +199,7 @@ say_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
|
||||
|
||||
dns_name_format(name, namestr, sizeof(namestr));
|
||||
retry:
|
||||
result = isc_buffer_allocate(mctx, &b, bufsize);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
isc_buffer_allocate(mctx, &b, bufsize);
|
||||
result = dns_rdata_totext(rdata, NULL, b);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
isc_buffer_free(&b);
|
||||
|
||||
+1
-3
@@ -221,9 +221,7 @@ printrdata(dns_rdata_t *rdata) {
|
||||
printf("rdata_%d = ", rdata->type);
|
||||
|
||||
while (!done) {
|
||||
result = isc_buffer_allocate(mctx, &b, size);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
isc_buffer_allocate(mctx, &b, size);
|
||||
result = dns_rdata_totext(rdata, NULL, b);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
printf("%.*s\n", (int)isc_buffer_usedlength(b),
|
||||
|
||||
@@ -370,8 +370,7 @@ formatset(dns_rdataset_t *rdataset) {
|
||||
mctx);
|
||||
check_result(result, "dns_master_stylecreate2 failed");
|
||||
|
||||
result = isc_buffer_allocate(mctx, &buf, MAX_CDS_RDATA_TEXT_SIZE);
|
||||
check_result(result, "printing DS records");
|
||||
isc_buffer_allocate(mctx, &buf, MAX_CDS_RDATA_TEXT_SIZE);
|
||||
result = dns_master_rdatasettotext(name, rdataset, style, NULL, buf);
|
||||
|
||||
if ((result == ISC_R_SUCCESS) && isc_buffer_availablelength(buf) < 1) {
|
||||
@@ -834,8 +833,7 @@ 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)");
|
||||
|
||||
result = isc_buffer_allocate(mctx, &new_ds_buf, size);
|
||||
check_result(result, "building new DS records");
|
||||
isc_buffer_allocate(mctx, &new_ds_buf, size);
|
||||
|
||||
for (result = dns_rdataset_first(rdset);
|
||||
result == ISC_R_SUCCESS;
|
||||
|
||||
@@ -226,8 +226,7 @@ dumpnode(dns_name_t *name, dns_dbnode_t *node) {
|
||||
|
||||
dns_rdataset_init(&rds);
|
||||
|
||||
result = isc_buffer_allocate(mctx, &buffer, bufsize);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
isc_buffer_allocate(mctx, &buffer, bufsize);
|
||||
|
||||
for (result = dns_rdatasetiter_first(iter);
|
||||
result == ISC_R_SUCCESS;
|
||||
@@ -253,8 +252,7 @@ dumpnode(dns_name_t *name, dns_dbnode_t *node) {
|
||||
|
||||
bufsize <<= 1;
|
||||
isc_buffer_free(&buffer);
|
||||
result = isc_buffer_allocate(mctx, &buffer, bufsize);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
isc_buffer_allocate(mctx, &buffer, bufsize);
|
||||
}
|
||||
check_result(result, "dns_master_rdatasettotext");
|
||||
|
||||
|
||||
@@ -445,9 +445,7 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
|
||||
goto cleanup_request;
|
||||
}
|
||||
|
||||
result = isc_buffer_allocate(listener->mctx, &text, 2 * 2048);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_request;
|
||||
isc_buffer_allocate(listener->mctx, &text, 2 * 2048);
|
||||
|
||||
/*
|
||||
* Establish nonce.
|
||||
@@ -493,10 +491,7 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
|
||||
goto cleanup_response;
|
||||
|
||||
if (conn->buffer == NULL) {
|
||||
result = isc_buffer_allocate(listener->mctx,
|
||||
&conn->buffer, 2 * 2048);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_response;
|
||||
isc_buffer_allocate(listener->mctx, &conn->buffer, 2 * 2048);
|
||||
}
|
||||
|
||||
isc_buffer_clear(conn->buffer);
|
||||
|
||||
+8
-26
@@ -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,9 +7694,7 @@ data_to_cfg(dns_view_t *view, MDB_val *key, MDB_val *data,
|
||||
REQUIRE(zoneconfig != NULL && *zoneconfig == NULL);
|
||||
|
||||
if (*text == NULL) {
|
||||
result = isc_buffer_allocate(view->mctx, text, 256);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_buffer_allocate(view->mctx, text, 256);
|
||||
} else {
|
||||
isc_buffer_clear(*text);
|
||||
}
|
||||
@@ -9546,7 +9544,7 @@ run_server(isc_task_t *task, isc_event_t *event) {
|
||||
named_g_nm,
|
||||
named_g_dispatchmgr,
|
||||
server->task, named_g_udpdisp, geoip,
|
||||
&server->interfacemgr),
|
||||
named_g_cpus, &server->interfacemgr),
|
||||
"creating interface manager");
|
||||
|
||||
CHECKFATAL(isc_timer_create(named_g_timermgr, isc_timertype_inactive,
|
||||
@@ -10067,8 +10065,7 @@ named_add_reserved_dispatch(named_server_t *server,
|
||||
return;
|
||||
|
||||
cleanup:
|
||||
if (dispatch != NULL)
|
||||
isc_mem_put(server->mctx, dispatch, sizeof(*dispatch));
|
||||
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,
|
||||
@@ -11030,8 +11027,7 @@ named_server_dumpdb(named_server_t *server, isc_lex_t *lex,
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
if (dctx != NULL)
|
||||
dumpcontext_destroy(dctx);
|
||||
dumpcontext_destroy(dctx);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -12394,17 +12390,7 @@ nzd_save(MDB_txn **txnp, MDB_dbi dbi, dns_zone_t *zone,
|
||||
/* We're creating or overwriting the zone */
|
||||
const cfg_obj_t *zoptions;
|
||||
|
||||
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;
|
||||
}
|
||||
isc_buffer_allocate(view->mctx, &text, 256);
|
||||
|
||||
zoptions = cfg_tuple_get(zconfig, "options");
|
||||
if (zoptions == NULL) {
|
||||
@@ -12429,7 +12415,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(result));
|
||||
isc_result_totext(dzarg.result));
|
||||
result = dzarg.result;
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -12761,7 +12747,7 @@ migrate_nzf(dns_view_t *view) {
|
||||
|
||||
CHECK(nzd_open(view, 0, &txn, &dbi));
|
||||
|
||||
CHECK(isc_buffer_allocate(view->mctx, &text, 256));
|
||||
isc_buffer_allocate(view->mctx, &text, 256);
|
||||
|
||||
for (element = cfg_list_first(zonelist);
|
||||
element != NULL;
|
||||
@@ -13847,10 +13833,6 @@ 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);
|
||||
}
|
||||
|
||||
@@ -1238,8 +1238,7 @@ parse_name(char **cmdlinep, dns_message_t *msg, dns_name_t **namep) {
|
||||
|
||||
result = dns_message_gettempname(msg, namep);
|
||||
check_result(result, "dns_message_gettempname");
|
||||
result = isc_buffer_allocate(gmctx, &namebuf, DNS_NAME_MAXWIRE);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
isc_buffer_allocate(gmctx, &namebuf, DNS_NAME_MAXWIRE);
|
||||
dns_name_init(*namep, NULL);
|
||||
dns_name_setbuffer(*namep, namebuf);
|
||||
dns_message_takebuffer(msg, &namebuf);
|
||||
@@ -1284,16 +1283,14 @@ 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");
|
||||
result = isc_buffer_allocate(gmctx, &buf, MAXWIRE);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
isc_buffer_allocate(gmctx, &buf, MAXWIRE);
|
||||
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);
|
||||
result = isc_buffer_allocate(gmctx, &newbuf, r.length);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
isc_buffer_allocate(gmctx, &newbuf, r.length);
|
||||
isc_buffer_putmem(newbuf, r.base, r.length);
|
||||
isc_buffer_usedregion(newbuf, &r);
|
||||
dns_rdata_fromregion(rdata, rdataclass, rdatatype, &r);
|
||||
@@ -2041,8 +2038,7 @@ show_message(FILE *stream, dns_message_t *msg, const char *description) {
|
||||
}
|
||||
if (buf != NULL)
|
||||
isc_buffer_free(&buf);
|
||||
result = isc_buffer_allocate(gmctx, &buf, bufsz);
|
||||
check_result(result, "isc_buffer_allocate");
|
||||
isc_buffer_allocate(gmctx, &buf, bufsz);
|
||||
result = dns_message_totext(msg, style, 0, buf);
|
||||
bufsz *= 2;
|
||||
} while (result == ISC_R_NOSPACE);
|
||||
|
||||
@@ -374,8 +374,8 @@ plugin_register(const char *parameters,
|
||||
cfg_line, mctx, lctx, actx));
|
||||
}
|
||||
|
||||
CHECK(isc_mempool_create(mctx, sizeof(filter_data_t),
|
||||
&inst->datapool));
|
||||
isc_mempool_create(mctx, sizeof(filter_data_t),
|
||||
&inst->datapool);
|
||||
CHECK(isc_ht_init(&inst->ht, mctx, 16));
|
||||
isc_mutex_init(&inst->hlock);
|
||||
|
||||
|
||||
+1
-2
@@ -965,8 +965,7 @@ main(int argc, char **argv) {
|
||||
|
||||
command = *argv;
|
||||
|
||||
DO("allocate data buffer",
|
||||
isc_buffer_allocate(rndc_mctx, &databuf, 2048));
|
||||
isc_buffer_allocate(rndc_mctx, &databuf, 2048);
|
||||
|
||||
/*
|
||||
* Convert argc/argv into a space-delimited command string
|
||||
|
||||
@@ -297,8 +297,8 @@ main(int argc, char **argv) {
|
||||
isc_mem_create(&mctx);
|
||||
|
||||
cmp = NULL;
|
||||
RUNTIME_CHECK(isc_mempool_create(mctx, sizeof(client_t), &cmp)
|
||||
== ISC_R_SUCCESS);
|
||||
isc_mempool_create(mctx, sizeof(client_t), &cmp)
|
||||
;
|
||||
isc_mempool_setname(cmp, "adb test clients");
|
||||
|
||||
result = isc_log_create(mctx, &lctx, &lcfg);
|
||||
|
||||
@@ -34,10 +34,10 @@ main(int argc, char *argv[]) {
|
||||
isc_mem_create(&mctx);
|
||||
|
||||
mp1 = NULL;
|
||||
RUNTIME_CHECK(isc_mempool_create(mctx, 24, &mp1) == ISC_R_SUCCESS);
|
||||
isc_mempool_create(mctx, 24, &mp1);
|
||||
|
||||
mp2 = NULL;
|
||||
RUNTIME_CHECK(isc_mempool_create(mctx, 31, &mp2) == ISC_R_SUCCESS);
|
||||
isc_mempool_create(mctx, 31, &mp2);
|
||||
|
||||
isc_mempool_associatelock(mp1, &lock);
|
||||
isc_mempool_associatelock(mp2, &lock);
|
||||
|
||||
+109
-81
@@ -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,96 +759,127 @@ if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||
status=$((status+ret))
|
||||
|
||||
##########################################################################
|
||||
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))
|
||||
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}"
|
||||
|
||||
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))
|
||||
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 "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 "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))
|
||||
|
||||
nextpart ns2/named.run >/dev/null
|
||||
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))
|
||||
|
||||
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
|
||||
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
|
||||
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 '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 "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 "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 ${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 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 "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 "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
|
||||
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
|
||||
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 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 "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 "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 ${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 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))
|
||||
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
|
||||
|
||||
##########################################################################
|
||||
echo_i "Testing adding a domain and a subdomain of it"
|
||||
@@ -954,8 +985,6 @@ 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
|
||||
@@ -1013,7 +1042,6 @@ 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))
|
||||
|
||||
@@ -95,6 +95,8 @@ else
|
||||
COLOR_WARN=''
|
||||
fi
|
||||
|
||||
SYSTESTDIR="`basename $PWD`"
|
||||
|
||||
if type printf > /dev/null 2>&1
|
||||
then
|
||||
echofail () {
|
||||
@@ -115,6 +117,23 @@ 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 "$*"
|
||||
@@ -134,36 +153,34 @@ 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
|
||||
|
||||
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
|
||||
while read -r __LINE ; do
|
||||
echoinfo "I:$SYSTESTDIR:$__LINE"
|
||||
done
|
||||
}
|
||||
|
||||
echo_d() {
|
||||
echo "$@" | while read __LINE ; do
|
||||
echoinfo "D:$SYSTESTDIR:$__LINE"
|
||||
done
|
||||
}
|
||||
|
||||
cat_d() {
|
||||
while read __LINE ; do
|
||||
while read -r __LINE ; do
|
||||
echoinfo "D:$SYSTESTDIR:$__LINE"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -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.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/dnskey-unsupported.example.db
|
||||
rm -f ./ns3/dnskey-unsupported.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,6 +80,7 @@ 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
|
||||
@@ -89,6 +90,7 @@ 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
|
||||
|
||||
@@ -238,6 +238,7 @@ 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
|
||||
@@ -281,6 +282,7 @@ 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
|
||||
|
||||
@@ -3317,6 +3317,24 @@ 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
|
||||
(
|
||||
@@ -3342,6 +3360,7 @@ 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"
|
||||
@@ -3356,12 +3375,38 @@ 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
|
||||
@@ -3497,6 +3542,24 @@ 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
|
||||
@@ -3530,6 +3593,7 @@ 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"
|
||||
@@ -3541,12 +3605,38 @@ 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
|
||||
|
||||
@@ -120,8 +120,7 @@ dyndb_init(isc_mem_t *mctx, const char *name, const char *parameters,
|
||||
*instp = sample_inst;
|
||||
|
||||
cleanup:
|
||||
if (s != NULL)
|
||||
isc_mem_free(mctx, s);
|
||||
isc_mem_free(mctx, s);
|
||||
if (argv != NULL)
|
||||
isc_mem_put(mctx, argv, argc * sizeof(*argv));
|
||||
|
||||
|
||||
@@ -107,6 +107,16 @@ 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.
|
||||
*/
|
||||
|
||||
@@ -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 \
|
||||
rsasha1-nsec3 rsasha256 rsasha512 ecdsa256 ecdsa384 inherit
|
||||
rumoured rsasha1-nsec3 rsasha256 rsasha512 ecdsa256 ecdsa384 inherit
|
||||
do
|
||||
setup "${zn}.kasp"
|
||||
cp template.db.in "$zonefile"
|
||||
@@ -72,6 +72,16 @@ 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.
|
||||
#
|
||||
|
||||
@@ -855,7 +855,7 @@ check_signatures() {
|
||||
response_has_cds_for_key() (
|
||||
awk -v zone="${ZONE%%.}." \
|
||||
-v ttl="${DNSKEY_TTL}" \
|
||||
-v qtype="${_qtype}" \
|
||||
-v qtype="CDS" \
|
||||
-v keyid="$(key_get "${1}" ID)" \
|
||||
-v keyalg="${_key_algnum}" \
|
||||
-v hashalg="2" \
|
||||
@@ -865,37 +865,70 @@ 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 ${_qtype} rrset is signed correctly for zone ${ZONE} ($n)"
|
||||
echo_i "check CDS and CDNSKEY rrset are signed correctly for zone ${ZONE} ($n)"
|
||||
ret=0
|
||||
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"
|
||||
|
||||
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"
|
||||
|
||||
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" || log_error "missing ${_qtype} record in response for key $(key_get KEY1 ID)"
|
||||
check_signatures $_qtype "dig.out.$DIR.test$n" "KSK"
|
||||
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"
|
||||
elif [ "$(key_get KEY1 EXPECT)" = "yes" ]; then
|
||||
response_has_cds_for_key KEY1 "dig.out.$DIR.test$n" && log_error "unexpected ${_qtype} record in response for key $(key_get KEY1 ID)"
|
||||
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.
|
||||
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" || log_error "missing ${_qtype} record in response for key $(key_get KEY2 ID)"
|
||||
check_signatures $_qtype "dig.out.$DIR.test$n" "KSK"
|
||||
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"
|
||||
elif [ "$(key_get KEY2 EXPECT)" = "yes" ]; then
|
||||
response_has_cds_for_key KEY2 "dig.out.$DIR.test$n" && log_error "unexpected ${_qtype} record in response for key $(key_get KEY2 ID)"
|
||||
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.
|
||||
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" || log_error "missing ${_qtype} record in response for key $(key_get KEY3 ID)"
|
||||
check_signatures $_qtype "dig.out.$DIR.test$n" "KSK"
|
||||
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"
|
||||
elif [ "$(key_get KEY3 EXPECT)" = "yes" ]; then
|
||||
response_has_cds_for_key KEY3 "dig.out.$DIR.test$n" && log_error "unexpected ${_qtype} record in response for key $(key_get KEY3 ID)"
|
||||
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.
|
||||
fi
|
||||
|
||||
test "$ret" -eq 0 || echo_i "failed"
|
||||
@@ -957,7 +990,7 @@ check_apex() {
|
||||
test "$ret" -eq 0 || echo_i "failed"
|
||||
status=$((status+ret))
|
||||
|
||||
# Test CDS publication.
|
||||
# Test CDS and CDNSKEY publication.
|
||||
check_cds
|
||||
}
|
||||
|
||||
@@ -1056,6 +1089,17 @@ 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.
|
||||
#
|
||||
|
||||
@@ -45,9 +45,10 @@ my $A = "ns.example 300 IN A $localaddr";
|
||||
#
|
||||
# Records to be TTL stretched
|
||||
#
|
||||
my $TXT = "data.example 1 IN TXT \"A text record with a 1 second ttl\"";
|
||||
my $TXT = "data.example 2 IN TXT \"A text record with a 2 second ttl\"";
|
||||
my $LONGTXT = "longttl.example 600 IN TXT \"A text record with a 600 second ttl\"";
|
||||
my $negSOA = "example 1 IN SOA . . 0 0 0 0 300";
|
||||
my $CAA = "othertype.example 2 IN CAA 0 issue \"ca1.example.net\"";
|
||||
my $negSOA = "example 2 IN SOA . . 0 0 0 0 300";
|
||||
|
||||
sub reply_handler {
|
||||
my ($qname, $qclass, $qtype) = @_;
|
||||
@@ -129,6 +130,15 @@ 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 35;
|
||||
max-stale-ttl 45;
|
||||
stale-answer-ttl 3;
|
||||
stale-answer-enable yes;
|
||||
};
|
||||
|
||||
@@ -30,6 +30,7 @@ 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.
|
||||
@@ -54,6 +55,15 @@ 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
|
||||
@@ -82,6 +92,7 @@ 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
|
||||
@@ -97,7 +108,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 1
|
||||
sleep 2
|
||||
|
||||
n=`expr $n + 1`
|
||||
echo_i "check 'rndc serve-stale status' ($n)"
|
||||
@@ -113,19 +124,29 @@ 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 1 second ttl" 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
|
||||
# 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 1 second ttl" > /dev/null 2>&1 || ret=1
|
||||
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
|
||||
# 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
|
||||
@@ -158,6 +179,7 @@ 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
|
||||
@@ -189,6 +211,14 @@ 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
|
||||
@@ -226,7 +256,17 @@ 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 1 second ttl" 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
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -273,6 +313,14 @@ 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
|
||||
@@ -310,7 +358,17 @@ 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 1 second ttl" 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
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -362,7 +420,17 @@ 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 1 second ttl" 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
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -425,7 +493,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=35)' rndc.out.test$n > /dev/null || ret=1
|
||||
grep '_default: off (rndc) (stale-answer-ttl=3 max-stale-ttl=45)' rndc.out.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -444,7 +512,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=35)' rndc.out.test$n > /dev/null || ret=1
|
||||
grep '_default: on (rndc) (stale-answer-ttl=3 max-stale-ttl=45)' rndc.out.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -457,7 +525,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 1
|
||||
sleep 2
|
||||
|
||||
n=`expr $n + 1`
|
||||
echo_i "prime cache longttl.example (low max-stale-ttl) ($n)"
|
||||
@@ -477,6 +545,15 @@ 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
|
||||
@@ -506,6 +583,7 @@ 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`
|
||||
@@ -520,7 +598,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 1
|
||||
sleep 2
|
||||
|
||||
n=`expr $n + 1`
|
||||
echo_i "check stale data.example (low max-stale-ttl) ($n)"
|
||||
@@ -528,7 +606,17 @@ 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 1 second ttl" 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
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -565,12 +653,14 @@ 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 1
|
||||
sleep 2
|
||||
|
||||
n=`expr $n + 1`
|
||||
echo_i "check ancient data.example (low max-stale-ttl) ($n)"
|
||||
@@ -581,6 +671,15 @@ 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
|
||||
@@ -628,7 +727,17 @@ 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 1 second ttl" 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
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -638,7 +747,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\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
|
||||
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -648,7 +757,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\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
|
||||
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -663,6 +772,7 @@ 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`
|
||||
@@ -677,7 +787,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 1
|
||||
sleep 2
|
||||
|
||||
n=`expr $n + 1`
|
||||
echo_i "check 'rndc serve-stale status' ($n)"
|
||||
@@ -696,6 +806,15 @@ 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
|
||||
@@ -727,8 +846,10 @@ 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
|
||||
|
||||
@@ -753,7 +874,17 @@ 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 1 second ttl" 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
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -806,7 +937,17 @@ 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\..*1.*IN.*TXT.*A text record with a 1 second ttl" 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
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -816,7 +957,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\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
|
||||
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -826,7 +967,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\..*1.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
|
||||
grep "example\..*2.*IN.*SOA" dig.out.test$n > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
@@ -841,6 +982,7 @@ 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`
|
||||
@@ -855,7 +997,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 1
|
||||
sleep 2
|
||||
|
||||
n=`expr $n + 1`
|
||||
echo_i "check 'rndc serve-stale status' ($n)"
|
||||
@@ -874,6 +1016,15 @@ 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
|
||||
@@ -905,6 +1056,7 @@ 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`
|
||||
@@ -947,7 +1099,7 @@ status=`expr $status + $ret`
|
||||
echo_i "start ns4"
|
||||
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} serve-stale ns4
|
||||
|
||||
sleep 1
|
||||
sleep 2
|
||||
|
||||
n=`expr $n + 1`
|
||||
echo_i "verify ancient cache statistics (serve-stale disabled) ($n)"
|
||||
@@ -960,6 +1112,7 @@ 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`
|
||||
|
||||
@@ -175,8 +175,7 @@ main(int argc, char *argv[]) {
|
||||
} else
|
||||
f = stdin;
|
||||
|
||||
result = isc_buffer_allocate(mctx, &input, 64 * 1024);
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
isc_buffer_allocate(mctx, &input, 64 * 1024);
|
||||
|
||||
if (rawdata) {
|
||||
while (fread(&c, 1, 1, f) != 0) {
|
||||
|
||||
+3
-7
@@ -309,8 +309,7 @@ recvresponse(isc_task_t *task, isc_event_t *event) {
|
||||
if (!display_comments)
|
||||
flags |= DNS_MESSAGETEXTFLAG_NOCOMMENTS;
|
||||
|
||||
result = isc_buffer_allocate(mctx, &buf, len);
|
||||
CHECK("isc_buffer_allocate", result);
|
||||
isc_buffer_allocate(mctx, &buf, len);
|
||||
|
||||
if (yaml) {
|
||||
char sockstr[ISC_SOCKADDR_FORMATSIZE];
|
||||
@@ -416,11 +415,8 @@ repopulate_buffer:
|
||||
buftoosmall:
|
||||
len += OUTPUTBUF;
|
||||
isc_buffer_free(&buf);
|
||||
result = isc_buffer_allocate(mctx, &buf, len);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
goto repopulate_buffer;
|
||||
else
|
||||
goto cleanup;
|
||||
isc_buffer_allocate(mctx, &buf, len);
|
||||
goto repopulate_buffer;
|
||||
}
|
||||
CHECK("dns_message_pseudosectiontotext", result);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
@@
|
||||
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);
|
||||
@@ -0,0 +1,49 @@
|
||||
@@
|
||||
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
|
||||
+ ;
|
||||
@@ -852,6 +852,7 @@ infodir
|
||||
docdir
|
||||
oldincludedir
|
||||
includedir
|
||||
runstatedir
|
||||
localstatedir
|
||||
sharedstatedir
|
||||
sysconfdir
|
||||
@@ -1025,6 +1026,7 @@ 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}'
|
||||
@@ -1277,6 +1279,15 @@ 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=* \
|
||||
@@ -1414,7 +1425,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
|
||||
libdir localedir mandir runstatedir
|
||||
do
|
||||
eval ac_val=\$$ac_var
|
||||
# Remove trailing slashes.
|
||||
@@ -1567,6 +1578,7 @@ 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]
|
||||
@@ -4011,7 +4023,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 << 62) - 1 + ((off_t) 1 << 62))
|
||||
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||
&& LARGE_OFF_T % 2147483647 == 1)
|
||||
? 1 : -1];
|
||||
@@ -4057,7 +4069,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 << 62) - 1 + ((off_t) 1 << 62))
|
||||
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||
&& LARGE_OFF_T % 2147483647 == 1)
|
||||
? 1 : -1];
|
||||
@@ -4081,7 +4093,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 << 62) - 1 + ((off_t) 1 << 62))
|
||||
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||
&& LARGE_OFF_T % 2147483647 == 1)
|
||||
? 1 : -1];
|
||||
@@ -4126,7 +4138,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 << 62) - 1 + ((off_t) 1 << 62))
|
||||
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||
&& LARGE_OFF_T % 2147483647 == 1)
|
||||
? 1 : -1];
|
||||
@@ -4150,7 +4162,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 << 62) - 1 + ((off_t) 1 << 62))
|
||||
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||
&& LARGE_OFF_T % 2147483647 == 1)
|
||||
? 1 : -1];
|
||||
@@ -16046,7 +16058,7 @@ esac
|
||||
if test "${enable_pthread_rwlock+set}" = set; then :
|
||||
enableval=$enable_pthread_rwlock;
|
||||
else
|
||||
enable_pthread_rwlock=no
|
||||
enable_pthread_rwlock=yes
|
||||
fi
|
||||
|
||||
|
||||
@@ -16070,10 +16082,6 @@ $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
|
||||
|
||||
#
|
||||
|
||||
+1
-4
@@ -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=no])
|
||||
[], [enable_pthread_rwlock=yes])
|
||||
|
||||
AS_IF([test "$enable_pthread_rwlock" = "yes"],
|
||||
[AC_CHECK_FUNCS([pthread_rwlock_rdlock], [],
|
||||
@@ -729,9 +729,6 @@ 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
|
||||
|
||||
#
|
||||
|
||||
@@ -157,7 +157,7 @@ is_safe(const char *input) {
|
||||
return (true);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
static void
|
||||
create_path_helper(char *out, const char *in, config_data_t *cd) {
|
||||
char *tmpString;
|
||||
char *tmpPtr;
|
||||
@@ -206,7 +206,6 @@ create_path_helper(char *out, const char *in, config_data_t *cd) {
|
||||
}
|
||||
|
||||
isc_mem_free(named_g_mctx, tmpString);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
/*%
|
||||
@@ -223,7 +222,6 @@ 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 */
|
||||
@@ -285,9 +283,7 @@ create_path(const char *zone, const char *host, const char *client,
|
||||
|
||||
/* add zone name - parsed properly */
|
||||
if (!isroot) {
|
||||
result = create_path_helper(tmpPath, zone, cd);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_mem;
|
||||
create_path_helper(tmpPath, zone, cd);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -322,26 +318,13 @@ 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);
|
||||
if ((result = create_path_helper(tmpPath, host,
|
||||
cd)) != ISC_R_SUCCESS)
|
||||
goto cleanup_mem;
|
||||
create_path_helper(tmpPath, host, cd);
|
||||
}
|
||||
|
||||
/* return the path we built. */
|
||||
*path = tmpPath;
|
||||
|
||||
/* 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);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
@@ -705,19 +688,18 @@ fs_allnodes(const char *zone, void *driverarg, void *dbdata,
|
||||
} /* end while */
|
||||
|
||||
complete_allnds:
|
||||
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));
|
||||
}
|
||||
/* 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)
|
||||
if (basepath != NULL) {
|
||||
isc_mem_free(named_g_mctx, basepath);
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -254,8 +254,7 @@ build_querylist(isc_mem_t *mctx, const char *query_str, char **zone,
|
||||
|
||||
flag_fail:
|
||||
/* get rid of what was build of the query list */
|
||||
if (tql != NULL)
|
||||
destroy_querylist(mctx, &tql);
|
||||
destroy_querylist(mctx, &tql);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/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())
|
||||
@@ -6866,9 +6866,11 @@ options {
|
||||
<term><command>forwarders</command></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the IP addresses to be used
|
||||
for forwarding. The default is the empty list (no
|
||||
forwarding).
|
||||
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.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
||||
target = target ? target + 1 : argv[0];
|
||||
target = (target != NULL) ? target + 1 : argv[0];
|
||||
if (strncmp(target, "lt-", 3) == 0) {
|
||||
target += 3;
|
||||
}
|
||||
|
||||
+1
-3
@@ -2646,9 +2646,7 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
|
||||
* Memory pools
|
||||
*/
|
||||
#define MPINIT(t, p, n) do { \
|
||||
result = isc_mempool_create(mem, sizeof(t), &(p)); \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
goto fail2; \
|
||||
isc_mempool_create(mem, sizeof(t), &(p)); \
|
||||
isc_mempool_setfreemax((p), FREE_ITEMS); \
|
||||
isc_mempool_setfillcount((p), FILL_COUNT); \
|
||||
isc_mempool_setname((p), n); \
|
||||
|
||||
+40
-29
@@ -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,10 +1239,8 @@ 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);
|
||||
result = isc_buffer_allocate(zone->catzs->mctx, &aclb, 16);
|
||||
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)) {
|
||||
@@ -1457,39 +1455,52 @@ 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);
|
||||
|
||||
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_allocate(zone->catzs->mctx, &tbuf,
|
||||
strlen(zone->catzs->view->name) + 2 *
|
||||
DNS_NAME_FORMATSIZE + 2);
|
||||
|
||||
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);
|
||||
@@ -1498,9 +1509,10 @@ 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 (tbuf->used > ISC_SHA256_DIGESTLENGTH * 2 + 1) {
|
||||
if (special || 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);
|
||||
@@ -1531,7 +1543,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; };
|
||||
* }
|
||||
@@ -1552,16 +1564,12 @@ 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.
|
||||
*/
|
||||
result = isc_buffer_allocate(zone->catzs->mctx, &buffer,
|
||||
ISC_BUFFER_INCR);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
isc_buffer_allocate(zone->catzs->mctx, &buffer, ISC_BUFFER_INCR);
|
||||
|
||||
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
|
||||
@@ -1569,7 +1577,8 @@ 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]);
|
||||
@@ -1611,8 +1620,9 @@ 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, "; ");
|
||||
}
|
||||
@@ -1620,8 +1630,9 @@ 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, "\"; ");
|
||||
|
||||
}
|
||||
@@ -1640,11 +1651,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:
|
||||
if (buffer != NULL)
|
||||
isc_buffer_free(&buffer);
|
||||
isc_buffer_free(&buffer);
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
+12
-37
@@ -1340,13 +1340,7 @@ dns_client_startresolve(dns_client_t *client, const dns_name_t *name,
|
||||
ISC_LIST_INIT(event->answerlist);
|
||||
|
||||
rctx = isc_mem_get(mctx, sizeof(*rctx));
|
||||
if (rctx == NULL)
|
||||
result = ISC_R_NOMEMORY;
|
||||
else {
|
||||
isc_mutex_init(&rctx->lock);
|
||||
}
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_mutex_init(&rctx->lock);
|
||||
|
||||
result = getrdataset(mctx, &rdataset);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
@@ -1399,8 +1393,7 @@ dns_client_startresolve(dns_client_t *client, const dns_name_t *name,
|
||||
isc_mutex_destroy(&rctx->lock);
|
||||
isc_mem_put(mctx, rctx, sizeof(*rctx));
|
||||
}
|
||||
if (event != NULL)
|
||||
isc_event_free(ISC_EVENT_PTR(&event));
|
||||
isc_event_free(ISC_EVENT_PTR(&event));
|
||||
isc_task_detach(&tclone);
|
||||
dns_view_detach(&view);
|
||||
|
||||
@@ -1495,7 +1488,6 @@ 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];
|
||||
@@ -1540,9 +1532,6 @@ 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);
|
||||
}
|
||||
@@ -1748,13 +1737,7 @@ dns_client_startrequest(dns_client_t *client, dns_message_t *qmessage,
|
||||
action, arg, sizeof(*event));
|
||||
|
||||
ctx = isc_mem_get(client->mctx, sizeof(*ctx));
|
||||
if (ctx == NULL)
|
||||
result = ISC_R_NOMEMORY;
|
||||
else {
|
||||
isc_mutex_init(&ctx->lock);
|
||||
}
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_mutex_init(&ctx->lock);
|
||||
|
||||
ctx->client = client;
|
||||
ISC_LINK_INIT(ctx, link);
|
||||
@@ -1787,16 +1770,13 @@ dns_client_startrequest(dns_client_t *client, dns_message_t *qmessage,
|
||||
|
||||
isc_refcount_decrement(&client->references);
|
||||
|
||||
cleanup:
|
||||
if (ctx != NULL) {
|
||||
LOCK(&client->lock);
|
||||
ISC_LIST_UNLINK(client->reqctxs, ctx, link);
|
||||
UNLOCK(&client->lock);
|
||||
isc_mutex_destroy(&ctx->lock);
|
||||
isc_mem_put(client->mctx, ctx, sizeof(*ctx));
|
||||
}
|
||||
if (event != NULL)
|
||||
isc_event_free(ISC_EVENT_PTR(&event));
|
||||
LOCK(&client->lock);
|
||||
ISC_LIST_UNLINK(client->reqctxs, ctx, link);
|
||||
UNLOCK(&client->lock);
|
||||
isc_mutex_destroy(&ctx->lock);
|
||||
isc_mem_put(client->mctx, ctx, sizeof(*ctx));
|
||||
|
||||
isc_event_free(ISC_EVENT_PTR(&event));
|
||||
isc_task_detach(&tclone);
|
||||
dns_view_detach(&view);
|
||||
|
||||
@@ -2556,9 +2536,7 @@ 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);
|
||||
result = isc_buffer_allocate(mctx, &namebuf, DNS_NAME_MAXWIRE);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto fail;
|
||||
isc_buffer_allocate(mctx, &namebuf, DNS_NAME_MAXWIRE);
|
||||
dns_name_init(newname, NULL);
|
||||
dns_name_setbuffer(newname, namebuf);
|
||||
dns_message_takebuffer(msg, &namebuf);
|
||||
@@ -2587,10 +2565,7 @@ copy_name(isc_mem_t *mctx, dns_message_t *msg, const dns_name_t *name,
|
||||
goto fail;
|
||||
dns_rdata_toregion(&rdata, &r);
|
||||
rdatabuf = NULL;
|
||||
result = isc_buffer_allocate(mctx, &rdatabuf,
|
||||
r.length);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto fail;
|
||||
isc_buffer_allocate(mctx, &rdatabuf, r.length);
|
||||
isc_buffer_putmem(rdatabuf, r.base, r.length);
|
||||
isc_buffer_usedregion(rdatabuf, &r);
|
||||
dns_rdata_init(newrdata);
|
||||
|
||||
+11
-41
@@ -1762,25 +1762,16 @@ dns_dispatchmgr_create(isc_mem_t *mctx, dns_dispatchmgr_t **mgrp)
|
||||
isc_mutex_init(&mgr->spool_lock);
|
||||
|
||||
mgr->depool = NULL;
|
||||
if (isc_mempool_create(mgr->mctx, sizeof(dns_dispatchevent_t),
|
||||
&mgr->depool) != ISC_R_SUCCESS) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto kill_locks;
|
||||
}
|
||||
isc_mempool_create(mgr->mctx, sizeof(dns_dispatchevent_t),
|
||||
&mgr->depool);
|
||||
|
||||
mgr->rpool = NULL;
|
||||
if (isc_mempool_create(mgr->mctx, sizeof(dns_dispentry_t),
|
||||
&mgr->rpool) != ISC_R_SUCCESS) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto kill_depool;
|
||||
}
|
||||
isc_mempool_create(mgr->mctx, sizeof(dns_dispentry_t),
|
||||
&mgr->rpool);
|
||||
|
||||
mgr->dpool = NULL;
|
||||
if (isc_mempool_create(mgr->mctx, sizeof(dns_dispatch_t),
|
||||
&mgr->dpool) != ISC_R_SUCCESS) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto kill_rpool;
|
||||
}
|
||||
isc_mempool_create(mgr->mctx, sizeof(dns_dispatch_t),
|
||||
&mgr->dpool);
|
||||
|
||||
isc_mempool_setname(mgr->depool, "dispmgr_depool");
|
||||
isc_mempool_setmaxalloc(mgr->depool, 32768);
|
||||
@@ -1835,11 +1826,8 @@ 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);
|
||||
@@ -1986,11 +1974,7 @@ dns_dispatchmgr_setudp(dns_dispatchmgr_t *mgr,
|
||||
mgr->maxbuffers = maxbuffers;
|
||||
}
|
||||
} else {
|
||||
result = isc_mempool_create(mgr->mctx, buffersize, &mgr->bpool);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNLOCK(&mgr->buffer_lock);
|
||||
return (result);
|
||||
}
|
||||
isc_mempool_create(mgr->mctx, buffersize, &mgr->bpool);
|
||||
isc_mempool_setname(mgr->bpool, "dispmgr_bpool");
|
||||
isc_mempool_setmaxalloc(mgr->bpool, maxbuffers);
|
||||
isc_mempool_setfreemax(mgr->bpool, maxbuffers);
|
||||
@@ -2009,10 +1993,8 @@ dns_dispatchmgr_setudp(dns_dispatchmgr_t *mgr,
|
||||
UNLOCK(&mgr->buffer_lock);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
result = isc_mempool_create(mgr->mctx, sizeof(dispsocket_t),
|
||||
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);
|
||||
@@ -2857,11 +2839,8 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
ISC_LIST_INIT(disp->port_table[i]);
|
||||
}
|
||||
|
||||
result = isc_mempool_create(mgr->mctx, sizeof(dispportentry_t),
|
||||
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);
|
||||
}
|
||||
@@ -2892,12 +2871,8 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
sizeof(isc_event_t));
|
||||
|
||||
disp->sepool = NULL;
|
||||
if (isc_mempool_create(mgr->mctx, sizeof(isc_socketevent_t),
|
||||
&disp->sepool) != ISC_R_SUCCESS)
|
||||
{
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto kill_ctlevent;
|
||||
}
|
||||
isc_mempool_create(mgr->mctx, sizeof(isc_socketevent_t),
|
||||
&disp->sepool);
|
||||
|
||||
isc_mutex_init(&disp->sepool_lock);
|
||||
|
||||
@@ -2929,11 +2904,6 @@ 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);
|
||||
|
||||
+3
-6
@@ -257,9 +257,7 @@ dns_dnssec_sign(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
|
||||
*/
|
||||
sig.signature = isc_mem_get(mctx, sig.siglen);
|
||||
|
||||
ret = isc_buffer_allocate(mctx, &databuf, sigsize + 256 + 18);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
goto cleanup_signature;
|
||||
isc_buffer_allocate(mctx, &databuf, sigsize + 256 + 18);
|
||||
|
||||
dns_rdata_init(&tmpsigrdata);
|
||||
ret = dns_rdata_fromstruct(&tmpsigrdata, sig.common.rdclass,
|
||||
@@ -355,7 +353,6 @@ cleanup_context:
|
||||
dst_context_destroy(&ctx);
|
||||
cleanup_databuf:
|
||||
isc_buffer_free(&databuf);
|
||||
cleanup_signature:
|
||||
isc_mem_put(mctx, sig.signature, sig.siglen);
|
||||
|
||||
return (ret);
|
||||
@@ -997,7 +994,7 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) {
|
||||
|
||||
rdata = NULL;
|
||||
RETERR(dns_message_gettemprdata(msg, &rdata));
|
||||
RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 1024));
|
||||
isc_buffer_allocate(msg->mctx, &dynbuf, 1024);
|
||||
RETERR(dns_rdata_fromstruct(rdata, dns_rdataclass_any,
|
||||
dns_rdatatype_sig /* SIG(0) */,
|
||||
&sig, dynbuf));
|
||||
@@ -1981,7 +1978,7 @@ dns_dnssec_syncupdate(dns_dnsseckeylist_t *keys, dns_dnsseckeylist_t *rmkeys,
|
||||
}
|
||||
|
||||
/*
|
||||
* Unconditionaly remove CDS/DNSKEY records for removed keys.
|
||||
* Unconditionally remove CDS/DNSKEY records for removed keys.
|
||||
*/
|
||||
for (key = ISC_LIST_HEAD(*rmkeys);
|
||||
key != NULL;
|
||||
|
||||
+24
-12
@@ -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.
|
||||
*/
|
||||
RETERR(isc_buffer_allocate(key->mctx, &key->key_tkeytoken,
|
||||
intoken->length));
|
||||
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,10 +2465,9 @@ 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)
|
||||
{
|
||||
@@ -2522,7 +2521,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
|
||||
@@ -2540,7 +2539,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
|
||||
@@ -2555,7 +2554,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);
|
||||
@@ -2579,7 +2578,20 @@ dst_key_is_removed(dst_key_t *key, isc_stdtime_t now, isc_stdtime_t *remove)
|
||||
time_ok = true;
|
||||
}
|
||||
|
||||
return state_ok && time_ok;
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+3
-13
@@ -54,18 +54,12 @@ 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;
|
||||
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);
|
||||
}
|
||||
isc_buffer_allocate(dctx->mctx, &ctx->buffer, INITIAL_BUFFER_SIZE);
|
||||
|
||||
dctx->ctxdata.gssctx = ctx;
|
||||
|
||||
@@ -107,9 +101,7 @@ gssapi_adddata(dst_context_t *dctx, const isc_region_t *data) {
|
||||
|
||||
length = isc_buffer_length(ctx->buffer) + data->length + BUFFER_EXTRA;
|
||||
|
||||
result = isc_buffer_allocate(dctx->mctx, &newbuffer, length);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(dctx->mctx, &newbuffer, length);
|
||||
|
||||
isc_buffer_usedregion(ctx->buffer, &r);
|
||||
(void)isc_buffer_copyregion(newbuffer, &r);
|
||||
@@ -276,9 +268,7 @@ gssapi_restore(dst_key_t *key, const char *keystr) {
|
||||
|
||||
len = (len / 4) * 3;
|
||||
|
||||
result = isc_buffer_allocate(key->mctx, &b, len);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(key->mctx, &b, len);
|
||||
|
||||
result = isc_base64_decodestring(keystr, b);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
||||
+2
-2
@@ -752,8 +752,8 @@ dst_gssapi_acceptctx(gss_cred_id_t cred,
|
||||
}
|
||||
|
||||
if (gouttoken.length > 0U) {
|
||||
RETERR(isc_buffer_allocate(mctx, outtoken,
|
||||
(unsigned int)gouttoken.length));
|
||||
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);
|
||||
|
||||
@@ -323,13 +323,15 @@ 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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1166,6 +1166,18 @@ 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);
|
||||
/*%<
|
||||
|
||||
@@ -126,26 +126,6 @@ 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
@@ -89,7 +89,7 @@ keymgr_keyrole(dst_key_t* key)
|
||||
return ("CSK");
|
||||
} else if (ksk) {
|
||||
return ("KSK");
|
||||
} else {
|
||||
} else if (zsk) {
|
||||
return ("ZSK");
|
||||
}
|
||||
return ("NOSIGN");
|
||||
@@ -1358,7 +1358,7 @@ dns_keymgr_run(const dns_name_t *origin, dns_rdataclass_t rdclass,
|
||||
lifetime);
|
||||
}
|
||||
|
||||
if (dst_key_is_active(dkey->key, now)) {
|
||||
if (dst_key_goal(dkey->key) == OMNIPRESENT) {
|
||||
if (active_key != NULL) {
|
||||
/*
|
||||
* Multiple signing keys match
|
||||
|
||||
+1
-3
@@ -592,9 +592,7 @@ dns_keytable_dump(dns_keytable_t *keytable, FILE *fp) {
|
||||
REQUIRE(VALID_KEYTABLE(keytable));
|
||||
REQUIRE(fp != NULL);
|
||||
|
||||
result = isc_buffer_allocate(keytable->mctx, &text, 4096);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(keytable->mctx, &text, 4096);
|
||||
|
||||
result = dns_keytable_totext(keytable, &text);
|
||||
|
||||
|
||||
@@ -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 ? *indentctx : default_indent;
|
||||
ctx->indent = *indentctx;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -1547,12 +1547,13 @@ 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);
|
||||
if (dctx != NULL)
|
||||
isc_mem_put(mctx, dctx, sizeof(*dctx));
|
||||
}
|
||||
isc_mem_put(mctx, dctx, sizeof(*dctx));
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
+8
-44
@@ -243,13 +243,10 @@ 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;
|
||||
result = isc_buffer_allocate(msg->mctx, &dynbuf, size);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (ISC_R_NOMEMORY);
|
||||
isc_buffer_allocate(msg->mctx, &dynbuf, size);
|
||||
|
||||
ISC_LIST_APPEND(msg->scratchpad, dynbuf, link);
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -702,7 +699,6 @@ 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;
|
||||
|
||||
@@ -743,49 +739,25 @@ 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)
|
||||
*/
|
||||
|
||||
result = isc_mempool_create(m->mctx, sizeof(dns_name_t), &m->namepool);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_mempool_create(m->mctx, sizeof(dns_name_t), &m->namepool);
|
||||
isc_mempool_setfillcount(m->namepool, NAME_COUNT);
|
||||
isc_mempool_setfreemax(m->namepool, NAME_COUNT);
|
||||
isc_mempool_setname(m->namepool, "msg:names");
|
||||
|
||||
result = isc_mempool_create(m->mctx, sizeof(dns_rdataset_t),
|
||||
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;
|
||||
result = isc_buffer_allocate(mctx, &dynbuf, SCRATCHPAD_SIZE);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_buffer_allocate(mctx, &dynbuf, SCRATCHPAD_SIZE);
|
||||
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
|
||||
@@ -2865,9 +2837,7 @@ dns_message_setquerytsig(dns_message_t *msg, isc_buffer_t *querytsig) {
|
||||
goto cleanup;
|
||||
|
||||
isc_buffer_usedregion(querytsig, &r);
|
||||
result = isc_buffer_allocate(msg->mctx, &buf, r.length);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_buffer_allocate(msg->mctx, &buf, r.length);
|
||||
isc_buffer_putmem(buf, r.base, r.length);
|
||||
isc_buffer_usedregion(buf, &r);
|
||||
dns_rdata_init(rdata);
|
||||
@@ -2912,9 +2882,7 @@ dns_message_getquerytsig(dns_message_t *msg, isc_mem_t *mctx,
|
||||
dns_rdataset_current(msg->tsig, &rdata);
|
||||
dns_rdata_toregion(&rdata, &r);
|
||||
|
||||
result = isc_buffer_allocate(mctx, querytsig, r.length);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(mctx, querytsig, r.length);
|
||||
isc_buffer_putmem(*querytsig, r.base, r.length);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -3033,9 +3001,7 @@ dns_message_signer(dns_message_t *msg, dns_name_t *signer) {
|
||||
|
||||
if (!dns_name_hasbuffer(signer)) {
|
||||
isc_buffer_t *dynbuf = NULL;
|
||||
result = isc_buffer_allocate(msg->mctx, &dynbuf, 512);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(msg->mctx, &dynbuf, 512);
|
||||
dns_name_setbuffer(signer, dynbuf);
|
||||
dns_message_takebuffer(msg, &dynbuf);
|
||||
}
|
||||
@@ -4479,9 +4445,7 @@ dns_message_buildopt(dns_message_t *message, dns_rdataset_t **rdatasetp,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = isc_buffer_allocate(message->mctx, &buf, len);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_buffer_allocate(message->mctx, &buf, len);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (ednsopts[i].code == DNS_OPT_PAD &&
|
||||
|
||||
+1
-3
@@ -568,9 +568,7 @@ dns_ntatable_dump(dns_ntatable_t *ntatable, FILE *fp) {
|
||||
isc_buffer_t *text = NULL;
|
||||
int len = 4096;
|
||||
|
||||
result = isc_buffer_allocate(ntatable->view->mctx, &text, len);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(ntatable->view->mctx, &text, len);
|
||||
|
||||
result = dns_ntatable_totext(ntatable, NULL, &text);
|
||||
|
||||
|
||||
@@ -273,16 +273,15 @@ 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);
|
||||
|
||||
result = isc_buffer_allocate(dctx->mctx, &buf, 64);
|
||||
isc_buffer_allocate(dctx->mctx, &buf, 64);
|
||||
dctx->ctxdata.generic = buf;
|
||||
|
||||
return (result);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -312,9 +311,7 @@ openssleddsa_adddata(dst_context_t *dctx, const isc_region_t *data) {
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
length = isc_buffer_length(buf) + data->length + 64;
|
||||
result = isc_buffer_allocate(dctx->mctx, &nbuf, length);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(dctx->mctx, &nbuf, length);
|
||||
isc_buffer_usedregion(buf, &r);
|
||||
(void) isc_buffer_copyregion(nbuf, &r);
|
||||
(void) isc_buffer_copyregion(nbuf, data);
|
||||
|
||||
@@ -108,9 +108,7 @@ pkcs11eddsa_adddata(dst_context_t *dctx, const isc_region_t *data) {
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
length = isc_buffer_length(buf) + data->length + 64;
|
||||
result = isc_buffer_allocate(dctx->mctx, &nbuf, length);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(dctx->mctx, &nbuf, length);
|
||||
isc_buffer_usedregion(buf, &r);
|
||||
(void) isc_buffer_copyregion(nbuf, &r);
|
||||
(void) isc_buffer_copyregion(nbuf, data);
|
||||
|
||||
+13
-14
@@ -172,9 +172,12 @@ typedef isc_rwlock_t nodelock_t;
|
||||
* to be 0 by default either with or without threads.
|
||||
*/
|
||||
#ifndef DNS_RBTDB_LIMITLRUUPDATE
|
||||
#define DNS_RBTDB_LIMITLRUUPDATE 0
|
||||
#define DNS_RBTDB_LIMITLRUUPDATE 1
|
||||
#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.
|
||||
@@ -309,7 +312,7 @@ typedef ISC_LIST(dns_rbtnode_t) rbtnodelist_t;
|
||||
(((header)->rdh_ttl > (now)) || \
|
||||
((header)->rdh_ttl == (now) && ZEROTTL(header)))
|
||||
|
||||
#define DEFAULT_NODE_LOCK_COUNT 7 /*%< Should be prime. */
|
||||
#define DEFAULT_NODE_LOCK_COUNT 53 /*%< Should be prime. */
|
||||
#define RBTDB_GLUE_TABLE_INIT_SIZE 2U
|
||||
|
||||
/*%
|
||||
@@ -329,7 +332,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 16
|
||||
#define DEFAULT_CACHE_NODE_LOCK_COUNT 97
|
||||
#endif /* DNS_RBTDB_CACHE_NODE_LOCK_COUNT */
|
||||
|
||||
typedef struct {
|
||||
@@ -1585,7 +1588,8 @@ 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 or stale, we can clean it up.
|
||||
* If current is nonexistent, ancient, or stale and
|
||||
* we are not keeping stale, we can clean it up.
|
||||
*/
|
||||
if (NONEXISTENT(current) || ANCIENT(current) ||
|
||||
(STALE(current) && ! KEEPSTALE(rbtdb))) {
|
||||
@@ -6367,8 +6371,7 @@ addnoqname(dns_rbtdb_t *rbtdb, rdatasetheader_t *newheader,
|
||||
cleanup:
|
||||
dns_rdataset_disassociate(&neg);
|
||||
dns_rdataset_disassociate(&negsig);
|
||||
if (noqname != NULL)
|
||||
free_noqname(mctx, &noqname);
|
||||
free_noqname(mctx, &noqname);
|
||||
return(result);
|
||||
}
|
||||
|
||||
@@ -6412,8 +6415,7 @@ addclosest(dns_rbtdb_t *rbtdb, rdatasetheader_t *newheader,
|
||||
cleanup:
|
||||
dns_rdataset_disassociate(&neg);
|
||||
dns_rdataset_disassociate(&negsig);
|
||||
if (closest != NULL)
|
||||
free_noqname(mctx, &closest);
|
||||
free_noqname(mctx, &closest);
|
||||
return(result);
|
||||
}
|
||||
|
||||
@@ -9884,10 +9886,7 @@ restart:
|
||||
dns_rdataset_t *sigrdataset_aaaa = NULL;
|
||||
dns_name_t *gluename = dns_fixedname_name(&ge->fixedname);
|
||||
|
||||
result = isc_buffer_allocate(msg->mctx, &buffer, 512);
|
||||
if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
|
||||
goto no_glue;
|
||||
}
|
||||
isc_buffer_allocate(msg->mctx, &buffer, 512);
|
||||
|
||||
result = dns_message_gettempname(msg, &name);
|
||||
if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
|
||||
@@ -10092,11 +10091,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 + 60 <= now);
|
||||
return (header->last_used + DNS_RBTDB_LRUUPDATE_GLUE <= now);
|
||||
}
|
||||
|
||||
/* Other records are updated if 5 minutes have passed. */
|
||||
return (header->last_used + 300 <= now);
|
||||
return (header->last_used + DNS_RBTDB_LRUUPDATE_REGULAR <= now);
|
||||
#else
|
||||
UNUSED(now);
|
||||
|
||||
|
||||
+1
-3
@@ -857,9 +857,7 @@ unknown_fromtext(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
||||
false));
|
||||
if (token.value.as_ulong > 65535U)
|
||||
return (ISC_R_RANGE);
|
||||
result = isc_buffer_allocate(mctx, &buf, token.value.as_ulong);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(mctx, &buf, token.value.as_ulong);
|
||||
|
||||
if (token.value.as_ulong != 0U) {
|
||||
result = isc_hex_tobuffer(lexer, buf,
|
||||
|
||||
+4
-14
@@ -780,10 +780,7 @@ dns_request_createraw(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
|
||||
sock = req_getsocket(request);
|
||||
INSIST(sock != NULL);
|
||||
|
||||
result = isc_buffer_allocate(mctx, &request->query,
|
||||
r.length + (tcp ? 2 : 0));
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_buffer_allocate(mctx, &request->query, r.length + (tcp ? 2 : 0));
|
||||
if (tcp)
|
||||
isc_buffer_putuint16(request->query, (uint16_t)r.length);
|
||||
result = isc_buffer_copyregion(request->query, &r);
|
||||
@@ -1040,9 +1037,7 @@ req_render(dns_message_t *message, isc_buffer_t **bufferp,
|
||||
/*
|
||||
* Create buffer able to hold largest possible message.
|
||||
*/
|
||||
result = isc_buffer_allocate(mctx, &buf1, 65535);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(mctx, &buf1, 65535);
|
||||
|
||||
result = dns_compress_init(&cctx, -1, mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
@@ -1087,9 +1082,7 @@ req_render(dns_message_t *message, isc_buffer_t **bufferp,
|
||||
result = DNS_R_USETCP;
|
||||
goto cleanup;
|
||||
}
|
||||
result = isc_buffer_allocate(mctx, &buf2, r.length + (tcp ? 2 : 0));
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_buffer_allocate(mctx, &buf2, r.length + (tcp ? 2 : 0));
|
||||
if (tcp)
|
||||
isc_buffer_putuint16(buf2, (uint16_t)r.length);
|
||||
result = isc_buffer_copyregion(buf2, &r);
|
||||
@@ -1348,10 +1341,7 @@ req_response(isc_task_t *task, isc_event_t *event) {
|
||||
* Copy buffer to request.
|
||||
*/
|
||||
isc_buffer_usedregion(&devent->buffer, &r);
|
||||
result = isc_buffer_allocate(request->mctx, &request->answer,
|
||||
r.length);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto done;
|
||||
isc_buffer_allocate(request->mctx, &request->answer, r.length);
|
||||
result = isc_buffer_copyregion(request->answer, &r);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
isc_buffer_free(&request->answer);
|
||||
|
||||
+9
-12
@@ -7220,19 +7220,21 @@ log_nsid(isc_buffer_t *opt, size_t nsid_len, resquery_t *query,
|
||||
{
|
||||
static const char hex[17] = "0123456789abcdef";
|
||||
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
|
||||
uint16_t buflen, i;
|
||||
size_t buflen;
|
||||
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 = (uint16_t)nsid_len * 2 + 1;
|
||||
buflen = 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 (i = 0; i < nsid_len; i++) {
|
||||
for (size_t i = 0; i < nsid_len; i++) {
|
||||
*p++ = hex[(nsid[i] >> 4) & 0xf];
|
||||
*p++ = hex[nsid[i] & 0xf];
|
||||
}
|
||||
@@ -7240,11 +7242,8 @@ log_nsid(isc_buffer_t *opt, size_t nsid_len, resquery_t *query,
|
||||
|
||||
/* Make printable version */
|
||||
p = pbuf;
|
||||
for (i = 0; i < nsid_len; i++) {
|
||||
if (isprint(nsid[i]))
|
||||
*p++ = nsid[i];
|
||||
else
|
||||
*p++ = '.';
|
||||
for (size_t i = 0; i < nsid_len; i++) {
|
||||
*p++ = isprint(nsid[i]) ? nsid[i] : '.';
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
@@ -7254,10 +7253,8 @@ 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);
|
||||
|
||||
if (pbuf != NULL)
|
||||
isc_mem_put(mctx, pbuf, nsid_len + 1);
|
||||
if (buf != NULL)
|
||||
isc_mem_put(mctx, buf, buflen);
|
||||
isc_mem_put(mctx, pbuf, nsid_len + 1);
|
||||
isc_mem_put(mctx, buf, buflen);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
||||
+2
-9
@@ -273,7 +273,6 @@ 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;
|
||||
|
||||
@@ -299,9 +298,7 @@ dns_sdb_putrdata(dns_sdblookup_t *lookup, dns_rdatatype_t typeval,
|
||||
|
||||
rdata = isc_mem_get(mctx, sizeof(dns_rdata_t));
|
||||
|
||||
result = isc_buffer_allocate(mctx, &rdatabuf, rdlen);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto failure;
|
||||
isc_buffer_allocate(mctx, &rdatabuf, rdlen);
|
||||
DE_CONST(rdatap, region.base);
|
||||
region.length = rdlen;
|
||||
isc_buffer_copyregion(rdatabuf, ®ion);
|
||||
@@ -311,12 +308,8 @@ dns_sdb_putrdata(dns_sdblookup_t *lookup, dns_rdatatype_t typeval,
|
||||
®ion);
|
||||
ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
|
||||
ISC_LIST_APPEND(lookup->buffers, rdatabuf, link);
|
||||
rdata = NULL;
|
||||
|
||||
failure:
|
||||
if (rdata != NULL)
|
||||
isc_mem_put(mctx, rdata, sizeof(dns_rdata_t));
|
||||
return (result);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
|
||||
+2
-6
@@ -1076,9 +1076,7 @@ modrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
||||
|
||||
mctx = sdlz->common.mctx;
|
||||
|
||||
result = isc_buffer_allocate(mctx, &buffer, 1024);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(mctx, &buffer, 1024);
|
||||
|
||||
result = dns_master_stylecreate(&style, 0, 0, 0, 0, 0, 0, 1,
|
||||
0xffffffff, mctx);
|
||||
@@ -1869,9 +1867,7 @@ dns_sdlz_putrr(dns_sdlzlookup_t *lookup, const char *type, dns_ttl_t ttl,
|
||||
goto failure;
|
||||
|
||||
rdatabuf = NULL;
|
||||
result = isc_buffer_allocate(mctx, &rdatabuf, size);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto failure;
|
||||
isc_buffer_allocate(mctx, &rdatabuf, size);
|
||||
|
||||
result = dns_rdata_fromtext(rdata, rdatalist->rdclass,
|
||||
rdatalist->type, lex,
|
||||
|
||||
+124
-103
@@ -42,38 +42,57 @@ 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 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.
|
||||
* 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.
|
||||
*/
|
||||
#define RDTYPECOUNTER_MAXTYPE 0x00ff
|
||||
|
||||
/*
|
||||
* types, !types, nxdomain, stale types, stale !types, stale nxdomain,
|
||||
* ancient types, ancient !types, ancient nxdomain
|
||||
*
|
||||
* Bit 7 is the NXRRSET (NX) flag and indicates whether this is a
|
||||
* positive (0) or a negative (1) RRset.
|
||||
*/
|
||||
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,
|
||||
};
|
||||
#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
|
||||
|
||||
/* dnssec maximum key id */
|
||||
static int dnssec_keyid_max = 65535;
|
||||
@@ -175,8 +194,12 @@ isc_result_t
|
||||
dns_rdatatypestats_create(isc_mem_t *mctx, dns_stats_t **statsp) {
|
||||
REQUIRE(statsp != NULL && *statsp == NULL);
|
||||
|
||||
return (create_stats(mctx, dns_statstype_rdtype, rdtypecounter_max,
|
||||
statsp));
|
||||
/*
|
||||
* 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));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@@ -184,7 +207,7 @@ dns_rdatasetstats_create(isc_mem_t *mctx, dns_stats_t **statsp) {
|
||||
REQUIRE(statsp != NULL && *statsp == NULL);
|
||||
|
||||
return (create_stats(mctx, dns_statstype_rdataset,
|
||||
rdatasettypecounter_max, statsp));
|
||||
(RDTYPECOUNTER_MAXVAL+1), statsp));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@@ -220,52 +243,62 @@ 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) {
|
||||
int counter;
|
||||
isc_statscounter_t counter;
|
||||
|
||||
REQUIRE(DNS_STATS_VALID(stats) && stats->type == dns_statstype_rdtype);
|
||||
|
||||
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);
|
||||
counter = rdatatype2counter(type);
|
||||
isc_stats_increment(stats->counters, counter);
|
||||
}
|
||||
|
||||
static inline void
|
||||
update_rdatasetstats(dns_stats_t *stats, dns_rdatastatstype_t rrsettype,
|
||||
bool increment)
|
||||
{
|
||||
int counter;
|
||||
dns_rdatatype_t rdtype;
|
||||
isc_statscounter_t counter;
|
||||
|
||||
if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) &
|
||||
DNS_RDATASTATSTYPE_ATTR_NXDOMAIN) != 0) {
|
||||
counter = rdtypecounter_nxdomain;
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
counter = rdatatype2counter(DNS_RDATASTATSTYPE_BASE(rrsettype));
|
||||
|
||||
if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) &
|
||||
DNS_RDATASTATSTYPE_ATTR_NXRRSET) != 0)
|
||||
counter += rdtypecounter_max;
|
||||
}
|
||||
DNS_RDATASTATSTYPE_ATTR_NXRRSET) != 0) {
|
||||
counter |= RDTYPECOUNTER_NXRRSET;
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -335,13 +368,10 @@ 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_others)
|
||||
if ((rdcounter & RDTYPECOUNTER_MAXTYPE) == 0) {
|
||||
attributes |= DNS_RDATASTATSTYPE_ATTR_OTHERTYPE;
|
||||
else {
|
||||
if (rdcounter == rdtypecounter_dlv)
|
||||
rdtype = dns_rdatatype_dlv;
|
||||
else
|
||||
rdtype = (dns_rdatatype_t)rdcounter;
|
||||
} else {
|
||||
rdtype = (dns_rdatatype_t)(rdcounter & RDTYPECOUNTER_MAXTYPE);
|
||||
}
|
||||
type = DNS_RDATASTATSTYPE_VALUE((dns_rdatastatstype_t)rdtype,
|
||||
attributes);
|
||||
@@ -370,48 +400,39 @@ 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;
|
||||
bool dump = true;
|
||||
unsigned int attributes = 0;
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
/* Out of bounds, do not dump entry. */
|
||||
dump = false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (dump) {
|
||||
dump_rdentry(counter, value, attributes, rdatadumparg->fn,
|
||||
dump_rdentry(counter, value, attributes, rdatadumparg->fn,
|
||||
rdatadumparg->arg);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -571,8 +571,7 @@ dns_test_namefromstring(const char *namestr, dns_fixedname_t *fname) {
|
||||
|
||||
name = dns_fixedname_initname(fname);
|
||||
|
||||
result = isc_buffer_allocate(dt_mctx, &b, length);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
isc_buffer_allocate(dt_mctx, &b, length);
|
||||
|
||||
isc_buffer_putmem(b, (const unsigned char *) namestr, length);
|
||||
result = dns_name_fromtext(name, b, dns_rootname, 0, NULL);
|
||||
|
||||
@@ -130,7 +130,7 @@ static isc_result_t
|
||||
write_data(FILE *file, unsigned char *datap, void *arg, uint64_t *crc) {
|
||||
isc_result_t result;
|
||||
size_t ret = 0;
|
||||
data_holder_t *data = (data_holder_t *)datap;
|
||||
data_holder_t *data;
|
||||
data_holder_t temp;
|
||||
off_t where;
|
||||
|
||||
@@ -138,7 +138,8 @@ write_data(FILE *file, unsigned char *datap, void *arg, uint64_t *crc) {
|
||||
|
||||
REQUIRE(file != NULL);
|
||||
REQUIRE(crc != NULL);
|
||||
REQUIRE(data != NULL);
|
||||
REQUIRE(datap != NULL);
|
||||
data = (data_holder_t *)datap;
|
||||
REQUIRE((data->len == 0 && data->data == NULL) ||
|
||||
(data->len != 0 && data->data != NULL));
|
||||
|
||||
@@ -402,7 +403,9 @@ 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) {
|
||||
|
||||
@@ -223,12 +223,11 @@ rdatasetstats(void **state, bool servestale) {
|
||||
result = dns_rdatasetstats_create(dt_mctx, &stats);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
/* First 256 types. */
|
||||
for (i = 0; i <= 255; i++) {
|
||||
/* First 255 types. */
|
||||
for (i = 1; 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);
|
||||
|
||||
@@ -237,12 +236,10 @@ rdatasetstats(void **state, bool servestale) {
|
||||
|
||||
if (servestale) {
|
||||
/* Mark stale */
|
||||
for (i = 0; i <= 255; i++) {
|
||||
for (i = 1; 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);
|
||||
@@ -255,12 +252,10 @@ rdatasetstats(void **state, bool servestale) {
|
||||
}
|
||||
|
||||
/* Mark ancient */
|
||||
for (i = 0; i <= 255; i++) {
|
||||
for (i = 1; 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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
CHECK(isc_buffer_allocate(dt_mctx, &dynbuf, 512));
|
||||
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,16 +312,14 @@ tsig_tcp_test(void **state) {
|
||||
/*
|
||||
* Create request.
|
||||
*/
|
||||
result = isc_buffer_allocate(dt_mctx, &buf, 65535);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
isc_buffer_allocate(dt_mctx, &buf, 65535);
|
||||
render(buf, 0, key, &tsigout, &querytsig, NULL);
|
||||
isc_buffer_free(&buf);
|
||||
|
||||
/*
|
||||
* Create response message 1.
|
||||
*/
|
||||
result = isc_buffer_allocate(dt_mctx, &buf, 65535);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
isc_buffer_allocate(dt_mctx, &buf, 65535);
|
||||
render(buf, DNS_MESSAGEFLAG_QR, key, &querytsig, &tsigout, NULL);
|
||||
|
||||
/*
|
||||
@@ -374,8 +372,7 @@ tsig_tcp_test(void **state) {
|
||||
/*
|
||||
* Create response message 2.
|
||||
*/
|
||||
result = isc_buffer_allocate(dt_mctx, &buf, 65535);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
isc_buffer_allocate(dt_mctx, &buf, 65535);
|
||||
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
render(buf, DNS_MESSAGEFLAG_QR, key, &tsigout, &tsigout, outctx);
|
||||
@@ -421,8 +418,7 @@ tsig_tcp_test(void **state) {
|
||||
/*
|
||||
* Create response message 3.
|
||||
*/
|
||||
result = isc_buffer_allocate(dt_mctx, &buf, 65535);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
isc_buffer_allocate(dt_mctx, &buf, 65535);
|
||||
render(buf, DNS_MESSAGEFLAG_QR, key, &tsigout, &tsigout, outctx);
|
||||
|
||||
result = add_tsig(outctx, key, buf);
|
||||
|
||||
+7
-7
@@ -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);
|
||||
RETERR(isc_buffer_allocate(msg->mctx, &tmprdatabuf, r.length));
|
||||
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));
|
||||
RETERR(isc_buffer_allocate(msg->mctx, &shared, sharedsize));
|
||||
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;
|
||||
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));
|
||||
isc_buffer_allocate(msg->mctx, &dynbuf, len);
|
||||
isc_buffer_allocate(msg->mctx, &anamebuf, name->length);
|
||||
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));
|
||||
RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 1024));
|
||||
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));
|
||||
RETERR(isc_buffer_allocate(rmsg->mctx, &shared, sharedsize));
|
||||
isc_buffer_allocate(rmsg->mctx, &shared, sharedsize);
|
||||
|
||||
RETERR(dst_key_computesecret(theirkey, key, shared));
|
||||
|
||||
|
||||
+1
-3
@@ -975,9 +975,7 @@ dns_tsig_sign(dns_message_t *msg) {
|
||||
ret = dns_message_gettemprdata(msg, &rdata);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
goto cleanup_signature;
|
||||
ret = isc_buffer_allocate(msg->mctx, &dynbuf, 512);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
goto cleanup_rdata;
|
||||
isc_buffer_allocate(msg->mctx, &dynbuf, 512);
|
||||
ret = dns_rdata_fromstruct(rdata, dns_rdataclass_any,
|
||||
dns_rdatatype_tsig, &tsig, dynbuf);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
|
||||
@@ -1432,6 +1432,7 @@ 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
|
||||
|
||||
+96
-44
@@ -13428,17 +13428,18 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) {
|
||||
|
||||
cleanup:
|
||||
cancel_refresh(zone);
|
||||
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));
|
||||
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 (message != NULL)
|
||||
dns_message_destroy(&message);
|
||||
unlock:
|
||||
@@ -13822,9 +13823,7 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags,
|
||||
goto soa_cleanup;
|
||||
dns_rdataset_current(&rdataset, &rdata);
|
||||
dns_rdata_toregion(&rdata, &r);
|
||||
result = isc_buffer_allocate(zone->mctx, &b, r.length);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto soa_cleanup;
|
||||
isc_buffer_allocate(zone->mctx, &b, r.length);
|
||||
isc_buffer_putmem(b, r.base, r.length);
|
||||
isc_buffer_usedregion(b, &r);
|
||||
dns_rdata_init(temprdata);
|
||||
@@ -16712,9 +16711,7 @@ dns_zone_forwardupdate(dns_zone_t *zone, dns_message_t *msg,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = isc_buffer_allocate(zone->mctx, &forward->msgbuf, mr->length);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_buffer_allocate(zone->mctx, &forward->msgbuf, mr->length);
|
||||
result = isc_buffer_copyregion(forward->msgbuf, mr);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
@@ -19137,11 +19134,14 @@ 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,16 +19149,19 @@ 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;
|
||||
}
|
||||
@@ -19166,21 +19169,25 @@ 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.
|
||||
* a matching DNSKEY record with the exception of a CDS deletion
|
||||
* record which must be by itself.
|
||||
*/
|
||||
if (dns_rdataset_isassociated(&cds)) {
|
||||
memset(algorithms, 0, sizeof(algorithms));
|
||||
bool delete = false;
|
||||
memset(algorithms, notexpected, sizeof(algorithms));
|
||||
for (result = dns_rdataset_first(&cds);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(&cds)) {
|
||||
@@ -19188,9 +19195,21 @@ 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] = 1;
|
||||
if (algorithms[structcds.algorithm] == 0) {
|
||||
algorithms[structcds.algorithm] = expected;
|
||||
}
|
||||
for (result = dns_rdataset_first(&dnskey);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(&dnskey)) {
|
||||
@@ -19203,16 +19222,23 @@ 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] = 2;
|
||||
dsrdata.length) == 0)
|
||||
{
|
||||
algorithms[structcds.algorithm] = found;
|
||||
}
|
||||
}
|
||||
if (result != ISC_R_NOMORE)
|
||||
if (result != ISC_R_NOMORE) {
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < sizeof(algorithms); i++) {
|
||||
if (algorithms[i] == 1) {
|
||||
result = DNS_R_BADCDNSKEY;
|
||||
if (delete) {
|
||||
if (algorithms[i] != notexpected) {
|
||||
result = DNS_R_BADCDS;
|
||||
goto failure;
|
||||
}
|
||||
} else if (algorithms[i] == expected) {
|
||||
result = DNS_R_BADCDS;
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
@@ -19220,10 +19246,12 @@ 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.
|
||||
* a matching DNSKEY record with the exception of a CDNSKEY deletion
|
||||
* record which must be by itself.
|
||||
*/
|
||||
if (dns_rdataset_isassociated(&cdnskey)) {
|
||||
memset(algorithms, 0, sizeof(algorithms));
|
||||
bool delete = false;
|
||||
memset(algorithms, notexpected, sizeof(algorithms));
|
||||
for (result = dns_rdataset_first(&cdnskey);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(&cdnskey)) {
|
||||
@@ -19231,10 +19259,23 @@ 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] = 1;
|
||||
if (algorithms[structcdnskey.algorithm] == 0) {
|
||||
algorithms[structcdnskey.algorithm] = expected;
|
||||
}
|
||||
for (result = dns_rdataset_first(&dnskey);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(&dnskey)) {
|
||||
@@ -19243,16 +19284,24 @@ 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] = 2;
|
||||
rdata.length) == 0)
|
||||
{
|
||||
algorithms[structcdnskey.algorithm] =
|
||||
found;
|
||||
}
|
||||
}
|
||||
if (result != ISC_R_NOMORE)
|
||||
if (result != ISC_R_NOMORE) {
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < sizeof(algorithms); i++) {
|
||||
if (algorithms[i] == 1) {
|
||||
result = DNS_R_BADCDS;
|
||||
if (delete) {
|
||||
if (algorithms[i] != notexpected) {
|
||||
result = DNS_R_BADCDNSKEY;
|
||||
goto failure;
|
||||
}
|
||||
} else if (algorithms[i] == expected) {
|
||||
result = DNS_R_BADCDNSKEY;
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
@@ -19260,12 +19309,15 @@ 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);
|
||||
}
|
||||
|
||||
+47
-28
@@ -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,6 +1162,37 @@ 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;
|
||||
@@ -1214,39 +1245,27 @@ verify_nsec3_chains(const vctx_t *vctx, isc_mem_t *mctx) {
|
||||
"not equal");
|
||||
result = ISC_R_FAILURE;
|
||||
}
|
||||
if (first == NULL || newchain(first, 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);
|
||||
}
|
||||
|
||||
if (first == NULL) {
|
||||
prev = first = e;
|
||||
continue;
|
||||
} else if (newchain(first, e)) {
|
||||
if (!checklast(mctx, vctx, first, prev)) {
|
||||
result = ISC_R_FAILURE;
|
||||
}
|
||||
|
||||
prev = first = e;
|
||||
} else {
|
||||
if (!checknext(mctx, vctx, first, prev, e)) {
|
||||
result = ISC_R_FAILURE;
|
||||
}
|
||||
|
||||
prev = e;
|
||||
}
|
||||
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)) {
|
||||
if (!checklast(mctx, vctx, first, prev)) {
|
||||
result = ISC_R_FAILURE;
|
||||
}
|
||||
if (prev != first) {
|
||||
free_element(mctx, prev);
|
||||
}
|
||||
}
|
||||
if (first != NULL) {
|
||||
free_element(mctx, first);
|
||||
}
|
||||
do {
|
||||
if (f != NULL) {
|
||||
|
||||
+1
-5
@@ -109,11 +109,7 @@ configure_key(isc_mem_t *mctx, const cfg_obj_t *key, irs_dnsconf_t *conf,
|
||||
return (result);
|
||||
}
|
||||
isc_buffer_usedregion(&rrdatabuf, &r);
|
||||
result = isc_buffer_allocate(mctx, &keydatabuf,
|
||||
r.length);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
isc_buffer_allocate(mctx, &keydatabuf, r.length);
|
||||
result = isc_buffer_copyregion(keydatabuf, &r);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
|
||||
+5
-13
@@ -500,9 +500,7 @@ isc_buffer_dup(isc_mem_t *mctx, isc_buffer_t **dstp, const isc_buffer_t *src) {
|
||||
|
||||
isc_buffer_usedregion(src, ®ion);
|
||||
|
||||
result = isc_buffer_allocate(mctx, &dst, region.length);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(mctx, &dst, region.length);
|
||||
|
||||
result = isc_buffer_copyregion(dst, ®ion);
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS); /* NOSPACE is impossible */
|
||||
@@ -536,18 +534,14 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r) {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
void
|
||||
isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
|
||||
unsigned int length)
|
||||
{
|
||||
isc_buffer_t *dbuf;
|
||||
unsigned char * bdata;
|
||||
REQUIRE(dynbuffer != NULL);
|
||||
REQUIRE(*dynbuffer == NULL);
|
||||
REQUIRE(dynbuffer != NULL && *dynbuffer == NULL);
|
||||
|
||||
dbuf = isc_mem_get(mctx, sizeof(isc_buffer_t));
|
||||
|
||||
bdata = isc_mem_get(mctx, length);
|
||||
isc_buffer_t *dbuf = isc_mem_get(mctx, sizeof(isc_buffer_t));
|
||||
unsigned char *bdata = isc_mem_get(mctx, length);
|
||||
|
||||
isc_buffer_init(dbuf, bdata, length);
|
||||
|
||||
@@ -556,8 +550,6 @@ isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
|
||||
dbuf->mctx = mctx;
|
||||
|
||||
*dynbuffer = dbuf;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
|
||||
@@ -192,7 +192,7 @@ struct isc_buffer {
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
isc_result_t
|
||||
void
|
||||
isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
|
||||
unsigned int length);
|
||||
/*!<
|
||||
@@ -204,10 +204,6 @@ 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.
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
/*%
|
||||
* Performance
|
||||
*/
|
||||
#ifdef CPPCHECK
|
||||
#define ISC_LIKELY(x) (x)
|
||||
#define ISC_UNLIKELY(x) (x)
|
||||
#else
|
||||
#ifdef HAVE_BUILTIN_EXPECT
|
||||
#define ISC_LIKELY(x) __builtin_expect(!!(x), 1)
|
||||
#define ISC_UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
@@ -22,5 +26,6 @@
|
||||
#define ISC_LIKELY(x) (x)
|
||||
#define ISC_UNLIKELY(x) (x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* ISC_LIKELY_H */
|
||||
|
||||
@@ -451,7 +451,7 @@ isc_mem_renderjson(void *memobj0);
|
||||
* Memory pools
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
void
|
||||
isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp);
|
||||
/*%<
|
||||
* Create a memory pool.
|
||||
|
||||
@@ -285,12 +285,17 @@ extern void mock_assert(const int result, const char* const expression,
|
||||
#ifdef UNIT_TESTING
|
||||
|
||||
#define RUNTIME_CHECK(expression) \
|
||||
mock_assert((int)(expression), #expression, __FILE__, __LINE__)
|
||||
((!(expression)) ? \
|
||||
(mock_assert(0, #expression, __FILE__, __LINE__), abort()) : (void)0)
|
||||
|
||||
#else /* UNIT_TESTING */
|
||||
|
||||
#ifndef CPPCHECK
|
||||
/*% Runtime Check */
|
||||
#define RUNTIME_CHECK(cond) ISC_ERROR_RUNTIMECHECK(cond)
|
||||
#else
|
||||
#define RUNTIME_CHECK(e) if (!(e)) abort()
|
||||
#endif
|
||||
|
||||
#endif /* UNIT_TESTING */
|
||||
|
||||
|
||||
+3
-11
@@ -181,7 +181,6 @@ 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;
|
||||
@@ -192,13 +191,8 @@ 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;
|
||||
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);
|
||||
}
|
||||
isc_buffer_allocate(lex->mctx, &source->pushback,
|
||||
(unsigned int)lex->max_token);
|
||||
source->ignored = 0;
|
||||
source->line = 1;
|
||||
ISC_LIST_INITANDPREPEND(lex->sources, source, link);
|
||||
@@ -320,9 +314,7 @@ pushandgrow(isc_lex_t *lex, inputsource *source, int c) {
|
||||
isc_result_t result;
|
||||
|
||||
oldlen = isc_buffer_length(source->pushback);
|
||||
result = isc_buffer_allocate(lex->mctx, &tbuf, oldlen * 2);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_allocate(lex->mctx, &tbuf, oldlen * 2);
|
||||
isc_buffer_usedregion(source->pushback, &used);
|
||||
result = isc_buffer_copyregion(tbuf, &used);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
||||
+15
-17
@@ -321,17 +321,15 @@ 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:
|
||||
@@ -377,18 +375,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
|
||||
if (lcfg != NULL)
|
||||
isc_logconfig_destroy(&lcfg);
|
||||
} else {
|
||||
isc_logconfig_destroy(&lcfg);
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
+98
-98
@@ -126,6 +126,11 @@ 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 *);
|
||||
|
||||
@@ -363,7 +368,6 @@ 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;
|
||||
@@ -380,7 +384,6 @@ 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++;
|
||||
@@ -473,7 +476,6 @@ 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++;
|
||||
@@ -596,7 +598,6 @@ 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))
|
||||
@@ -723,10 +724,10 @@ initialize_action(void) {
|
||||
static void
|
||||
mem_create(isc_mem_t **ctxp, unsigned int flags)
|
||||
{
|
||||
isc__mem_t *ctx;
|
||||
|
||||
REQUIRE(ctxp != NULL && *ctxp == NULL);
|
||||
|
||||
isc__mem_t *ctx;
|
||||
|
||||
STATIC_ASSERT((ALIGNMENT_SIZE & (ALIGNMENT_SIZE - 1)) == 0,
|
||||
"wrong alignment size");
|
||||
|
||||
@@ -774,7 +775,6 @@ 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,7 +784,6 @@ 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 *);
|
||||
@@ -797,7 +796,6 @@ 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);
|
||||
@@ -895,11 +893,11 @@ destroy(isc__mem_t *ctx) {
|
||||
|
||||
void
|
||||
isc_mem_attach(isc_mem_t *source0, isc_mem_t **targetp) {
|
||||
isc__mem_t *source = (isc__mem_t *)source0;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(source));
|
||||
REQUIRE(VALID_CONTEXT(source0));
|
||||
REQUIRE(targetp != NULL && *targetp == NULL);
|
||||
|
||||
isc__mem_t *source = (isc__mem_t *)source0;
|
||||
|
||||
isc_refcount_increment(&source->references);
|
||||
|
||||
*targetp = (isc_mem_t *)source;
|
||||
@@ -908,6 +906,7 @@ 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;
|
||||
|
||||
@@ -931,6 +930,7 @@ 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,16 +970,14 @@ 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);
|
||||
ctx = (isc__mem_t *)*ctxp;
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
REQUIRE(ctxp != NULL && VALID_CONTEXT(*ctxp));
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)*ctxp;
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if (isc_refcount_decrement(&ctx->references) > 1) {
|
||||
@@ -996,12 +994,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));
|
||||
@@ -1040,14 +1038,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))
|
||||
{
|
||||
@@ -1092,9 +1090,9 @@ isc___mem_put(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
|
||||
|
||||
void
|
||||
isc_mem_waterack(isc_mem_t *ctx0, int flag) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
MCTXLOCK(ctx);
|
||||
if (flag == ISC_MEM_LOWATER)
|
||||
@@ -1144,12 +1142,13 @@ 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++) {
|
||||
@@ -1232,12 +1231,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)) {
|
||||
@@ -1274,12 +1273,11 @@ 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) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
REQUIRE(VALID_CONTEXT(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
|
||||
@@ -1315,14 +1313,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);
|
||||
@@ -1373,13 +1371,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);
|
||||
@@ -1392,9 +1390,10 @@ 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;
|
||||
@@ -1404,10 +1403,11 @@ 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,10 +1419,11 @@ 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;
|
||||
@@ -1434,10 +1435,11 @@ 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;
|
||||
@@ -1451,14 +1453,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;
|
||||
@@ -1486,9 +1488,9 @@ isc_mem_setwater(isc_mem_t *ctx0, isc_mem_water_t water, void *water_arg,
|
||||
|
||||
bool
|
||||
isc_mem_isovermem(isc_mem_t *ctx0) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
/*
|
||||
* We don't bother to lock the context because 100% accuracy isn't
|
||||
@@ -1500,9 +1502,9 @@ isc_mem_isovermem(isc_mem_t *ctx0) {
|
||||
|
||||
void
|
||||
isc_mem_setname(isc_mem_t *ctx0, const char *name, void *tag) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
LOCK(&ctx->lock);
|
||||
strlcpy(ctx->name, name, sizeof(ctx->name));
|
||||
@@ -1512,9 +1514,9 @@ isc_mem_setname(isc_mem_t *ctx0, const char *name, void *tag) {
|
||||
|
||||
const char *
|
||||
isc_mem_getname(isc_mem_t *ctx0) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
if (ctx->name[0] == 0)
|
||||
return ("");
|
||||
@@ -1524,9 +1526,9 @@ isc_mem_getname(isc_mem_t *ctx0) {
|
||||
|
||||
void *
|
||||
isc_mem_gettag(isc_mem_t *ctx0) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
return (ctx->tag);
|
||||
}
|
||||
@@ -1535,21 +1537,20 @@ isc_mem_gettag(isc_mem_t *ctx0) {
|
||||
* Memory pool stuff
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
void
|
||||
isc_mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
|
||||
isc__mem_t *mctx = (isc__mem_t *)mctx0;
|
||||
isc__mempool_t *mpctx;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(mctx));
|
||||
REQUIRE(VALID_CONTEXT(mctx0));
|
||||
REQUIRE(size > 0U);
|
||||
REQUIRE(mpctxp != NULL && *mpctxp == NULL);
|
||||
|
||||
isc__mem_t *mctx = (isc__mem_t *)mctx0;
|
||||
isc__mempool_t *mpctx;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
@@ -1579,16 +1580,14 @@ 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) {
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
REQUIRE(name != NULL);
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
#if ISC_MEMPOOL_NAMES
|
||||
if (mpctx->lock != NULL)
|
||||
@@ -1606,14 +1605,15 @@ 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,24 +1670,25 @@ 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)
|
||||
@@ -1757,14 +1758,12 @@ isc__mempool_get(isc_mempool_t *mpctx0 FLARG) {
|
||||
/* coverity[+free : arg-1] */
|
||||
void
|
||||
isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
isc__mem_t *mctx;
|
||||
element *item;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
REQUIRE(mem != NULL);
|
||||
|
||||
mctx = mpctx->mctx;
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
isc__mem_t *mctx = mpctx->mctx;
|
||||
element *item;
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
LOCK(mpctx->lock);
|
||||
@@ -1815,9 +1814,9 @@ isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
|
||||
|
||||
void
|
||||
isc_mempool_setfreemax(isc_mempool_t *mpctx0, unsigned int limit) {
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
LOCK(mpctx->lock);
|
||||
@@ -1830,11 +1829,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);
|
||||
|
||||
@@ -1848,10 +1847,11 @@ 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,11 +1866,10 @@ isc_mempool_getfreecount(isc_mempool_t *mpctx0) {
|
||||
|
||||
void
|
||||
isc_mempool_setmaxalloc(isc_mempool_t *mpctx0, unsigned int limit) {
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
REQUIRE(limit > 0);
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
if (mpctx->lock != NULL)
|
||||
LOCK(mpctx->lock);
|
||||
@@ -1883,11 +1882,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);
|
||||
|
||||
@@ -1901,10 +1900,11 @@ 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,10 +1919,10 @@ isc_mempool_getallocated(isc_mempool_t *mpctx0) {
|
||||
|
||||
void
|
||||
isc_mempool_setfillcount(isc_mempool_t *mpctx0, unsigned int limit) {
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
REQUIRE(limit > 0);
|
||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
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)
|
||||
{
|
||||
int xmlrc;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
|
||||
int xmlrc;
|
||||
|
||||
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
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
REQUIRE(VALID_CONTEXT(ctx0));
|
||||
REQUIRE(file != NULL);
|
||||
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
|
||||
print_active(ctx, file);
|
||||
#else
|
||||
UNUSED(ctx0);
|
||||
|
||||
@@ -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[65536];
|
||||
char * recvbuf;
|
||||
bool recvbuf_inuse;
|
||||
} isc__networker_t;
|
||||
|
||||
|
||||
@@ -210,6 +210,7 @@ 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
|
||||
@@ -281,6 +282,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -956,8 +958,8 @@ isc__nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr,
|
||||
} else {
|
||||
sock->statsindex = tcp6statsindex;
|
||||
}
|
||||
break;
|
||||
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_ACTIVE]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -982,14 +984,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 <= 65536);
|
||||
REQUIRE(size <= ISC_NETMGR_RECVBUF_SIZE);
|
||||
|
||||
worker = &sock->mgr->workers[sock->tid];
|
||||
INSIST(!worker->recvbuf_inuse);
|
||||
|
||||
buf->base = worker->recvbuf;
|
||||
worker->recvbuf_inuse = true;
|
||||
buf->len = size;
|
||||
buf->len = ISC_NETMGR_RECVBUF_SIZE;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1004,8 +1006,11 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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, &localaddr);
|
||||
nmhandle = isc__nmhandle_get(sock, &sockaddr, NULL);
|
||||
region.base = (unsigned char *) buf->base;
|
||||
region.length = nrecv;
|
||||
|
||||
|
||||
+8
-6
@@ -14,6 +14,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <isc/log.h>
|
||||
#include <isc/mem.h>
|
||||
@@ -21,6 +22,7 @@
|
||||
#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>
|
||||
@@ -151,8 +153,12 @@ pk11_mem_get(size_t size) {
|
||||
ptr = isc_mem_get(pk11_mctx, size);
|
||||
else {
|
||||
ptr = malloc(size);
|
||||
if (ptr != NULL)
|
||||
allocsize += (int)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);
|
||||
}
|
||||
}
|
||||
UNLOCK(&alloclock);
|
||||
|
||||
@@ -323,8 +329,6 @@ 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;
|
||||
@@ -479,7 +483,6 @@ 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++) {
|
||||
@@ -490,7 +493,6 @@ 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);
|
||||
|
||||
@@ -103,10 +103,10 @@ void isc__mutex_init(isc_mutex_t *mp, const char *file, unsigned int line);
|
||||
|
||||
#if ISC_MUTEX_PROFILE
|
||||
#define isc_mutex_destroy(mp) \
|
||||
(RUNTIME_CHECK(pthread_mutex_destroy((&(mp)->mutex)) == 0))
|
||||
RUNTIME_CHECK(pthread_mutex_destroy((&(mp)->mutex)) == 0)
|
||||
#else
|
||||
#define isc_mutex_destroy(mp) \
|
||||
(RUNTIME_CHECK(pthread_mutex_destroy((mp)) == 0))
|
||||
RUNTIME_CHECK(pthread_mutex_destroy((mp)) == 0)
|
||||
#endif
|
||||
|
||||
#if ISC_MUTEX_PROFILE
|
||||
|
||||
+7
-7
@@ -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_mutex_t lock;
|
||||
static isc_rwlock_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);
|
||||
|
||||
LOCK(&lock);
|
||||
RWLOCK(&lock, isc_rwlocktype_write);
|
||||
|
||||
ISC_LIST_APPEND(*tables, table, link);
|
||||
|
||||
UNLOCK(&lock);
|
||||
RWUNLOCK(&lock, isc_rwlocktype_write);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -221,7 +221,7 @@ static void
|
||||
initialize_action(void) {
|
||||
isc_result_t result;
|
||||
|
||||
isc_mutex_init(&lock);
|
||||
isc_rwlock_init(&lock, 0, 0);
|
||||
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();
|
||||
|
||||
LOCK(&lock);
|
||||
RWLOCK(&lock, isc_rwlocktype_read);
|
||||
|
||||
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)";
|
||||
}
|
||||
|
||||
UNLOCK(&lock);
|
||||
RWUNLOCK(&lock, isc_rwlocktype_read);
|
||||
|
||||
return (text);
|
||||
}
|
||||
|
||||
+44
-11
@@ -23,11 +23,14 @@
|
||||
#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
|
||||
@@ -42,6 +45,17 @@ 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;
|
||||
@@ -50,7 +64,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;
|
||||
counters_alloc_size = sizeof(isc__atomic_statcounter_t) * ncounters * STATS_BUCKETS;
|
||||
stats->counters = isc_mem_get(mctx, counters_alloc_size);
|
||||
isc_refcount_init(&stats->references, 1);
|
||||
memset(stats->counters, 0, counters_alloc_size);
|
||||
@@ -85,7 +99,8 @@ 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->ncounters *
|
||||
STATS_BUCKETS);
|
||||
isc_mem_putanddetach(&stats->mctx, stats, sizeof(*stats));
|
||||
}
|
||||
}
|
||||
@@ -108,8 +123,8 @@ void
|
||||
isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter) {
|
||||
REQUIRE(ISC_STATS_VALID(stats));
|
||||
REQUIRE(counter < stats->ncounters);
|
||||
|
||||
atomic_fetch_add_explicit(&stats->counters[counter], 1,
|
||||
int idx = threadhash() * stats->ncounters + counter;
|
||||
atomic_fetch_add_explicit(&stats->counters[idx], 1,
|
||||
memory_order_relaxed);
|
||||
}
|
||||
|
||||
@@ -118,7 +133,8 @@ isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter) {
|
||||
REQUIRE(ISC_STATS_VALID(stats));
|
||||
REQUIRE(counter < stats->ncounters);
|
||||
|
||||
atomic_fetch_sub_explicit(&stats->counters[counter], 1,
|
||||
int idx = threadhash() * stats->ncounters + counter;
|
||||
atomic_fetch_sub_explicit(&stats->counters[idx], 1,
|
||||
memory_order_relaxed);
|
||||
}
|
||||
|
||||
@@ -131,8 +147,13 @@ 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 = atomic_load_explicit(&stats->counters[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],
|
||||
memory_order_relaxed);
|
||||
}
|
||||
if ((options & ISC_STATSDUMP_VERBOSE) == 0 && counter == 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -144,11 +165,17 @@ 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,
|
||||
@@ -158,9 +185,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 =
|
||||
atomic_load_relaxed(&stats->counters[counter]);
|
||||
isc_statscounter_t curr_value;
|
||||
do {
|
||||
curr_value = atomic_load_relaxed(&stats->counters[counter]);
|
||||
if (curr_value >= value) {
|
||||
break;
|
||||
}
|
||||
@@ -172,9 +199,15 @@ 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);
|
||||
|
||||
return (atomic_load_explicit(&stats->counters[counter],
|
||||
memory_order_relaxed));
|
||||
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);
|
||||
}
|
||||
|
||||
+54
-29
@@ -106,6 +106,7 @@ 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;
|
||||
@@ -152,6 +153,7 @@ struct isc__taskqueue {
|
||||
isc_thread_t thread;
|
||||
unsigned int threadid;
|
||||
isc__taskmgr_t *manager;
|
||||
uint64_t eprocessed;
|
||||
};
|
||||
|
||||
struct isc__taskmgr {
|
||||
@@ -308,6 +310,7 @@ 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);
|
||||
@@ -407,7 +410,7 @@ task_shutdown(isc__task_t *task) {
|
||||
/*
|
||||
* Moves a task onto the appropriate run queue.
|
||||
*
|
||||
* Caller must NOT hold manager lock.
|
||||
* Caller must NOT hold queue lock.
|
||||
*/
|
||||
static inline void
|
||||
task_ready(isc__task_t *task) {
|
||||
@@ -415,7 +418,6 @@ 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);
|
||||
@@ -967,10 +969,13 @@ 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 manager lock.
|
||||
* Caller must hold the task queue 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,
|
||||
@@ -1128,6 +1133,17 @@ 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");
|
||||
@@ -1145,6 +1161,7 @@ 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)(
|
||||
@@ -1215,6 +1232,15 @@ 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
|
||||
@@ -1227,17 +1253,8 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
|
||||
* so the minimum quantum is one.
|
||||
*/
|
||||
XTRACE("quantum");
|
||||
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;
|
||||
}
|
||||
task->state = task_state_ready;
|
||||
requeue = true;
|
||||
done = true;
|
||||
}
|
||||
} while (!done);
|
||||
@@ -1428,6 +1445,7 @@ 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];
|
||||
@@ -1523,7 +1541,11 @@ 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.
|
||||
*/
|
||||
@@ -1686,31 +1708,27 @@ 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
|
||||
@@ -1721,6 +1739,13 @@ 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 */
|
||||
|
||||
@@ -65,8 +65,7 @@ isc_buffer_reserve_test(void **state) {
|
||||
UNUSED(state);
|
||||
|
||||
b = NULL;
|
||||
result = isc_buffer_allocate(test_mctx, &b, 1024);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
isc_buffer_allocate(test_mctx, &b, 1024);
|
||||
assert_int_equal(b->length, 1024);
|
||||
|
||||
/*
|
||||
@@ -127,7 +126,6 @@ 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;
|
||||
@@ -135,8 +133,7 @@ isc_buffer_dynamic_test(void **state) {
|
||||
UNUSED(state);
|
||||
|
||||
b = NULL;
|
||||
result = isc_buffer_allocate(test_mctx, &b, last_length);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
isc_buffer_allocate(test_mctx, &b, last_length);
|
||||
assert_non_null(b);
|
||||
assert_int_equal(b->length, last_length);
|
||||
|
||||
@@ -194,8 +191,7 @@ isc_buffer_copyregion_test(void **state) {
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = isc_buffer_allocate(test_mctx, &b, sizeof(data));
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
isc_buffer_allocate(test_mctx, &b, sizeof(data));
|
||||
|
||||
/*
|
||||
* Fill originally allocated buffer space.
|
||||
@@ -234,8 +230,7 @@ isc_buffer_printf_test(void **state) {
|
||||
* Prepare a buffer with auto-reallocation enabled.
|
||||
*/
|
||||
b = NULL;
|
||||
result = isc_buffer_allocate(test_mctx, &b, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
isc_buffer_allocate(test_mctx, &b, 0);
|
||||
isc_buffer_setautorealloc(b, true);
|
||||
|
||||
/*
|
||||
|
||||
@@ -69,7 +69,6 @@ _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;
|
||||
@@ -79,11 +78,8 @@ isc_mem_test(void **state) {
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
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_create(test_mctx, 24, &mp1);
|
||||
isc_mempool_create(test_mctx, 31, &mp2);
|
||||
|
||||
isc_mempool_setfreemax(mp1, MP1_FREEMAX);
|
||||
isc_mempool_setfillcount(mp1, MP1_FILLCNT);
|
||||
@@ -148,8 +144,7 @@ isc_mem_test(void **state) {
|
||||
isc_mempool_destroy(&mp1);
|
||||
isc_mempool_destroy(&mp2);
|
||||
|
||||
result = isc_mempool_create(test_mctx, 2, &mp1);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
isc_mempool_create(test_mctx, 2, &mp1);
|
||||
|
||||
tmp = isc_mempool_get(mp1);
|
||||
assert_non_null(tmp);
|
||||
@@ -460,8 +455,7 @@ isc_mempool_benchmark(void **state) {
|
||||
|
||||
isc_mutex_init(&mplock);
|
||||
|
||||
result = isc_mempool_create(test_mctx, ITEM_SIZE, &mp);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
isc_mempool_create(test_mctx, ITEM_SIZE, &mp);
|
||||
|
||||
isc_mempool_associatelock(mp, &mplock);
|
||||
|
||||
|
||||
+22
-16
@@ -239,7 +239,11 @@ 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)
|
||||
{
|
||||
isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
|
||||
REQUIRE(VALID_MANAGER(manager0));
|
||||
REQUIRE(task != NULL);
|
||||
REQUIRE(action != NULL);
|
||||
|
||||
isc__timermgr_t *manager;
|
||||
isc__timer_t *timer;
|
||||
isc_result_t result;
|
||||
isc_time_t now;
|
||||
@@ -251,10 +255,7 @@ 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(manager));
|
||||
REQUIRE(task != NULL);
|
||||
REQUIRE(action != NULL);
|
||||
manager = (isc__timermgr_t *)manager0;
|
||||
if (expires == NULL)
|
||||
expires = isc_time_epoch;
|
||||
if (interval == NULL)
|
||||
@@ -352,7 +353,7 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
|
||||
const isc_time_t *expires, const isc_interval_t *interval,
|
||||
bool purge)
|
||||
{
|
||||
isc__timer_t *timer = (isc__timer_t *)timer0;
|
||||
isc__timer_t *timer;
|
||||
isc_time_t now;
|
||||
isc__timermgr_t *manager;
|
||||
isc_result_t result;
|
||||
@@ -363,7 +364,8 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
|
||||
* are purged from its task's event queue.
|
||||
*/
|
||||
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
REQUIRE(VALID_TIMER(timer0));
|
||||
timer = (isc__timer_t *)timer0;
|
||||
manager = timer->manager;
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
|
||||
@@ -425,10 +427,11 @@ isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
|
||||
|
||||
isc_timertype_t
|
||||
isc_timer_gettype(isc_timer_t *timer0) {
|
||||
isc__timer_t *timer = (isc__timer_t *)timer0;
|
||||
isc__timer_t *timer;
|
||||
isc_timertype_t t;
|
||||
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
REQUIRE(VALID_TIMER(timer0));
|
||||
timer = (isc__timer_t *)timer0;
|
||||
|
||||
LOCK(&timer->lock);
|
||||
t = timer->type;
|
||||
@@ -439,7 +442,7 @@ isc_timer_gettype(isc_timer_t *timer0) {
|
||||
|
||||
isc_result_t
|
||||
isc_timer_touch(isc_timer_t *timer0) {
|
||||
isc__timer_t *timer = (isc__timer_t *)timer0;
|
||||
isc__timer_t *timer;
|
||||
isc_result_t result;
|
||||
isc_time_t now;
|
||||
|
||||
@@ -447,7 +450,8 @@ isc_timer_touch(isc_timer_t *timer0) {
|
||||
* Set the last-touched time of 'timer' to the current time.
|
||||
*/
|
||||
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
REQUIRE(VALID_TIMER(timer0));
|
||||
timer = (isc__timer_t *)timer0;
|
||||
|
||||
LOCK(&timer->lock);
|
||||
|
||||
@@ -470,13 +474,14 @@ isc_timer_touch(isc_timer_t *timer0) {
|
||||
|
||||
void
|
||||
isc_timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
|
||||
isc__timer_t *timer = (isc__timer_t *)timer0;
|
||||
isc__timer_t *timer;
|
||||
|
||||
/*
|
||||
* Attach *timerp to timer.
|
||||
*/
|
||||
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
REQUIRE(VALID_TIMER(timer0));
|
||||
timer = (isc__timer_t *)timer0;
|
||||
REQUIRE(timerp != NULL && *timerp == NULL);
|
||||
isc_refcount_increment(&timer->references);
|
||||
|
||||
@@ -661,8 +666,8 @@ static void
|
||||
set_index(void *what, unsigned int index) {
|
||||
isc__timer_t *timer;
|
||||
|
||||
REQUIRE(VALID_TIMER(what));
|
||||
timer = what;
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
|
||||
timer->index = index;
|
||||
}
|
||||
@@ -707,9 +712,10 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
|
||||
|
||||
void
|
||||
isc_timermgr_poke(isc_timermgr_t *manager0) {
|
||||
isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
|
||||
isc__timermgr_t *manager;
|
||||
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
REQUIRE(VALID_MANAGER(manager0));
|
||||
manager = (isc__timermgr_t *)manager0;
|
||||
|
||||
SIGNAL(&manager->wakeup);
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
* The last resort defaults: use all non well known port space
|
||||
*/
|
||||
#ifndef ISC_NET_PORTRANGELOW
|
||||
#define ISC_NET_PORTRANGELOW 1024
|
||||
#define ISC_NET_PORTRANGELOW 32768
|
||||
#endif /* ISC_NET_PORTRANGELOW */
|
||||
#ifndef ISC_NET_PORTRANGEHIGH
|
||||
#define ISC_NET_PORTRANGEHIGH 65535
|
||||
|
||||
+62
-57
@@ -132,6 +132,8 @@ 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) {
|
||||
@@ -1660,6 +1662,7 @@ 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;
|
||||
@@ -2212,38 +2215,34 @@ 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");
|
||||
|
||||
#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 tid = isc_nm_tid();
|
||||
if (tid < 0) {
|
||||
tid = isc_random_uniform(manager->ncpus);
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -2267,10 +2266,8 @@ 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);
|
||||
result = isc_task_create(mgr->taskmgr, 20, &client->task);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
get_clienttask(mgr, &client->task);
|
||||
|
||||
result = dns_message_create(client->mctx,
|
||||
DNS_MESSAGE_INTENTPARSE,
|
||||
&client->message);
|
||||
@@ -2397,21 +2394,18 @@ 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;
|
||||
|
||||
#if CLIENT_NMCTXS > 0
|
||||
for (i = 0; i < CLIENT_NMCTXS; i++) {
|
||||
if (manager->mctxpool[i] != NULL)
|
||||
isc_mem_detach(&manager->mctxpool[i]);
|
||||
for (i = 0; i < manager->ncpus * CLIENT_NMCTXS_PERCPU; i++) {
|
||||
isc_mem_detach(&manager->mctxpool[i]);
|
||||
}
|
||||
#endif
|
||||
isc_mem_put(manager->mctx, manager->mctxpool,
|
||||
manager->ncpus * CLIENT_NMCTXS_PERCPU * sizeof(isc_mem_t*));
|
||||
|
||||
if (manager->interface != NULL) {
|
||||
ns_interface_detach(&manager->interface);
|
||||
@@ -2422,14 +2416,22 @@ clientmgr_destroy(ns_clientmgr_t *manager) {
|
||||
|
||||
if (manager->excl != NULL)
|
||||
isc_task_detach(&manager->excl);
|
||||
|
||||
for (i = 0; i < CLIENT_NTASKS; i++) {
|
||||
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]);
|
||||
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,
|
||||
CLIENT_NTASKS * sizeof(isc_task_t *));
|
||||
manager->ncpus * CLIENT_NTASKS_PERCPU *
|
||||
sizeof(isc_task_t *));
|
||||
ns_server_detach(&manager->sctx);
|
||||
|
||||
isc_mem_put(manager->mctx, manager, sizeof(*manager));
|
||||
@@ -2438,13 +2440,12 @@ 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,
|
||||
ns_clientmgr_t **managerp)
|
||||
int ncpus, ns_clientmgr_t **managerp)
|
||||
{
|
||||
ns_clientmgr_t *manager;
|
||||
isc_result_t result;
|
||||
#if CLIENT_NMCTXS > 0
|
||||
int i;
|
||||
#endif
|
||||
int npools;
|
||||
|
||||
manager = isc_mem_get(mctx, sizeof(*manager));
|
||||
*manager = (ns_clientmgr_t) { .magic = 0 };
|
||||
@@ -2461,26 +2462,36 @@ 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;
|
||||
manager->taskpool =
|
||||
isc_mem_get(mctx, CLIENT_NTASKS*sizeof(isc_task_t *));
|
||||
for (i = 0; i < CLIENT_NTASKS; i++) {
|
||||
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[i] = NULL;
|
||||
isc_task_create(manager->taskmgr, 20, &manager->taskpool[i]);
|
||||
result = isc_task_create_bound(manager->taskmgr, 20,
|
||||
&manager->taskpool[i],
|
||||
i % manager->ncpus);
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
}
|
||||
isc_refcount_init(&manager->references, 1);
|
||||
manager->sctx = NULL;
|
||||
ns_server_attach(sctx, &manager->sctx);
|
||||
|
||||
ISC_LIST_INIT(manager->recursing);
|
||||
#if CLIENT_NMCTXS > 0
|
||||
manager->nextmctx = 0;
|
||||
for (i = 0; i < CLIENT_NMCTXS; i++)
|
||||
manager->mctxpool[i] = NULL; /* will be created on-demand */
|
||||
#endif
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
manager->magic = MANAGER_MAGIC;
|
||||
|
||||
MTRACE("create");
|
||||
@@ -2858,17 +2869,11 @@ 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;
|
||||
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_buffer_allocate(client->mctx, &dbuf, 1024);
|
||||
ISC_LIST_APPEND(client->query.namebufs, dbuf, link);
|
||||
|
||||
CTRACE("ns_client_newnamebuf: done");
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
#define NS_CLIENT_SEND_BUFFER_SIZE 4096
|
||||
#define NS_CLIENT_RECV_BUFFER_SIZE 4096
|
||||
|
||||
#define CLIENT_NMCTXS 100
|
||||
#define CLIENT_NMCTXS_PERCPU 8
|
||||
/*%<
|
||||
* 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 100
|
||||
#define CLIENT_NTASKS_PERCPU 16
|
||||
/*%<
|
||||
* Number of tasks to be used by clients - those are used only when recursing
|
||||
*/
|
||||
@@ -166,10 +166,13 @@ 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. */
|
||||
@@ -180,11 +183,8 @@ struct ns_clientmgr {
|
||||
isc_mutex_t reclock;
|
||||
client_list_t recursing; /*%< Recursing clients */
|
||||
|
||||
#if CLIENT_NMCTXS > 0
|
||||
/*%< mctx pool for clients. */
|
||||
unsigned int nextmctx;
|
||||
isc_mem_t * mctxpool[CLIENT_NMCTXS];
|
||||
#endif
|
||||
isc_mem_t ** mctxpool;
|
||||
};
|
||||
|
||||
/*% 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,
|
||||
isc_timermgr_t *timermgr, ns_interface_t *ifp, int ncpus,
|
||||
ns_clientmgr_t **managerp);
|
||||
/*%<
|
||||
* Create a client manager.
|
||||
|
||||
@@ -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,
|
||||
ns_interfacemgr_t **mgrp);
|
||||
int ncpus, ns_interfacemgr_t **mgrp);
|
||||
/*%<
|
||||
* Create a new interface manager.
|
||||
*
|
||||
|
||||
@@ -75,6 +75,7 @@ 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;
|
||||
@@ -181,6 +182,7 @@ 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;
|
||||
@@ -219,6 +221,7 @@ 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);
|
||||
@@ -425,7 +428,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,
|
||||
&ifp->clientmgr);
|
||||
mgr->ncpus, &ifp->clientmgr);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(IFMGR_COMMON_LOGARGS, ISC_LOG_ERROR,
|
||||
"ns_clientmgr_create() failed: %s",
|
||||
|
||||
+5
-9
@@ -7458,11 +7458,9 @@ query_dns64(query_ctx_t *qctx) {
|
||||
|
||||
isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr);
|
||||
|
||||
result = isc_buffer_allocate(client->mctx, &buffer,
|
||||
view->dns64cnt * 16 *
|
||||
dns_rdataset_count(qctx->rdataset));
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_buffer_allocate(client->mctx, &buffer,
|
||||
view->dns64cnt * 16 *
|
||||
dns_rdataset_count(qctx->rdataset));
|
||||
result = dns_message_gettemprdataset(client->message,
|
||||
&dns64_rdataset);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
@@ -7628,10 +7626,8 @@ query_filter64(query_ctx_t *qctx) {
|
||||
client->query.attributes &= ~NS_QUERYATTR_SECURE;
|
||||
}
|
||||
|
||||
result = isc_buffer_allocate(client->mctx, &buffer,
|
||||
16 * dns_rdataset_count(qctx->rdataset));
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_buffer_allocate(client->mctx, &buffer,
|
||||
16 * dns_rdataset_count(qctx->rdataset));
|
||||
result = dns_message_gettemprdataset(client->message, &myrdataset);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user