]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
stats: remove tracking of expiring records
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 27 Jul 2017 13:00:39 +0000 (15:00 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Thu, 15 Feb 2018 15:41:06 +0000 (16:41 +0100)
The predict module doesn't use this way since 965bab926f (v1.3.2),
and there seems to be no other likely use case.

NEWS
modules/stats/README.rst
modules/stats/stats.c

diff --git a/NEWS b/NEWS
index 894de67815d9e35f8376357d39b3c372fb429234..2cae8a224e53cc9b6c286b97c8ef526a5b362d1e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Knot Resolver 2.X.Y (2018-0M-DD)
 
 Incompatible changes
 --------------------
+- stats: remove tracking of expiring records (predict uses another way)
 - systemd: more chages in default unit files (TODO)
 - ta_sentinel: implement protocol draft-ietf-dnsop-kskroll-sentinel-01
   (our draft-ietf-dnsop-kskroll-sentinel-00 implementation had inverted logic)
@@ -15,6 +16,7 @@ Bugfixes
 - cache: fix broken refresh of insecure records that were about to expire
 - fix the hints module on some systems, e.g. Fedora (came back on 2.0.0)
 - build with older gnutls (conditionally disable features)
+- fix the predict module to work with insecure records & cleanup code
 
 
 Knot Resolver 2.0.0 (2018-01-31)
index 8f5280641f6ba02ae91f1be3eb9d0034b90099ad..29d23d8bc823ad14fb1f5ef84a5846fe4536dd71 100644 (file)
@@ -86,14 +86,6 @@ and include subrequests. The list maximum size is 5000 entries, make diffs if yo
 
 Clear the list of most frequent iterative queries.
 
-.. function:: stats.expiring()
-
-Outputs list of soon-to-expire records as a JSON array.
-The list maximum size is 5000 entries, make diffs if you want to track it over time.
-
-.. function:: stats.clear_expiring()
-
-Clear the list of soon expiring records.
 
 Built-in statistics
 ^^^^^^^^^^^^^^^^^^^
index f0a517f82fc955bb660d366e628cde7187adb27b..8a593ca5d4796d350bc985cf35561e3c2329e29f 100644 (file)
@@ -84,7 +84,6 @@ struct stat_data {
        map_t map;
        struct {
                namehash_t *frequent;
-               namehash_t *expiring;
        } queries;
        struct {
                addrlist_t q;
@@ -124,10 +123,10 @@ static inline int collect_key(char *key, const knot_dname_t *name, uint16_t type
 {
        memcpy(key, &type, sizeof(type));
        int key_len = knot_dname_to_wire((uint8_t *)key + sizeof(type), name, KNOT_DNAME_MAXLEN);
-       if (key_len > 0) {
-               return key_len + sizeof(type);
+       if (key_len < 0) {
+               return kr_error(key_len);
        }
-       return key_len;
+       return key_len + sizeof(type);
 }
 
 static void collect_sample(struct stat_data *data, struct kr_rplan *rplan, knot_pkt_t *pkt)
@@ -135,18 +134,18 @@ static void collect_sample(struct stat_data *data, struct kr_rplan *rplan, knot_
        /* Sample key = {[2] type, [1-255] owner} */
        char key[sizeof(uint16_t) + KNOT_DNAME_MAXLEN];
        for (size_t i = 0; i < rplan->resolved.len; ++i) {
-               /* Sample queries leading to iteration or expiring */
+               /* Sample queries leading to iteration */
                struct kr_query *qry = rplan->resolved.at[i];
-               if ((qry->flags.CACHED) && !(qry->flags.EXPIRING)) {
+               if (qry->flags.CACHED) {
                        continue;
                }
-               int key_len = collect_key(key, qry->sname, qry->stype);
-               if (qry->flags.EXPIRING) {
-                       unsigned *count = lru_get_new(data->queries.expiring, key, key_len);
-                       if (count)
-                               *count += 1;
                /* Consider 1 in N for frequent sampling. */
-               } else if (kr_rand_uint(FREQUENT_PSAMPLE) <= 1) {
+               if (kr_rand_uint(FREQUENT_PSAMPLE) <= 1) {
+                       int key_len = collect_key(key, qry->sname, qry->stype);
+                       if (key_len < 0) {
+                               assert(false);
+                               continue;
+                       }
                        unsigned *count = lru_get_new(data->queries.frequent, key, key_len);
                        if (count)
                                *count += 1;
@@ -370,19 +369,6 @@ static char* clear_frequent(void *env, struct kr_module *module, const char *arg
        return NULL;
 }
 
-static char* dump_expiring(void *env, struct kr_module *module, const char *args)
-{
-       struct stat_data *data = module->data;
-       return dump_list(env, module, args, data->queries.expiring);
-}
-
-static char* clear_expiring(void *env, struct kr_module *module, const char *args)
-{
-       struct stat_data *data = module->data;
-       lru_reset(data->queries.expiring);
-       return NULL;
-}
-
 static char* dump_upstreams(void *env, struct kr_module *module, const char *args)
 {
        struct stat_data *data = module->data;
@@ -447,7 +433,6 @@ int stats_init(struct kr_module *module)
        data->map = map_make();
        module->data = data;
        lru_create(&data->queries.frequent, FREQUENT_COUNT, NULL, NULL);
-       lru_create(&data->queries.expiring, FREQUENT_COUNT, NULL, NULL);
        /* Initialize ring buffer of recently visited upstreams */
        array_init(data->upstreams.q);
        if (array_reserve(data->upstreams.q, UPSTREAMS_COUNT) != 0) {
@@ -467,7 +452,6 @@ int stats_deinit(struct kr_module *module)
        if (data) {
                map_clear(&data->map);
                lru_free(data->queries.frequent);
-               lru_free(data->queries.expiring);
                array_clear(data->upstreams.q);
                free(data);
        }
@@ -483,8 +467,6 @@ struct kr_prop *stats_props(void)
            { &stats_list,    "list", "List observed metrics.", },
            { &dump_frequent, "frequent", "List most frequent queries.", },
            { &clear_frequent,"clear_frequent", "Clear frequent queries log.", },
-           { &dump_expiring, "expiring", "List expiring records.", },
-           { &clear_expiring,"clear_expiring", "Clear expiring records log.", },
            { &dump_upstreams,  "upstreams", "List recently seen authoritatives.", },
            { NULL, NULL, NULL }
        };