]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/rules: log more info for a MDB_BAD_VALSIZE case docs-log-bad-vals-5ptxos/deployments/9746 1876/head
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 30 Jul 2026 12:24:21 +0000 (14:24 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 5 Aug 2026 07:02:02 +0000 (09:02 +0200)
Issue 956: it's not difficult to run into this limit, e.g. by using
blocking style with hosts-like files pointing names to 127.0.0.1.
Now it additionally explains a little, e.g.:
  [rules ] records too big (512 B) for 1.0.0.127.in-addr.arpa. PTR

lib/rules/api.c

index 679fee637914bf6db2304b5bf3ad2b46354374d4..7a57aad9d7f5997a66b645550b63a328bf479a4a 100644 (file)
@@ -8,6 +8,7 @@
 #include "lib/cache/cdb_lmdb.h"
 
 #include <stdlib.h>
+#include <lmdb.h>
 
 
 struct kr_rules *the_rules = NULL;
@@ -635,8 +636,15 @@ int local_data_ins(knot_db_val_t key, const knot_rrset_t *rrs, const knot_rdatas
 
        knot_db_val_t val = { .data = buf, .len = val_len };
        int ret = ruledb_op(write, &key, &val, 1); // TODO: overwriting on ==tags?
-       // ENOSPC seems to be the only expectable error.
-       kr_assert(ret == 0 || ret == kr_error(ENOSPC));
+       if (unlikely(ret == MDB_BAD_VALSIZE)) { // yeah, leaking implementation details
+               KR_DNAME_GET_STR(owner_str, rrs->owner);
+               KR_RRTYPE_GET_STR(type_str, rrs->type);
+               kr_log_error(RULES, "records too big (%d B) for %s %s\n",
+                               val_len, owner_str, type_str);
+       } else {
+               // ENOSPC seems to be the only other expectable error.
+               kr_assert(ret == 0 || ret == kr_error(ENOSPC));
+       }
 
        if (ret || rrs->type != KNOT_RRTYPE_DNAME)
                return ret;