]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: dns: New DNS response analysis code: DNS_RESP_TRUNCATED
authorBaptiste Assmann <bedis9@gmail.com>
Wed, 2 Sep 2015 19:58:32 +0000 (21:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 Sep 2015 12:58:07 +0000 (14:58 +0200)
This patch introduces a new internal response state about the analysis
of a DNS response received by a server.
It is dedicated to report to above layer that the response is
'truncated'.

include/types/dns.h
src/dns.c
src/server.c

index ba35c7160b9977d3857e4f9e20b0c761541ba973..3ec3492520d78de441700f9625e3853b8c9a2f1b 100644 (file)
@@ -198,6 +198,7 @@ enum {
        DNS_RESP_WRONG_NAME,            /* response does not match query name */
        DNS_RESP_CNAME_ERROR,           /* error when resolving a CNAME in an atomic response */
        DNS_RESP_TIMEOUT,               /* DNS server has not answered in time */
+       DNS_RESP_TRUNCATED,             /* DNS response is truncated */
 };
 
 /* return codes after searching an IP in a DNS response buffer, using a family preference */
index bf5afdf964e46ae1df266f60245a8cf9970ba0ae..d1952175efa5fb78d33d6eae8c608c68467010bd 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -218,6 +218,10 @@ void dns_resolve_recv(struct dgram_conn *dgram)
                        resolution->requester_error_cb(resolution, DNS_RESP_CNAME_ERROR);
                        continue;
 
+               case DNS_RESP_TRUNCATED:
+                       nameserver->counters.truncated += 1;
+                       resolution->requester_error_cb(resolution, DNS_RESP_TRUNCATED);
+                       continue;
                }
 
                nameserver->counters.valid += 1;
index 9bbed7979f13407bfbba7d9dcae43fe302d4bb5b..ca8c4f88daca24ab66e2fae76d11cc3344f3a2b6 100644 (file)
@@ -2132,6 +2132,7 @@ int snr_resolution_error_cb(struct dns_resolution *resolution, int error_code)
                        break;
 
                case DNS_RESP_ANCOUNT_ZERO:
+               case DNS_RESP_TRUNCATED:
                case DNS_RESP_ERROR:
                        if (resolution->query_type == DNS_RTYPE_ANY) {
                                /* let's change the query type */