log_err("out of memory");
return 0;
}
+ /* Register an EDNS option (65534) to bypass the worker cache lookup
+ * for testing */
+ if(!edns_register_option(LDNS_EDNS_UNBOUND_CACHEDB_TESTFRAME_TEST,
+ 1 /* bypass cache */,
+ 0 /* no aggregation */, env)) {
+ log_err("testframe_init, could not register test opcode");
+ free(d);
+ return 0;
+ }
lock_basic_init(&d->lock);
lock_protect(&d->lock, d, sizeof(*d));
return 1;
* See if unbound's internal cache can answer the query
*/
static int
-cachedb_intcache_lookup(struct module_qstate* qstate)
+cachedb_intcache_lookup(struct module_qstate* qstate, struct cachedb_env* cde)
{
uint8_t* dpname=NULL;
size_t dpnamelen=0;
struct dns_msg* msg;
+ /* for testframe bypass this lookup */
+ if(cde->backend == &testframe_backend) {
+ return 0;
+ }
if(iter_stub_fwd_no_cache(qstate, &qstate->qinfo,
&dpname, &dpnamelen))
return 0; /* no cache for these queries */
/* lookup inside unbound's internal cache.
* This does not look for expired entries. */
- if(cachedb_intcache_lookup(qstate)) {
+ if(cachedb_intcache_lookup(qstate, ie)) {
if(verbosity >= VERB_ALGO) {
if(qstate->return_msg->rep)
log_dns_msg("cachedb internal cache lookup",
LDNS_EDNS_KEEPALIVE = 11, /* draft-ietf-dnsop-edns-tcp-keepalive*/
LDNS_EDNS_PADDING = 12, /* RFC7830 */
LDNS_EDNS_EDE = 15, /* RFC8914 */
- LDNS_EDNS_CLIENT_TAG = 16 /* draft-bellis-dnsop-edns-tags-01 */
+ LDNS_EDNS_CLIENT_TAG = 16, /* draft-bellis-dnsop-edns-tags-01 */
+ LDNS_EDNS_UNBOUND_CACHEDB_TESTFRAME_TEST = 65534
};
typedef enum sldns_enum_edns_option sldns_edns_option;
FOUND_STATS_FILE=found_stats.$$
REST_STATS_FILE=rest_stats.$$
-DEBUG=1
+DEBUG=0
# Write stats to $STATS_FILE.
# Call this when you want to get stats from unbound.
else
echo "! bad expected stats:"
cat $FILTERED_STATS_FILE
- exit 1
+ end 1
fi
}
fi
if grep -v "=0$" $REST_STATS_FILE; then
echo "! bad rest stats"
- exit 1
+ end 1
else
echo "OK"
fi
echo
echo "[ Check cachedb cache miss. ]"
echo "> dig www.example.com."
-dig @127.0.0.1 -p $UNBOUND_PORT 0ttl.example.com. | tee outfile
+dig @127.0.0.1 +ednsopt=65534 -p $UNBOUND_PORT www.example.com. | tee outfile
echo "> check answer"
-if grep "0.0.0.1" outfile; then
+if grep "10.20.30.40" outfile; then
echo "OK"
else
end 1
num.query.edns.present=1
num.query.udpout=1
num.query.cachedb=0
-msg.cache.count=0
+msg.cache.count=1
rrset.cache.count=1
infra.cache.count=1
num.answer.rcode.NOERROR=1"
echo
echo "[ Check cachedb cache hit. ]"
echo "> dig www.example.com."
-dig @127.0.0.1 -p $UNBOUND_PORT 0ttl.example.com. | tee outfile
+dig @127.0.0.1 +ednsopt=65534 -p $UNBOUND_PORT www.example.com. | tee outfile
echo "> check answer"
-if grep "0.0.0.1" outfile; then
+if grep "10.20.30.40" outfile; then
echo "OK"
else
end 1
echo
echo "[ Check cachedb cache hit with stat reset ]"
echo "> dig www.example.com."
-dig @127.0.0.1 -p $UNBOUND_PORT 0ttl.example.com. | tee outfile
+dig @127.0.0.1 +ednsopt=65534 -p $UNBOUND_PORT www.example.com. | tee outfile
echo "> check answer"
-if grep "0.0.0.1" outfile; then
+if grep "10.20.30.40" outfile; then
echo "OK"
else
end 1
fi
check_stats "\
total.num.queries=1
-total.num.cachemiss=0
-total.num.cachehits=1
-total.num.recursivereplies=0
+total.num.cachemiss=1
+total.num.cachehits=0
+total.num.recursivereplies=1
num.query.type.A=1
num.query.class.IN=1
num.query.opcode.QUERY=1
num.query.flags.RD=1
num.query.flags.AD=1
num.query.edns.present=1
-num.query.cachedb=0
+num.query.cachedb=1
msg.cache.count=1
rrset.cache.count=1
infra.cache.count=1