]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix log_dns_msg to log irrespective of minimal responses config.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 21 Aug 2019 15:41:29 +0000 (17:41 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 21 Aug 2019 15:41:29 +0000 (17:41 +0200)
doc/Changelog
testcode/unitmsgparse.c
util/data/msgencode.c
util/data/msgencode.h
util/data/msgreply.c

index 2f89463464a265ada542714c18f9b68a693f9b3a..9401554db14096f829507373602f3e9651909448 100644 (file)
@@ -1,3 +1,6 @@
+21 August 2019: Wouter
+       - Fix log_dns_msg to log irrespective of minimal responses config.
+
 19 August 2019: Ralph
        - Document limitation of pidfile removal outside of chroot directory.
 
index c0b38bac76e4f0f42f5cf470f24a838707a1d702..6f1edc6e9d6e559966cc5d7640c50be16ad2849e 100644 (file)
@@ -179,7 +179,7 @@ perf_encode(struct query_info* qi, struct reply_info* rep, uint16_t id,
        /* encode a couple times */
        for(i=0; i<max; i++) {
                ret = reply_info_encode(qi, rep, id, flags, out, timenow,
-                       r2, 65535, (int)(edns->bits & EDNS_DO) );
+                       r2, 65535, (int)(edns->bits & EDNS_DO), 0);
                unit_assert(ret != 0); /* udp packets should fit */
                attach_edns_record(out, edns);
                regional_free_all(r2);
@@ -342,7 +342,7 @@ testpkt(sldns_buffer* pkt, struct alloc_cache* alloc, sldns_buffer* out,
        } else if(!check_formerr_gone) {
                const size_t lim = 512;
                ret = reply_info_encode(&qi, rep, id, flags, out, timenow,
-                       region, 65535, (int)(edns.bits & EDNS_DO) );
+                       region, 65535, (int)(edns.bits & EDNS_DO), 0);
                unit_assert(ret != 0); /* udp packets should fit */
                attach_edns_record(out, &edns);
                if(vbmp) printf("inlen %u outlen %u\n", 
@@ -357,7 +357,7 @@ testpkt(sldns_buffer* pkt, struct alloc_cache* alloc, sldns_buffer* out,
                        ret = reply_info_encode(&qi, rep, id, flags, out, 
                                timenow, region, 
                                lim - calc_edns_field_size(&edns),
-                               (int)(edns.bits & EDNS_DO));
+                               (int)(edns.bits & EDNS_DO), 0);
                        unit_assert(ret != 0); /* should fit, but with TC */
                        attach_edns_record(out, &edns);
                        if( LDNS_QDCOUNT(sldns_buffer_begin(out)) !=
index 0be99c04f12312f00eb435f520139e4f45ff3bb7..a51a4b9b85d8a4b408b80e722b4a2835440bbf34 100644 (file)
@@ -664,7 +664,7 @@ negative_answer(struct reply_info* rep) {
 int
 reply_info_encode(struct query_info* qinfo, struct reply_info* rep,
        uint16_t id, uint16_t flags, sldns_buffer* buffer, time_t timenow,
-       struct regional* region, uint16_t udpsize, int dnssec)
+       struct regional* region, uint16_t udpsize, int dnssec, int minimise)
 {
        uint16_t ancount=0, nscount=0, arcount=0;
        struct compress_tree_node* tree = 0;
@@ -744,7 +744,7 @@ reply_info_encode(struct query_info* qinfo, struct reply_info* rep,
        sldns_buffer_write_u16_at(buffer, 6, ancount);
 
        /* if response is positive answer, auth/add sections are not required */
-       if( ! (MINIMAL_RESPONSES && positive_answer(rep, qinfo->qtype)) ) {
+       if( ! (minimise && positive_answer(rep, qinfo->qtype)) ) {
                /* insert auth section */
                if((r=insert_section(rep, rep->ns_numrrsets, &nscount, buffer,
                        rep->an_numrrsets, timenow, region, &tree,
@@ -761,7 +761,7 @@ reply_info_encode(struct query_info* qinfo, struct reply_info* rep,
                }
                sldns_buffer_write_u16_at(buffer, 8, nscount);
 
-               if(! (MINIMAL_RESPONSES && negative_answer(rep))) {
+               if(! (minimise && negative_answer(rep))) {
                        /* insert add section */
                        if((r=insert_section(rep, rep->ar_numrrsets, &arcount, buffer,
                                rep->an_numrrsets + rep->ns_numrrsets, timenow, region,
@@ -874,7 +874,7 @@ reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep,
        }
 
        if(!reply_info_encode(qinf, rep, id, flags, pkt, timenow, region,
-               udpsize, dnssec)) {
+               udpsize, dnssec, MINIMAL_RESPONSES)) {
                log_err("reply encode: out of memory");
                return 0;
        }
index eea129d98d59823358a9f0bbd74dc71fb1ff8dd4..30dc515cbe595eadcb0bf58b5ded21b32e55296c 100644 (file)
@@ -85,12 +85,14 @@ int reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep,
  * @param region: to store temporary data in.
  * @param udpsize: size of the answer, 512, from EDNS, or 64k for TCP.
  * @param dnssec: if 0 DNSSEC records are omitted from the answer.
+ * @param minimise: if true, the answer is a minimal response, with
+ *   authority and additional removed if possible.
  * @return: nonzero is success, or 
  *     0 on error: malloc failure (no log_err has been done).
  */
 int reply_info_encode(struct query_info* qinfo, struct reply_info* rep, 
        uint16_t id, uint16_t flags, struct sldns_buffer* buffer, time_t timenow, 
-       struct regional* region, uint16_t udpsize, int dnssec);
+       struct regional* region, uint16_t udpsize, int dnssec, int minimise);
 
 /**
  * Encode query packet. Assumes the buffer is large enough.
index 32aec4bf4c959161babc5fd04df7ebac7d9b04f3..a2c09ac2016bf847d484fdc131de9ce86628c3a0 100644 (file)
@@ -819,7 +819,7 @@ log_dns_msg(const char* str, struct query_info* qinfo, struct reply_info* rep)
        sldns_buffer* buf = sldns_buffer_new(65535);
        struct regional* region = regional_create();
        if(!reply_info_encode(qinfo, rep, 0, rep->flags, buf, 0, 
-               region, 65535, 1)) {
+               region, 65535, 1, 0)) {
                log_info("%s: log_dns_msg: out of memory", str);
        } else {
                char* s = sldns_wire2str_pkt(sldns_buffer_begin(buf),