Compare commits

...
13 Commits
Author SHA1 Message Date
Witold Kręcicki b9808f6e5d Part2: don't attach/detach view 2019-05-16 18:16:40 +02:00
Witold Kręcicki d31fcfbbad Part1: make zt->references an isc_refcount_t 2019-05-16 18:14:55 +02:00
Witold Kręcicki 9be6f98c13 Test: Don't attach/detach qctx->view 2019-05-16 16:56:36 +02:00
Ondřej Surý e02228125e Merge branch 'ondrej/add-all-isc-atomic-defines' into 'master'
Add most useful relaxed and acquire-relase stdatomic convenience macros

See merge request isc-projects/bind9!1935
2019-05-13 03:03:17 -04:00
Ondřej Surý ab389695b0 Add most useful relaxed and acquire-relase stdatomic convenience macros
The header file <isc/atomic.h> now contains convenience macros for
most useful explicit memory ordering for C11 stdatomics, only relaxed
and acquire-release semantics is being used.  These macros SHOULD be
used instead of atomic_<func>_explicit functions.
2019-05-13 12:17:21 +07:00
Ondřej Surý 976d62aa23 Merge branch '899-remove-unspec' into 'master'
Remove UNSPEC rrtype

Closes #899

See merge request isc-projects/bind9!1931
2019-05-12 23:51:14 -04:00
Witold KręcickiandOndřej Surý a8e2ca6f7d Remove UNSPEC rrtype 2019-05-13 10:05:03 +07:00
Mark Andrews de49b26eb0 Merge branch '981-armv5-build-is-broken' into 'master'
Resolve "armv5 build is broken"

Closes #981

See merge request isc-projects/bind9!1892
2019-05-12 21:51:21 -04:00
Mark Andrews f546769b8b arm: just use the compiler's default yield support 2019-05-12 21:39:43 -04:00
Mark Andrews 9150e432aa Merge branch '984-remove-dead-code-in-pkcs11-keygen-c' into 'master'
Resolve "Remove dead code in pkcs11-keygen.c"

Closes #984

See merge request isc-projects/bind9!1814
2019-05-12 21:38:58 -04:00
Mark Andrews 2e4986e2c4 remove dead code and unnecessary call to pkcs_C_GetAttributeValue 2019-05-13 11:21:09 +10:00
Ondřej Surý 3ee94d7845 Merge branch '713-mem-benchmark' into 'master'
Add benchmark for isc_{mem,mempool}_{get,put} operations

Closes #713

See merge request isc-projects/bind9!1928
2019-05-10 17:20:26 -04:00
Ondřej Surý 7ec9502ec5 Add benchmark for isc_{mem,mempool}_{get,put} operations 2019-05-11 04:02:35 +07:00
21 changed files with 213 additions and 623 deletions
+3
View File
@@ -1,3 +1,6 @@
5234. [port] arm: just use the compiler's default support for
yield. [GL #981]
--- 9.15.0 released ---
5233. [bug] Negative trust anchors did not work with "forward only;"
-29
View File
@@ -72,35 +72,6 @@ These are platforms on which BIND 9.15 is known *not* to build or run:
## Platform quirks
### ARM
If the compilation ends with following error:
```
Error: selected processor does not support `yield' in ARM mode
```
You will need to set `-march` compiler option to `native`, so the compiler
recognizes `yield` assembler instruction. The proper way to set `-march=native`
would be to put it into `CFLAGS`, e.g. run `./configure` like this:
`CFLAGS="-march=native -Os -g" ./configure` plus your usual options.
If that doesn't work, you can enforce the minimum CPU and FPU (taken from Debian
armhf documentation):
* The lowest worthwhile CPU implementation is Armv7-A, therefore the recommended
build option is `-march=armv7-a`.
* FPU should be set at VFPv3-D16 as they represent the minimum specification of
the processors to support here, therefore the recommended build option is
`-mfpu=vfpv3-d16`.
The `configure` command should look like this:
```
CFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -Os -g" ./configure
```
### NetBSD 6 i386
The i386 build of NetBSD requires the `libatomic` library, available from
+1 -1
View File
@@ -9690,7 +9690,7 @@ get_matching_view(isc_netaddr_t *srcaddr, isc_netaddr_t *destaddr,
!(view->matchrecursiveonly &&
(message->flags & DNS_MESSAGEFLAG_RD) == 0))
{
dns_view_attach(view, viewp);
*viewp = view; // dns_view_attach(view, viewp);
return (ISC_R_SUCCESS);
}
}
+4 -47
View File
@@ -185,13 +185,13 @@ main(int argc, char *argv[]) {
isc_result_t result;
CK_RV rv;
CK_SLOT_ID slot = 0;
CK_MECHANISM mech, dpmech;
CK_MECHANISM mech;
CK_SESSION_HANDLE hSession;
char *lib_name = NULL;
char *pin = NULL;
CK_ULONG bits = 0;
CK_CHAR *label = NULL;
CK_OBJECT_HANDLE privatekey, publickey, domainparams;
CK_OBJECT_HANDLE privatekey, publickey;
CK_BYTE exponent[5];
CK_ULONG expsize = 0;
pk11_context_t pctx;
@@ -199,7 +199,6 @@ main(int argc, char *argv[]) {
int c, errflg = 0;
int hide = 1, quiet = 0;
int idlen = 0, id_offset = 0;
unsigned int i;
unsigned long id = 0;
CK_BYTE idbuf[4];
CK_ULONG ulObjectCount;
@@ -207,10 +206,7 @@ main(int argc, char *argv[]) {
{CKA_LABEL, NULL_PTR, 0}
};
CK_ATTRIBUTE *public_template = NULL;
CK_ATTRIBUTE *domain_template = NULL;
CK_ATTRIBUTE *param_template = NULL;
CK_ULONG public_attrcnt = 0, private_attrcnt = PRIVATE_ATTRS;
CK_ULONG domain_attrcnt = 0, param_attrcnt = 0;
key_class_t keyclass = key_rsa;
pk11_optype_t op_type = OP_ANY;
@@ -455,46 +451,6 @@ main(int argc, char *argv[]) {
private_template[5].pValue = &truevalue;
}
if (keyclass == key_rsa || keyclass == key_ecc || keyclass == key_ecx)
goto generate_keys;
/* Generate Domain parameters */
rv = pkcs_C_GenerateKey(hSession, &dpmech, domain_template,
domain_attrcnt, &domainparams);
if (rv != CKR_OK) {
fprintf(stderr,
"C_GenerateKey: Error = 0x%.8lX\n", rv);
error = 1;
goto exit_search;
}
/* Get Domain parameters */
rv = pkcs_C_GetAttributeValue(hSession, domainparams,
param_template, param_attrcnt);
if (rv != CKR_OK) {
fprintf(stderr,
"C_GetAttributeValue0: Error = 0x%.8lX\n", rv);
error = 1;
goto exit_search;
}
/* Allocate space for parameter attributes */
for (i = 0; i < param_attrcnt; i++) {
param_template[i].pValue = NULL;
}
for (i = 0; i < param_attrcnt; i++) {
param_template[i].pValue = malloc(param_template[i].ulValueLen);
if (param_template[i].pValue == NULL) {
fprintf(stderr, "malloc failed\n");
error = 1;
goto exit_search;
}
}
generate_keys:
/* Generate Key pair for signing/verifying */
rv = pkcs_C_GenerateKeyPair(hSession, &mech,
public_template, public_attrcnt,
@@ -504,8 +460,9 @@ main(int argc, char *argv[]) {
if (rv != CKR_OK) {
fprintf(stderr, "C_GenerateKeyPair: Error = 0x%.8lX\n", rv);
error = 1;
} else if (!quiet)
} else if (!quiet) {
printf("Key pair generation complete.\n");
}
exit_search:
rv = pkcs_C_FindObjectsFinal(hSession);
+2 -1
View File
@@ -390,7 +390,8 @@ uid01 UID \# 1 02
; type 102 (GID - not implemented by BIND - unknown record format only)
gid01 GID \# 1 03
; type 103 (UNSPEC - XXXMUKS TODO - this has some weird encoding - see btoa_totext())
; type 103 (UNSPEC - not implemented by BIND - unknown record format only)
unspec01 UNSPEC \# 1 04
; type 104
nid NID 10 0014:4fff:ff20:ee64
+1
View File
@@ -52,6 +52,7 @@ eid01.example. 3600 IN EID 1289AB
eui48.example. 3600 IN EUI48 01-23-45-67-89-ab
eui64.example. 3600 IN EUI64 01-23-45-67-89-ab-cd-ef
gid01.example. 3600 IN GID \# 1 03
unspec01.example. 3600 IN UNSPEC \# 1 04
gpos01.example. 3600 IN GPOS "-22.6882" "116.8652" "250.0"
gpos02.example. 3600 IN GPOS "" "" ""
hinfo01.example. 3600 IN HINFO "Generic PC clone" "NetBSD-1.4"
+1
View File
@@ -52,6 +52,7 @@ eid01.example. 3600 IN EID 1289AB
eui48.example. 3600 IN EUI48 01-23-45-67-89-ab
eui64.example. 3600 IN EUI64 01-23-45-67-89-ab-cd-ef
gid01.example. 3600 IN GID \# 1 03
unspec01.example. 3600 IN UNSPEC \# 1 04
gpos01.example. 3600 IN GPOS "-22.6882" "116.8652" "250.0"
gpos02.example. 3600 IN GPOS "" "" ""
hinfo01.example. 3600 IN HINFO "Generic PC clone" "NetBSD-1.4"
+3
View File
@@ -45,6 +45,9 @@
/* Define to 1 if you have the `arc4random_uniform' function. */
#undef HAVE_ARC4RANDOM_UNIFORM
/* define if the ARM yield instruction is available */
#undef HAVE_ARM_YIELD
/* Define to 1 if the compiler supports __builtin_clz. */
#undef HAVE_BUILTIN_CLZ
Vendored
+7 -5
View File
@@ -13831,17 +13831,15 @@ $as_echo "#define FLEXIBLE_ARRAY_MEMBER /**/" >>confdefs.h
#
case $host in #(
arm*) :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for yield instruction support" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for yield instruction support" >&5
$as_echo_n "checking for yield instruction support... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
__asm__ __volatile__ ("yield")
;
return 0;
}
@@ -13849,8 +13847,12 @@ _ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE_ARM_YIELD 1" >>confdefs.h
else
as_fn_error $? "no, try adding -march=native or -march=armv7-a to CFLAGS (see PLATFORMS.md for more information)" "$LINENO" 5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; #(
*) :
+9 -9
View File
@@ -424,15 +424,15 @@ AC_C_FLEXIBLE_ARRAY_MEMBER
# Check for yield support on ARM processors
#
AS_CASE([$host],
[arm*],[
AC_MSG_CHECKING([for yield instruction support])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[]],
[[__asm__ __volatile__ ("yield")]]
)],
[AC_MSG_RESULT([yes])],
[AC_MSG_ERROR([no, try adding -march=native or -march=armv7-a to CFLAGS (see PLATFORMS.md for more information)])])])
[arm*],
[AC_MSG_CHECKING([for yield instruction support])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]],
[[__asm__ __volatile__ ("yield")]])],
[AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_ARM_YIELD], [1],
[define if the ARM yield instruction is available])],
[AC_MSG_RESULT([no])])])
AC_CHECK_FUNCS([sysctlbyname])
+1
View File
@@ -771,6 +771,7 @@ main(int argc, char **argv) {
insert_into_typenames(100, "uinfo", RESERVEDNAME);
insert_into_typenames(101, "uid", RESERVEDNAME);
insert_into_typenames(102, "gid", RESERVEDNAME);
insert_into_typenames(103, "unspec", RESERVEDNAME);
insert_into_typenames(251, "ixfr", METAQUESTIONONLY);
insert_into_typenames(252, "axfr", METAQUESTIONONLY);
insert_into_typenames(253, "mailb", METAQUESTIONONLY);
-278
View File
@@ -189,12 +189,6 @@ hexvalue(char value);
static int
decvalue(char value);
static isc_result_t
btoa_totext(unsigned char *inbuf, int inbuflen, isc_buffer_t *target);
static isc_result_t
atob_tobuffer(isc_lex_t *lexer, isc_buffer_t *target);
static void
default_fromtext_callback(dns_rdatacallbacks_t *callbacks, const char *, ...)
ISC_FORMAT_PRINTF(2, 3);
@@ -1869,278 +1863,6 @@ decvalue(char value) {
return (int)(s - decdigits);
}
static const char atob_digits[86] =
"!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" \
"abcdefghijklmnopqrstu";
/*
* Subroutines to convert between 8 bit binary bytes and printable ASCII.
* Computes the number of bytes, and three kinds of simple checksums.
* Incoming bytes are collected into 32-bit words, then printed in base 85:
* exp(85,5) > exp(2,32)
* The ASCII characters used are between '!' and 'u';
* 'z' encodes 32-bit zero; 'x' is used to mark the end of encoded data.
*
* Originally by Paul Rutter (philabs!per) and Joe Orost (petsd!joe) for
* the atob/btoa programs, released with the compress program, in mod.sources.
* Modified by Mike Schwartz 8/19/86 for use in BIND.
* Modified to be re-entrant 3/2/99.
*/
struct state {
int32_t Ceor;
int32_t Csum;
int32_t Crot;
int32_t word;
int32_t bcount;
};
#define Ceor state->Ceor
#define Csum state->Csum
#define Crot state->Crot
#define word state->word
#define bcount state->bcount
#define times85(x) ((((((x<<2)+x)<<2)+x)<<2)+x)
static isc_result_t byte_atob(int c, isc_buffer_t *target,
struct state *state);
static isc_result_t putbyte(int c, isc_buffer_t *, struct state *state);
static isc_result_t byte_btoa(int c, isc_buffer_t *, struct state *state);
/*
* Decode ASCII-encoded byte c into binary representation and
* place into *bufp, advancing bufp.
*/
static isc_result_t
byte_atob(int c, isc_buffer_t *target, struct state *state) {
const char *s;
if (c == 'z') {
if (bcount != 0)
return(DNS_R_SYNTAX);
else {
RETERR(putbyte(0, target, state));
RETERR(putbyte(0, target, state));
RETERR(putbyte(0, target, state));
RETERR(putbyte(0, target, state));
}
} else if ((s = strchr(atob_digits, c)) != NULL) {
if (bcount == 0) {
word = (int32_t)(s - atob_digits);
++bcount;
} else if (bcount < 4) {
word = times85(word);
word += (int32_t)(s - atob_digits);
++bcount;
} else {
word = times85(word);
word += (int32_t)(s - atob_digits);
RETERR(putbyte((word >> 24) & 0xff, target, state));
RETERR(putbyte((word >> 16) & 0xff, target, state));
RETERR(putbyte((word >> 8) & 0xff, target, state));
RETERR(putbyte(word & 0xff, target, state));
word = 0;
bcount = 0;
}
} else
return(DNS_R_SYNTAX);
return(ISC_R_SUCCESS);
}
/*
* Compute checksum info and place c into target.
*/
static isc_result_t
putbyte(int c, isc_buffer_t *target, struct state *state) {
isc_region_t tr;
Ceor ^= c;
Csum += c;
Csum += 1;
if ((Crot & 0x80000000)) {
Crot <<= 1;
Crot += 1;
} else {
Crot <<= 1;
}
Crot += c;
isc_buffer_availableregion(target, &tr);
if (tr.length < 1)
return (ISC_R_NOSPACE);
tr.base[0] = c;
isc_buffer_add(target, 1);
return (ISC_R_SUCCESS);
}
/*
* Read the ASCII-encoded data from inbuf, of length inbuflen, and convert
* it into T_UNSPEC (binary data) in outbuf, not to exceed outbuflen bytes;
* outbuflen must be divisible by 4. (Note: this is because outbuf is filled
* in 4 bytes at a time. If the actual data doesn't end on an even 4-byte
* boundary, there will be no problem...it will be padded with 0 bytes, and
* numbytes will indicate the correct number of bytes. The main point is
* that since the buffer is filled in 4 bytes at a time, even if there is
* not a full 4 bytes of data at the end, there has to be room to 0-pad the
* data, so the buffer must be of size divisible by 4). Place the number of
* output bytes in numbytes, and return a failure/success status.
*/
static isc_result_t
atob_tobuffer(isc_lex_t *lexer, isc_buffer_t *target) {
long oeor, osum, orot;
struct state statebuf, *state= &statebuf;
isc_token_t token;
char c;
char *e;
Ceor = Csum = Crot = word = bcount = 0;
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
false));
while (token.value.as_textregion.length != 0) {
if ((c = token.value.as_textregion.base[0]) == 'x') {
break;
} else
RETERR(byte_atob(c, target, state));
isc_textregion_consume(&token.value.as_textregion, 1);
}
/*
* Number of bytes.
*/
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
false));
if ((token.value.as_ulong % 4) != 0U) {
unsigned long padding = 4 - (token.value.as_ulong % 4);
if (isc_buffer_usedlength(target) < padding)
return (DNS_R_SYNTAX);
isc_buffer_subtract(target, padding);
}
/*
* Checksum.
*/
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
false));
oeor = strtol(DNS_AS_STR(token), &e, 16);
if (*e != 0)
return (DNS_R_SYNTAX);
/*
* Checksum.
*/
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
false));
osum = strtol(DNS_AS_STR(token), &e, 16);
if (*e != 0)
return (DNS_R_SYNTAX);
/*
* Checksum.
*/
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
false));
orot = strtol(DNS_AS_STR(token), &e, 16);
if (*e != 0)
return (DNS_R_SYNTAX);
if ((oeor != Ceor) || (osum != Csum) || (orot != Crot))
return(DNS_R_BADCKSUM);
return (ISC_R_SUCCESS);
}
/*
* Encode binary byte c into ASCII representation and place into *bufp,
* advancing bufp.
*/
static isc_result_t
byte_btoa(int c, isc_buffer_t *target, struct state *state) {
isc_region_t tr;
isc_buffer_availableregion(target, &tr);
Ceor ^= c;
Csum += c;
Csum += 1;
if ((Crot & 0x80000000)) {
Crot <<= 1;
Crot += 1;
} else {
Crot <<= 1;
}
Crot += c;
word <<= 8;
word |= c;
if (bcount == 3) {
if (word == 0) {
if (tr.length < 1)
return (ISC_R_NOSPACE);
tr.base[0] = 'z';
isc_buffer_add(target, 1);
} else {
register int tmp = 0;
register int32_t tmpword = word;
if (tmpword < 0) {
/*
* Because some don't support u_long.
*/
tmp = 32;
tmpword -= (int32_t)(85 * 85 * 85 * 85 * 32);
}
if (tmpword < 0) {
tmp = 64;
tmpword -= (int32_t)(85 * 85 * 85 * 85 * 32);
}
if (tr.length < 5)
return (ISC_R_NOSPACE);
tr.base[0] = atob_digits[(tmpword /
(int32_t)(85 * 85 * 85 * 85))
+ tmp];
tmpword %= (int32_t)(85 * 85 * 85 * 85);
tr.base[1] = atob_digits[tmpword / (85 * 85 * 85)];
tmpword %= (85 * 85 * 85);
tr.base[2] = atob_digits[tmpword / (85 * 85)];
tmpword %= (85 * 85);
tr.base[3] = atob_digits[tmpword / 85];
tmpword %= 85;
tr.base[4] = atob_digits[tmpword];
isc_buffer_add(target, 5);
}
bcount = 0;
} else {
bcount += 1;
}
return (ISC_R_SUCCESS);
}
/*
* Encode the binary data from inbuf, of length inbuflen, into a
* target. Return success/failure status
*/
static isc_result_t
btoa_totext(unsigned char *inbuf, int inbuflen, isc_buffer_t *target) {
int inc;
struct state statebuf, *state = &statebuf;
char buf[sizeof("x 2000000000 ffffffff ffffffff ffffffff")];
Ceor = Csum = Crot = word = bcount = 0;
for (inc = 0; inc < inbuflen; inbuf++, inc++)
RETERR(byte_btoa(*inbuf, target, state));
while (bcount != 0)
RETERR(byte_btoa(0, target, state));
/*
* Put byte count and checksum information at end of buffer,
* delimited by 'x'
*/
snprintf(buf, sizeof(buf), "x %d %x %x %x", inbuflen, Ceor, Csum, Crot);
return (str_totext(buf, target));
}
static void
default_fromtext_callback(dns_rdatacallbacks_t *callbacks, const char *fmt,
...)
-187
View File
@@ -1,187 +0,0 @@
/*
* 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.
*/
#ifndef RDATA_GENERIC_UNSPEC_103_C
#define RDATA_GENERIC_UNSPEC_103_C
#define RRTYPE_UNSPEC_ATTRIBUTES (0)
static inline isc_result_t
fromtext_unspec(ARGS_FROMTEXT) {
REQUIRE(type == dns_rdatatype_unspec);
UNUSED(type);
UNUSED(rdclass);
UNUSED(origin);
UNUSED(options);
UNUSED(callbacks);
return (atob_tobuffer(lexer, target));
}
static inline isc_result_t
totext_unspec(ARGS_TOTEXT) {
REQUIRE(rdata->type == dns_rdatatype_unspec);
UNUSED(tctx);
return (btoa_totext(rdata->data, rdata->length, target));
}
static inline isc_result_t
fromwire_unspec(ARGS_FROMWIRE) {
isc_region_t sr;
REQUIRE(type == dns_rdatatype_unspec);
UNUSED(type);
UNUSED(rdclass);
UNUSED(dctx);
UNUSED(options);
isc_buffer_activeregion(source, &sr);
isc_buffer_forward(source, sr.length);
return (mem_tobuffer(target, sr.base, sr.length));
}
static inline isc_result_t
towire_unspec(ARGS_TOWIRE) {
REQUIRE(rdata->type == dns_rdatatype_unspec);
UNUSED(cctx);
return (mem_tobuffer(target, rdata->data, rdata->length));
}
static inline int
compare_unspec(ARGS_COMPARE) {
isc_region_t r1;
isc_region_t r2;
REQUIRE(rdata1->type == rdata2->type);
REQUIRE(rdata1->rdclass == rdata2->rdclass);
REQUIRE(rdata1->type == dns_rdatatype_unspec);
dns_rdata_toregion(rdata1, &r1);
dns_rdata_toregion(rdata2, &r2);
return (isc_region_compare(&r1, &r2));
}
static inline isc_result_t
fromstruct_unspec(ARGS_FROMSTRUCT) {
dns_rdata_unspec_t *unspec = source;
REQUIRE(type == dns_rdatatype_unspec);
REQUIRE(source != NULL);
REQUIRE(unspec->common.rdtype == type);
REQUIRE(unspec->common.rdclass == rdclass);
REQUIRE(unspec->data != NULL || unspec->datalen == 0);
UNUSED(type);
UNUSED(rdclass);
return (mem_tobuffer(target, unspec->data, unspec->datalen));
}
static inline isc_result_t
tostruct_unspec(ARGS_TOSTRUCT) {
dns_rdata_unspec_t *unspec = target;
isc_region_t r;
REQUIRE(rdata->type == dns_rdatatype_unspec);
REQUIRE(target != NULL);
unspec->common.rdclass = rdata->rdclass;
unspec->common.rdtype = rdata->type;
ISC_LINK_INIT(&unspec->common, link);
dns_rdata_toregion(rdata, &r);
unspec->datalen = r.length;
unspec->data = mem_maybedup(mctx, r.base, r.length);
if (unspec->data == NULL)
return (ISC_R_NOMEMORY);
unspec->mctx = mctx;
return (ISC_R_SUCCESS);
}
static inline void
freestruct_unspec(ARGS_FREESTRUCT) {
dns_rdata_unspec_t *unspec = source;
REQUIRE(source != NULL);
REQUIRE(unspec->common.rdtype == dns_rdatatype_unspec);
if (unspec->mctx == NULL)
return;
if (unspec->data != NULL)
isc_mem_free(unspec->mctx, unspec->data);
unspec->mctx = NULL;
}
static inline isc_result_t
additionaldata_unspec(ARGS_ADDLDATA) {
REQUIRE(rdata->type == dns_rdatatype_unspec);
UNUSED(rdata);
UNUSED(add);
UNUSED(arg);
return (ISC_R_SUCCESS);
}
static inline isc_result_t
digest_unspec(ARGS_DIGEST) {
isc_region_t r;
REQUIRE(rdata->type == dns_rdatatype_unspec);
dns_rdata_toregion(rdata, &r);
return ((digest)(arg, &r));
}
static inline bool
checkowner_unspec(ARGS_CHECKOWNER) {
REQUIRE(type == dns_rdatatype_unspec);
UNUSED(name);
UNUSED(type);
UNUSED(rdclass);
UNUSED(wildcard);
return (true);
}
static inline bool
checknames_unspec(ARGS_CHECKNAMES) {
REQUIRE(rdata->type == dns_rdatatype_unspec);
UNUSED(rdata);
UNUSED(owner);
UNUSED(bad);
return (true);
}
static inline int
casecompare_unspec(ARGS_COMPARE) {
return (compare_unspec(rdata1, rdata2));
}
#endif /* RDATA_GENERIC_UNSPEC_103_C */
-24
View File
@@ -1,24 +0,0 @@
/*
* 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.
*/
/* */
#ifndef GENERIC_UNSPEC_103_H
#define GENERIC_UNSPEC_103_H 1
typedef struct dns_rdata_unspec_t {
dns_rdatacommon_t common;
isc_mem_t *mctx;
unsigned char *data;
uint16_t datalen;
} dns_rdata_unspec_t;
#endif /* GENERIC_UNSPEC_103_H */
+9 -30
View File
@@ -47,7 +47,7 @@ struct dns_zt {
struct zt_load_params *loadparams;
/* Locked by lock. */
bool flush;
uint32_t references;
isc_refcount_t references;
unsigned int loads_pending;
dns_rbt_t *table;
};
@@ -93,7 +93,7 @@ dns_zt_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_zt_t **ztp) {
zt->mctx = NULL;
isc_mem_attach(mctx, &zt->mctx);
zt->references = 1;
isc_refcount_init(&zt->references, 1);
zt->flush = false;
zt->rdclass = rdclass;
zt->magic = ZTMAGIC;
@@ -209,14 +209,8 @@ dns_zt_attach(dns_zt_t *zt, dns_zt_t **ztp) {
REQUIRE(VALID_ZT(zt));
REQUIRE(ztp != NULL && *ztp == NULL);
RWLOCK(&zt->rwlock, isc_rwlocktype_write);
INSIST(zt->references > 0);
zt->references++;
INSIST(zt->references != 0);
RWUNLOCK(&zt->rwlock, isc_rwlocktype_write);
isc_refcount_increment(&zt->references);
*ztp = zt;
}
@@ -244,20 +238,9 @@ zt_flushanddetach(dns_zt_t **ztp, bool need_flush) {
REQUIRE(ztp != NULL && VALID_ZT(*ztp));
zt = *ztp;
RWLOCK(&zt->rwlock, isc_rwlocktype_write);
INSIST(zt->references > 0);
zt->references--;
if (zt->references == 0)
destroy = true;
if (need_flush)
zt->flush = true;
RWUNLOCK(&zt->rwlock, isc_rwlocktype_write);
if (destroy)
if (isc_refcount_decrement(&zt->references) == 1) {
zt_destroy(zt);
}
*ztp = NULL;
}
@@ -340,15 +323,13 @@ asyncload(dns_zone_t *zone, void *zt_) {
isc_result_t result;
struct dns_zt *zt = (dns_zt_t*) zt_;
REQUIRE(zone != NULL);
INSIST(zt->references > 0);
zt->references++;
isc_refcount_increment(&zt->references);
zt->loads_pending++;
result = dns_zone_asyncload(zone, zt->loadparams->newonly, *zt->loadparams->dl, zt);
if (result != ISC_R_SUCCESS) {
zt->references--;
isc_refcount_decrement(&zt->references);
zt->loads_pending--;
INSIST(zt->references > 0);
}
return (ISC_R_SUCCESS);
}
@@ -548,9 +529,7 @@ doneloading(dns_zt_t *zt, dns_zone_t *zone, isc_task_t *task) {
RWLOCK(&zt->rwlock, isc_rwlocktype_write);
INSIST(zt->loads_pending != 0);
INSIST(zt->references != 0);
zt->references--;
if (zt->references == 0)
if (isc_refcount_decrement(&zt->references) == 1)
destroy = true;
zt->loads_pending--;
if (zt->loads_pending == 0) {
+33 -4
View File
@@ -21,7 +21,36 @@
* We define a few additional macros to make things easier
*/
#define atomic_store_relaxed(o, v) atomic_store_explicit((o), \
(v), \
memory_order_relaxed)
#define atomic_load_relaxed(o) atomic_load_explicit((o), memory_order_relaxed)
/* Relaxed Memory Ordering */
#define atomic_store_relaxed(o, v) \
atomic_store_explicit((o), (v), memory_order_relaxed)
#define atomic_load_relaxed(o) \
atomic_load_explicit((o), memory_order_relaxed)
#define atomic_fetch_add_relaxed(o, v) \
atomic_fetch_add_explicit((o), (v), memory_order_relaxed)
#define atomic_fetch_sub_relaxed(o, v) \
atomic_fetch_sub_explicit((o), (v), memory_order_relaxed)
#define atomic_exchange_relaxed(o, v) \
atomic_exchange_explicit((o), (v), memory_order_relaxed)
#define atomic_compare_exchange_weak_relaxed(o, e, d) \
atomic_compare_exchange_weak_explicit((o), (e), (d), \
memory_order_relaxed, \
memory_order_relaxed)
/* Acquire-Release Memory Ordering */
#define atomic_store_release(o, v) \
atomic_store_explicit((o), (v), memory_order_release)
#define atomic_load_acquire(o) \
atomic_load_explicit((o), memory_order_acquire)
#define atomic_fetch_add_acquire(o, v) \
atomic_fetch_add_explicit((o), (v), memory_order_acquire)
#define atomic_fetch_sub_release(o, v) \
atomic_fetch_sub_explicit((o), (v), memory_order_release)
#define atomic_exchange_acq_rel(o, v) \
atomic_exchange_explicit((o), (v), memory_order_acq_rel)
#define atomic_compare_exchange_weak_acq_rel(o, e, d) \
atomic_compare_exchange_weak_explicit((o), (e), (d), \
memory_order_acq_rel, \
memory_order_acquire)
+1 -1
View File
@@ -52,7 +52,7 @@
# define isc_rwlock_pause() __asm__ __volatile__ ("rep; nop")
#elif defined(__ia64__)
# define isc_rwlock_pause() __asm__ __volatile__ ("hint @pause")
#elif defined(__arm__)
#elif defined(__arm__) && HAVE_ARM_YIELD
# define isc_rwlock_pause() __asm__ __volatile__ ("yield")
#elif defined(sun) && (defined(__sparc) || defined(__sparc__))
# define isc_rwlock_pause() smt_pause()
+131
View File
@@ -24,10 +24,14 @@
#include <isc/file.h>
#include <isc/mem.h>
#include <isc/mutex.h>
#include <isc/os.h>
#include <isc/print.h>
#include <isc/result.h>
#include <isc/stdio.h>
#include <isc/util.h>
#include <isc/thread.h>
#include <isc/time.h>
#include "../mem_p.h"
@@ -422,6 +426,129 @@ isc_mem_traceflag_test(void **state) {
}
#endif
#define ITERS 512
#define NUM_ITEMS 1024 //768
#define ITEM_SIZE 65534
static void *
mem_thread(void *arg) {
void *items[NUM_ITEMS];
size_t size = *((size_t *)arg);
for (int i = 0; i < ITERS; i++) {
for (int j = 0; j < NUM_ITEMS; j++) {
items[j] = isc_mem_get(mctx, size);
}
for (int j = 0; j < NUM_ITEMS; j++) {
isc_mem_put(mctx, items[j], size);
}
}
return (NULL);
}
static void
isc_mem_benchmark(void **state) {
int nthreads = ISC_MAX(ISC_MIN(isc_os_ncpus(), 32), 1);
isc_thread_t threads[32];
isc_time_t ts1, ts2;
double t;
isc_result_t result;
size_t size = ITEM_SIZE;
UNUSED(state);
result = isc_time_now(&ts1);
assert_int_equal(result, ISC_R_SUCCESS);
for (int i = 0; i < nthreads; i++) {
result = isc_thread_create(mem_thread, &size, &threads[i]);
assert_int_equal(result, ISC_R_SUCCESS);
size = size / 2;
}
for (int i = 0; i < nthreads; i++) {
result = isc_thread_join(threads[i], NULL);
assert_int_equal(result, ISC_R_SUCCESS);
}
result = isc_time_now(&ts2);
assert_int_equal(result, ISC_R_SUCCESS);
t = isc_time_microdiff(&ts2, &ts1);
printf("[ TIME ] isc_mem_benchmark: "
"%d isc_mem_{get,put} calls, %f seconds, %f calls/second\n",
nthreads * ITERS * NUM_ITEMS, t / 1000000.0,
(nthreads * ITERS * NUM_ITEMS) / (t / 1000000.0));
}
static void *
mempool_thread(void *arg) {
isc_mempool_t *mp = (isc_mempool_t *)arg;
void *items[NUM_ITEMS];
for (int i = 0; i < ITERS; i++) {
for (int j = 0; j < NUM_ITEMS; j++) {
items[j] = isc_mempool_get(mp);
}
for (int j = 0; j < NUM_ITEMS; j++) {
isc_mempool_put(mp, items[j]);
}
}
return (NULL);
}
static void
isc_mempool_benchmark(void **state) {
int nthreads = ISC_MAX(ISC_MIN(isc_os_ncpus(), 32), 1);
isc_thread_t threads[32];
isc_time_t ts1, ts2;
double t;
isc_result_t result;
size_t size = ITEM_SIZE;
isc_mempool_t *mp = NULL;
isc_mutex_t mplock;
isc_mutex_init(&mplock);
result = isc_mempool_create(mctx, ITEM_SIZE, &mp);
assert_int_equal(result, ISC_R_SUCCESS);
isc_mempool_associatelock(mp, &mplock);
isc_mempool_setfreemax(mp, 32768);
isc_mempool_setfillcount(mp, ISC_MAX(NUM_ITEMS / nthreads, 1));
UNUSED(state);
result = isc_time_now(&ts1);
assert_int_equal(result, ISC_R_SUCCESS);
for (int i = 0; i < nthreads; i++) {
result = isc_thread_create(mempool_thread, mp, &threads[i]);
assert_int_equal(result, ISC_R_SUCCESS);
size = size / 2;
}
for (int i = 0; i < nthreads; i++) {
result = isc_thread_join(threads[i], NULL);
assert_int_equal(result, ISC_R_SUCCESS);
}
result = isc_time_now(&ts2);
assert_int_equal(result, ISC_R_SUCCESS);
t = isc_time_microdiff(&ts2, &ts1);
printf("[ TIME ] isc_mempool_benchmark: "
"%d isc_mempool_{get,put} calls, %f seconds, %f calls/second\n",
nthreads * ITERS * NUM_ITEMS, t / 1000000.0,
(nthreads * ITERS * NUM_ITEMS) / (t / 1000000.0));
isc_mempool_destroy(&mp);
isc_mutex_destroy(&mplock);
}
/*
* Main
*/
@@ -444,6 +571,10 @@ main(void) {
cmocka_unit_test_setup_teardown(isc_mem_traceflag_test,
_setup, _teardown),
#endif
cmocka_unit_test_setup_teardown(isc_mem_benchmark,
_setup, _teardown),
cmocka_unit_test_setup_teardown(isc_mempool_benchmark,
_setup, _teardown),
};
return (cmocka_run_group_tests(tests, NULL, NULL));
+6 -3
View File
@@ -462,8 +462,10 @@ exit_check(ns_client_t *client) {
* Keep the view attached until any outstanding updates complete.
*/
if (client->nupdates == 0 &&
client->newstate == NS_CLIENTSTATE_FREED && client->view != NULL)
dns_view_detach(&client->view);
client->newstate == NS_CLIENTSTATE_FREED && client->view != NULL) {
client->view = NULL;
// dns_view_detach(&client->view);
}
if (client->state == NS_CLIENTSTATE_WORKING ||
client->state == NS_CLIENTSTATE_RECURSING)
@@ -893,7 +895,8 @@ ns_client_endrequest(ns_client_t *client) {
dns_adb_flush(client->view->adb);
}
#endif
dns_view_detach(&client->view);
// dns_view_detach(&client->view);
client->view = NULL;
}
if (client->opt != NULL) {
INSIST(dns_rdataset_isassociated(client->opt));
+1 -2
View File
@@ -4973,7 +4973,7 @@ qctx_init(ns_client_t *client, dns_fetchevent_t *event,
/* Set this first so CCTRACE will work */
qctx->client = client;
dns_view_attach(client->view, &qctx->view);
qctx->view = client->view;
CCTRACE(ISC_LOG_DEBUG(3), "qctx_init");
@@ -5049,7 +5049,6 @@ static void
qctx_destroy(query_ctx_t *qctx) {
CALL_HOOK_NORETURN(NS_QUERY_QCTX_DESTROYED, qctx);
dns_view_detach(&qctx->view);
if (qctx->detach_client) {
ns_client_detach(&qctx->client);
}
-2
View File
@@ -1907,8 +1907,6 @@
./lib/dns/rdata/generic/tlsa_52.h C 2012,2014,2016,2018,2019
./lib/dns/rdata/generic/txt_16.c C 1998,1999,2000,2001,2002,2004,2007,2008,2009,2012,2014,2015,2016,2018,2019
./lib/dns/rdata/generic/txt_16.h C 1998,1999,2000,2001,2004,2005,2007,2016,2018,2019
./lib/dns/rdata/generic/unspec_103.c C 1999,2000,2001,2002,2004,2007,2009,2015,2016,2018,2019
./lib/dns/rdata/generic/unspec_103.h C 1999,2000,2001,2004,2005,2007,2016,2018,2019
./lib/dns/rdata/generic/uri_256.c C 2011,2012,2014,2015,2016,2017,2018,2019
./lib/dns/rdata/generic/uri_256.h C 2011,2012,2016,2018,2019
./lib/dns/rdata/generic/x25_19.c C 1999,2000,2001,2002,2004,2005,2007,2009,2014,2015,2016,2018,2019