]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/selection debug logs: print one more line
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 24 May 2022 08:36:50 +0000 (10:36 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 9 Jun 2022 07:16:54 +0000 (09:16 +0200)
And that made the "NO6: is KO" line extraneous.
Example in context:
[select][14162.01]   => id: '15271' choosing from addresses: 0 v4 + 1 v6; names to resolve: 6 v4 + 5 v6; force_resolve: 0; NO6: IPv6 is OK
[select][14162.01]   => id: '15271' choosing: 'ns1.p31.dynect.net.'@'2600:2000:2210::31#00053' with timeout 774 ms zone cut: 'amazon.com.'
[select][14162.01]   => id: '15271' updating: 'ns1.p31.dynect.net.'@'2600:2000:2210::31#00053' zone cut: 'amazon.com.' with rtt 316 to srtt: 311 and variance: 89

lib/selection.c
lib/selection.h
lib/selection_iter.c

index a418fc045cc04933714cdb70ac081ca4c2aac5f6..0a112884c40ccfe599df53ee2516029e803c123f 100644 (file)
@@ -76,7 +76,7 @@ static struct {
        uint8_t addr_prefixes[NO6_PREFIX_COUNT][NO6_PREFIX_BYTES];
 } no6_est = { .len_used = 0 };
 
-static inline bool no6_is_bad(void)
+bool no6_is_bad(void)
 {
        return no6_est.len_used == NO6_PREFIX_COUNT;
 }
@@ -459,8 +459,6 @@ struct kr_transport *select_transport(const struct choice choices[], int choices
                /* "EXPLOIT":
                 * choose a resolved address which seems best right now. */
                chosen = best;
-               if (no6_is_bad())
-                       VERBOSE_MSG(NULL, "NO6: is KO [exploit]\n");
        }
 
        /* Don't try the same server again when there are other choices to be explored */
index 81e1118458f696bb4db8062716752d48afb12874..468638bf36de44f615f248d3b8c6e4b66e4fc296 100644 (file)
@@ -263,3 +263,7 @@ uint8_t *ip_to_bytes(const union kr_sockaddr *src, size_t len);
  */
 void update_address_state(struct address_state *state, union kr_sockaddr *address,
                          size_t address_len, struct kr_query *qry);
+
+/** @internal Return whether IPv6 is considered to be broken. */
+bool no6_is_bad(void);
+
index eff4c0b9c51d17f964f4dd69a447d8dd26f5e864..c59a88c60e4b468fc339d0598f1944f7d06060b1 100644 (file)
@@ -249,10 +249,29 @@ void iter_choose_transport(struct kr_query *qry, struct kr_transport **transport
        // Filter valid addresses and names from the tries
        int choices_len = get_valid_addresses(local_state, choices);
        int resolvable_len = get_resolvable_names(local_state, resolvable, qry);
+       bool * const force_resolve_p = &qry->server_selection.local_state->force_resolve;
+
+       // Print some stats into debug logs.
+       if (kr_log_is_debug_qry(SELECTION, qry)) {
+               int v4_choices = 0;
+               for (int i = 0; i < choices_len; ++i)
+                       if (choices[i].address.ip.sa_family == AF_INET)
+                               ++v4_choices;
+               int v4_resolvable = 0;
+               for (int i = 0; i < resolvable_len; ++i)
+                       if (resolvable[i].type == KR_TRANSPORT_RESOLVE_A)
+                               ++v4_resolvable;
+               VERBOSE_MSG(qry, "=> id: '%05u' choosing from addresses: %d v4 + %d v6; "
+                       "names to resolve: %d v4 + %d v6; "
+                       "force_resolve: %d; NO6: IPv6 is %s\n",
+                       qry->id, v4_choices, choices_len - v4_choices,
+                       v4_resolvable, resolvable_len - v4_resolvable,
+                       (int)*force_resolve_p, no6_is_bad() ? "KO" : "OK");
+       }
 
-       if (qry->server_selection.local_state->force_resolve && resolvable_len) {
+       if (*force_resolve_p && resolvable_len) {
                choices_len = 0;
-               qry->server_selection.local_state->force_resolve = false;
+               *force_resolve_p = false;
        }
 
        bool tcp = qry->flags.TCP || qry->server_selection.local_state->truncated;