]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- cachedb-no-store, implement `cachedb-no-store: yes` configuration option.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 6 Oct 2023 11:22:10 +0000 (13:22 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 6 Oct 2023 11:22:10 +0000 (13:22 +0200)
cachedb/cachedb.c
util/config_file.c
util/config_file.h
util/configlexer.lex
util/configparser.y

index 30645268ca23b8c407b016c54dca2b4ae7fa35a2..01f4a6d8497fab43f13af489b2455892dde52e71 100644 (file)
@@ -815,6 +815,11 @@ cachedb_handle_response(struct module_qstate* qstate,
                qstate->ext_state[id] = module_finished;
                return;
        }
+       if(qstate->env->cfg->cachedb_no_store) {
+               /* do not store the item in the external cache */
+               qstate->ext_state[id] = module_finished;
+               return;
+       }
 
        /* store the item into the backend cache */
        cachedb_extcache_store(qstate, ie);
index 45409634232634626c08365deafc2d9e63fdaaaa..e33cd9d5adfc09ba589ee23e1a01cb88511044eb 100644 (file)
@@ -381,6 +381,7 @@ config_create(void)
 #ifdef USE_CACHEDB
        if(!(cfg->cachedb_backend = strdup("testframe"))) goto error_exit;
        if(!(cfg->cachedb_secret = strdup("default"))) goto error_exit;
+       cfg->cachedb_no_store = 0;
 #ifdef USE_REDIS
        if(!(cfg->redis_server_host = strdup("127.0.0.1"))) goto error_exit;
        cfg->redis_server_path = NULL;
@@ -819,6 +820,9 @@ int config_set_option(struct config_file* cfg, const char* opt,
        { IS_NUMBER_OR_ZERO; cfg->ipsecmod_max_ttl = atoi(val); }
        else S_YNO("ipsecmod-strict:", ipsecmod_strict)
 #endif
+#ifdef USE_CACHEDB
+       else S_YNO("cachedb-no-store:", cachedb_no_store)
+#endif /* USE_CACHEDB */
        else if(strcmp(opt, "define-tag:") ==0) {
                return config_add_tag(cfg, val);
        /* val_sig_skew_min, max and val_max_restart are copied into val_env
@@ -1306,6 +1310,7 @@ config_get_option(struct config_file* cfg, const char* opt,
 #ifdef USE_CACHEDB
        else O_STR(opt, "backend", cachedb_backend)
        else O_STR(opt, "secret-seed", cachedb_secret)
+       else O_YNO(opt, "cachedb-no-store", cachedb_no_store)
 #ifdef USE_REDIS
        else O_STR(opt, "redis-server-host", redis_server_host)
        else O_DEC(opt, "redis-server-port", redis_server_port)
index 452f3c6a78fb9361645b1c47516204579ec7ba29..ce65079859ca7d7857682f1345c6d099e68a0d9e 100644 (file)
@@ -699,6 +699,8 @@ struct config_file {
        char* cachedb_backend;
        /** secret seed for hash key calculation */
        char* cachedb_secret;
+       /** cachedb that does not store, but only reads from database, if on */
+       int cachedb_no_store;
 #ifdef USE_REDIS
        /** redis server's IP address or host name */
        char* redis_server_host;
index 3fcdfa62e03351bb3706a38b57d47e03a4c74da1..144817879c7bf5cba0e2b5e715779c8c11a9b8d5 100644 (file)
@@ -557,6 +557,7 @@ ipsecmod-strict{COLON}              { YDVAR(1, VAR_IPSECMOD_STRICT) }
 cachedb{COLON}                 { YDVAR(0, VAR_CACHEDB) }
 backend{COLON}                 { YDVAR(1, VAR_CACHEDB_BACKEND) }
 secret-seed{COLON}             { YDVAR(1, VAR_CACHEDB_SECRETSEED) }
+cachedb-no-store{COLON}                { YDVAR(1, VAR_CACHEDB_NO_STORE) }
 redis-server-host{COLON}       { YDVAR(1, VAR_CACHEDB_REDISHOST) }
 redis-server-port{COLON}       { YDVAR(1, VAR_CACHEDB_REDISPORT) }
 redis-server-path{COLON}       { YDVAR(1, VAR_CACHEDB_REDISPATH) }
index d8f25a67ebbfded22d1a5f307a859f041ea29332..4cc52cfb986fee9f9bc3c6f4d88467946082ae8f 100644 (file)
@@ -198,7 +198,7 @@ extern struct config_parser_state* cfg_parser;
 %token VAR_INTERFACE_ACTION VAR_INTERFACE_VIEW VAR_INTERFACE_TAG
 %token VAR_INTERFACE_TAG_ACTION VAR_INTERFACE_TAG_DATA
 %token VAR_PROXY_PROTOCOL_PORT VAR_STATISTICS_INHIBIT_ZERO
-%token VAR_HARDEN_UNKNOWN_ADDITIONAL
+%token VAR_HARDEN_UNKNOWN_ADDITIONAL VAR_CACHEDB_NO_STORE
 
 %%
 toplevelvars: /* empty */ | toplevelvars toplevelvar ;
@@ -3701,7 +3701,8 @@ contents_cachedb: contents_cachedb content_cachedb
        | ;
 content_cachedb: cachedb_backend_name | cachedb_secret_seed |
        redis_server_host | redis_server_port | redis_timeout |
-       redis_expire_records | redis_server_path | redis_server_password
+       redis_expire_records | redis_server_path | redis_server_password |
+       cachedb_no_store
        ;
 cachedb_backend_name: VAR_CACHEDB_BACKEND STRING_ARG
        {
@@ -3727,6 +3728,19 @@ cachedb_secret_seed: VAR_CACHEDB_SECRETSEED STRING_ARG
        #endif
        }
        ;
+cachedb_no_store: VAR_CACHEDB_NO_STORE STRING_ARG
+       {
+       #ifdef USE_CACHEDB
+               OUTYY(("P(cachedb_no_store:%s)\n", $2));
+               if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
+                       yyerror("expected yes or no.");
+               else cfg_parser->cfg->cachedb_no_store = (strcmp($2, "yes")==0);
+       #else
+               OUTYY(("P(Compiled without cachedb, ignoring)\n"));
+       #endif
+               free($2);
+       }
+       ;
 redis_server_host: VAR_CACHEDB_REDISHOST STRING_ARG
        {
        #if defined(USE_CACHEDB) && defined(USE_REDIS)