Bug 235 - Skip dname compression for replies with no answers.
Skip dname compression for replies with no answers.
Status: RESOLVED FIXED
Product: NSD
Classification: Unclassified
Component: NSD Code
3.0.x
All All
: P2 trivial
Assigned To: NSD team
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-02-18 05:48 CET by Piotr Sikora
Modified: 2009-02-19 12:26 CET (History)
1 user (show)

See Also:


Attachments
patch (581 bytes, patch)
2009-02-18 05:48 CET, Piotr Sikora
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Sikora 2009-02-18 05:48:53 CET
Created attachment 100 [details]
patch

This is trivial patch, but we shouldn't waste precious CPUTIME ;)
Comment 1 Matthijs Mekking 2009-02-18 11:58:18 CET
But you still may compress dnames in the authoritative or additional section (in case of YXDOMAIN for example).
Comment 2 Piotr Sikora 2009-02-18 20:46:49 CET
Well, I thought that I'd probably miss some RCODEs... To be honest I never encountered YXDOMAIN before, so I didn't even think about this case.

Anyway, fast grep through source code shows that those RCODEs are used:
- OK - with answers,
- FORMAT - no answers,
- SERVFAIL - no answers,
- NXDOMAIN - with answers,
- IMPL - no answers,
- REFUSE - no answers,
- YXDOMAIN - with answers(?).

Please correct me if I'm wrong...

Index: query.c
===================================================================
--- query.c	(revision 2858)
+++ query.c	(working copy)
@@ -1171,6 +1171,11 @@
 	answer_lookup_zone(nsd, q, &answer, 0, exact, closest_match,
 		closest_encloser, q->qname);
 
+	/* We can't use !AA(q->packet) because of queries with class ANY */
+	if (RCODE(q->packet) != RCODE_OK && RCODE(q->packet) != RCODE_NXDOMAIN
+		&& RCODE(q->packet) != RCODE_YXDOMAIN)
+		return;
+
 	offset = dname_label_offsets(q->qname)[domain_dname(closest_encloser)->label_count - 1] + QHEADERSZ;
 	query_add_compression_domain(q, closest_encloser, offset);
Comment 3 Matthijs Mekking 2009-02-19 11:14:45 CET
A whole list can be found here:
    http://tools.ietf.org/html/rfc2929#section-2.3
or in dns.h ;-).

Anyway, I prefer to assure that no dnames (except the QDNAME) in the response in order to skip dname compression.

+ if (ANCOUNT(q->packet) + NSCOUNT(q->packet) + ARCOUNT(q->packet) == 0)
+    return;
Comment 4 Matthijs Mekking 2009-02-19 12:19:41 CET
Thanks for the patch. I have made changes according to my last comment. Hope this will satisfy you enough:)
Comment 5 Piotr Sikora 2009-02-19 12:26:26 CET
Your patch is even better, thanks!