+6 October 2022: Wouter
+ - Fix to stop responses with TC flag from resulting in partial
+ responses. It retries to fetch the data elsewhere, or fails the
+ query and in depth fix removes the TC flag from the cached item.
+
5 October 2022: Wouter
- Fix dnscrypt compile for proxy protocol code changes.
if(!msg || !request)
return RESPONSE_TYPE_THROWAWAY;
-
+ /* If the TC flag is set, the response is incomplete. Too large to
+ * fit even in TCP or so. Discard it, it cannot be retrieved here. */
+ if((msg->rep->flags & BIT_TC))
+ return RESPONSE_TYPE_THROWAWAY;
+
/* If the message is NXDOMAIN, then it answers the question. */
if(FLAGS_GET_RCODE(msg->rep->flags) == LDNS_RCODE_NXDOMAIN) {
/* make sure its not recursive when we don't want it to */
(int)((iq->chase_flags&BIT_RD) || iq->chase_to_rd),
iq->response, &iq->qinfo_out, iq->dp);
iq->chase_to_rd = 0;
+ /* remove TC flag, if this is erroneously set by TCP upstream */
+ iq->response->rep->flags &= ~BIT_TC;
if(type == RESPONSE_TYPE_REFERRAL && (iq->chase_flags&BIT_RD) &&
!iq->auth_zone_response) {
/* When forwarding (RD bit is set), we handle referrals
/* remove CD-bit, we asked for in case we handle validation ourself */
prs->flags &= ~BIT_CD;
- /* remove TC flag, if this is erroneously set by TCP upstream */
- prs->flags &= ~BIT_TC;
/* normalize and sanitize: easy to delete items from linked lists */
if(!scrub_message(pkt, prs, &iq->qinfo_out, iq->dp->name,
ENTRY_END
ENTRY_BEGIN
-MATCH opcode qtype qname
-ADJUST copy_id
+MATCH opcode subdomain
+ADJUST copy_id copy_query
REPLY QR NOERROR
SECTION QUESTION
-www.example.com. IN A
+example.com. IN NS
SECTION AUTHORITY
example.com. IN NS ns.example.com.
SECTION ADDITIONAL
ns.example.com. IN A 1.2.3.4
ENTRY_END
+ENTRY_BEGIN
+MATCH opcode qtype qname
+ADJUST copy_id
+REPLY QR AA NOERROR
+SECTION QUESTION
+ns.example.com. IN A
+SECTION ANSWER
+ns.example.com. IN A 1.2.3.4
+ENTRY_END
+
+ENTRY_BEGIN
+MATCH opcode qtype qname
+ADJUST copy_id
+REPLY QR AA NOERROR
+SECTION QUESTION
+ns.example.com. IN AAAA
+SECTION ANSWER
+SECTION AUTHORITY
+example.com. IN NS ns.example.com.
+ENTRY_END
+
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
STEP 10 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
-REPLY QR RD RA NOERROR
+REPLY QR RD RA SERVFAIL
SECTION QUESTION
www.example.com. IN A
-SECTION ANSWER
-www.example.com. IN A 10.20.30.40
-SECTION AUTHORITY
-example.com. IN NS ns.example.com.
-SECTION ADDITIONAL
-ns.example.com. IN A 1.2.3.4
ENTRY_END
SCENARIO_END
cat fwd.log
cat unbound.log
echo "> check answer"
-if grep "10.20.30.42" outfile; then
+if grep "SERVFAIL" outfile; then
echo "OK"
else
echo "Not OK"