]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/zonecut.c fetch_addr(): resurrect filtering by NO_IPV*
authorVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 3 Nov 2023 11:31:06 +0000 (12:31 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 3 Nov 2023 11:59:16 +0000 (12:59 +0100)
This filtering was dropped in 4565cc596680 (v5.3.0).
Now it's reintroduced - but inside the function, as that seems nicer.
Nit: naming and comment were updated to fit the current usage.

As the code is designed so far (in whole history probably), in order
to detect whether we need to choose a zone cut closer to the root,
we need to do something like this in lib/zonecut.c already,
instead of just during server selection.

I don't think this change can break anything.
Fetching unusable addresses from cache seems pointless,
as selection wouldn't be allowed to use them or try resolving them.

NEWS
lib/zonecut.c

diff --git a/NEWS b/NEWS
index fa25a72a20211cab45986dbba1f8be41e32519c7..72f022fa38a91d08a676ad322c2dbd7ce8e17f13 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+Knot Resolver 5.x.y (202y-mm-dd)
+================================
+
+Bugfixes
+--------
+- fix potential SERVFAIL deadlocks if net.ipv6 = false (#880)
+
+
 Knot Resolver 5.7.0 (2023-08-22)
 ================================
 
index 4ec403672a8e5ea648c40a4b5a541acd90ccce1d..2bbd26fcc717d6a106744f61b74291d07202160a 100644 (file)
@@ -19,8 +19,7 @@
 /** Information for one NS name + address type. */
 typedef enum {
        AI_UNINITED = 0,
-       AI_REPUT,       /**< Don't use this addrset, due to: cache_rep, NO_IPV6, ...
-                        * cache_rep approximates various problems when fetching the RRset. */
+       AI_DISABLED,    /**< Can't use this addrset. */
        AI_CYCLED,      /**< Skipped due to cycle detection; see implementation for details. */
        AI_LAST_BAD = AI_CYCLED, /** bad states: <= AI_LAST_BAD */
        AI_UNKNOWN,     /**< Don't know status of this RRset; various reasons. */
@@ -289,9 +288,13 @@ static addrset_info_t fetch_addr(pack_t *addrs, const knot_dname_t *ns, uint16_t
        int rdlen;
        switch (rrtype) {
        case KNOT_RRTYPE_A:
+               if (qry->flags.NO_IPV4)
+                       return AI_DISABLED;
                rdlen = 4;
                break;
        case KNOT_RRTYPE_AAAA:
+               if (qry->flags.NO_IPV6 || no6_is_bad())
+                       return AI_DISABLED;
                rdlen = 16;
                break;
        default: