From b1fd8ee3ad940a2e38bbc857098f067cedbd427a Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 15 Dec 2015 19:49:40 +1100 Subject: [PATCH] 4281. [bug] Teach dns_message_totext about BADCOOKIE. [RT #41257] (cherry picked from commit f647c0df9fd334b19a5bdc9c252f90d94c0abf1e) Conflicts: CHANGES bin/named/query.c bin/tests/system/sit/tests.sh lib/dns/message.c (cherry picked from commit d090709551d9fe975125c9ed5fb457d71d583003) Conflicts: CHANGES --- CHANGES | 2 ++ bin/named/query.c | 2 +- lib/dns/message.c | 34 ++++++---------------------------- lib/dns/rcode.c | 10 +++++++++- 4 files changed, 18 insertions(+), 30 deletions(-) diff --git a/CHANGES b/CHANGES index 5f00f5127f..99b2763093 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +4281. [bug] Teach dns_message_totext about BADCOOKIE. [RT #41257] + 4277. [performance] Improve performance of the RBT, the central zone datastructure: The aux hashtable was improved, hash function was updated to perform more diff --git a/bin/named/query.c b/bin/named/query.c index 11403331d8..01fbdae6bf 100644 --- a/bin/named/query.c +++ b/bin/named/query.c @@ -6073,7 +6073,7 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype) inc_stats(client, dns_nsstatscounter_rateslipped); client->message->flags |= - DNS_MESSAGEFLAG_TC; + DNS_MESSAGEFLAG_TC; if (resp_result == DNS_R_NXDOMAIN) client->message->rcode = dns_rcode_nxdomain; diff --git a/lib/dns/message.c b/lib/dns/message.c index d4def431a1..0b7aa693da 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -145,27 +146,6 @@ static const char *opcodetext[] = { "RESERVED15" }; -static const char *rcodetext[] = { - "NOERROR", - "FORMERR", - "SERVFAIL", - "NXDOMAIN", - "NOTIMP", - "REFUSED", - "YXDOMAIN", - "YXRRSET", - "NXRRSET", - "NOTAUTH", - "NOTZONE", - "RESERVED11", - "RESERVED12", - "RESERVED13", - "RESERVED14", - "RESERVED15", - "BADVERS" -}; - - /*% * "helper" type, which consists of a block of some type, and is linkable. * For it to work, sizeof(dns_msgblock_t) must be a multiple of the pointer @@ -3396,7 +3376,8 @@ dns_message_pseudosectiontotext(dns_message_t *msg, isc_result_t dns_message_totext(dns_message_t *msg, const dns_master_style_t *style, - dns_messagetextflag_t flags, isc_buffer_t *target) { + dns_messagetextflag_t flags, isc_buffer_t *target) +{ char buf[sizeof("1234567890")]; isc_result_t result; @@ -3407,12 +3388,9 @@ dns_message_totext(dns_message_t *msg, const dns_master_style_t *style, ADD_STRING(target, ";; ->>HEADER<<- opcode: "); ADD_STRING(target, opcodetext[msg->opcode]); ADD_STRING(target, ", status: "); - if (msg->rcode < (sizeof(rcodetext)/sizeof(rcodetext[0]))) { - ADD_STRING(target, rcodetext[msg->rcode]); - } else { - snprintf(buf, sizeof(buf), "%4u", msg->rcode); - ADD_STRING(target, buf); - } + result = dns_rcode_totext(msg->rcode, target); + if (result != ISC_R_SUCCESS) + return (result); ADD_STRING(target, ", id: "); snprintf(buf, sizeof(buf), "%6u", msg->id); ADD_STRING(target, buf); diff --git a/lib/dns/rcode.c b/lib/dns/rcode.c index 2fdb751e6d..fac86d977c 100644 --- a/lib/dns/rcode.c +++ b/lib/dns/rcode.c @@ -49,6 +49,8 @@ #define NUMBERSIZE sizeof("037777777777") /* 2^32-1 octal + NUL */ +#define TOTEXTONLY 0x01 + #define RCODENAMES \ /* standard rcodes */ \ { dns_rcode_noerror, "NOERROR", 0}, \ @@ -61,7 +63,12 @@ { dns_rcode_yxrrset, "YXRRSET", 0}, \ { dns_rcode_nxrrset, "NXRRSET", 0}, \ { dns_rcode_notauth, "NOTAUTH", 0}, \ - { dns_rcode_notzone, "NOTZONE", 0}, + { dns_rcode_notzone, "NOTZONE", 0}, \ + { 11, "RESERVED11", TOTEXTONLY}, \ + { 12, "RESERVED12", TOTEXTONLY}, \ + { 13, "RESERVED13", TOTEXTONLY}, \ + { 14, "RESERVED14", TOTEXTONLY}, \ + { 15, "RESERVED15", TOTEXTONLY}, #define ERCODENAMES \ /* extended rcodes */ \ @@ -247,6 +254,7 @@ dns_mnemonic_fromtext(unsigned int *valuep, isc_textregion_t *source, unsigned int n; n = strlen(table[i].name); if (n == source->length && + (table[i].flags & TOTEXTONLY) == 0 && strncasecmp(source->base, table[i].name, n) == 0) { *valuep = table[i].value; return (ISC_R_SUCCESS);