]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
layer/iterate: accept REFUSED as an answer
authorMarek Vavruša <marek.vavrusa@nic.cz>
Tue, 2 Jun 2015 08:30:26 +0000 (10:30 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Tue, 2 Jun 2015 08:30:26 +0000 (10:30 +0200)
some servers break qname m12n by sending REFUSED, this accepts such answer and requeries with m12n turned off

lib/layer/iterate.c
lib/layer/iterate.h

index 10b323c627b5cbb4565ae9eef23195273d2b887c..b711d2971a6f150f72ab2f2db7b91ed146e9a8bb 100644 (file)
@@ -108,6 +108,8 @@ int kr_response_classify(knot_pkt_t *pkt)
                return (an->count == 0) ? PKT_NODATA : PKT_NOERROR;
        case KNOT_RCODE_NXDOMAIN:
                return PKT_NXDOMAIN;
+       case KNOT_RCODE_REFUSED:
+               return PKT_REFUSED;
        default:
                return PKT_ERROR;
        }
@@ -282,7 +284,7 @@ static int process_answer(knot_pkt_t *pkt, struct kr_request *req)
        bool is_final = (query->parent == NULL);
        int pkt_class = kr_response_classify(pkt);
        if (!knot_dname_is_equal(knot_pkt_qname(pkt), query->sname) &&
-           (pkt_class & (PKT_NOERROR|PKT_NXDOMAIN|PKT_NODATA))) {
+           (pkt_class & (PKT_NOERROR|PKT_NXDOMAIN|PKT_REFUSED|PKT_NODATA))) {
                DEBUG_MSG("<= found cut, retrying with non-minimized name\n");
                query->flags |= QUERY_NO_MINIMIZE;
                return KNOT_STATE_DONE;
@@ -424,6 +426,7 @@ static int resolve(knot_layer_t *ctx, knot_pkt_t *pkt)
        switch(knot_wire_get_rcode(pkt->wire)) {
        case KNOT_RCODE_NOERROR:
        case KNOT_RCODE_NXDOMAIN:
+       case KNOT_RCODE_REFUSED:
                break; /* OK */
        case KNOT_RCODE_FORMERR:
        case KNOT_RCODE_NOTIMPL:
index dbdcf81c88d56deb5a000a368823e8ff4219d98e..86a2442b5eeb19168067eaf154e98ffcd2fa53ac 100644 (file)
@@ -24,11 +24,12 @@ enum {
        PKT_NOERROR   = 1 << 0, /* Positive response */
        PKT_NODATA    = 1 << 1, /* No data response */
        PKT_NXDOMAIN  = 1 << 2, /* Negative response */
-       PKT_ERROR     = 1 << 3  /* Refused or server failure */
+       PKT_REFUSED   = 1 << 3, /* Refused response */
+       PKT_ERROR     = 1 << 4  /* Bad message */
 };
 
 /** Classify response by type. */
 int kr_response_classify(knot_pkt_t *pkt);
 
 /* Processing module implementation. */
-const knot_layer_api_t *iterate_layer(struct kr_module *module);
\ No newline at end of file
+const knot_layer_api_t *iterate_layer(struct kr_module *module);