From 2325010e69333c090189d045043b29027e597a43 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Wed, 14 Jun 2017 08:35:53 +0200 Subject: [PATCH] with this, EDNS Client Subnet becomes compatible with the packet cache, using the existing variable answer facility. (cherry picked from commit 8bec43b3a28df7d31a4bb464dd043d7ec9caeab0) --- pdns/recursor_cache.cc | 5 ++++- pdns/recursor_cache.hh | 2 +- pdns/syncres.cc | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pdns/recursor_cache.cc b/pdns/recursor_cache.cc index b25b68fa0..d3178beb3 100644 --- a/pdns/recursor_cache.cc +++ b/pdns/recursor_cache.cc @@ -31,7 +31,7 @@ unsigned int MemRecursorCache::bytes() } // returns -1 for no hits -int MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt, vector* res, const ComboAddress& who, vector>* signatures) +int MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt, vector* res, const ComboAddress& who, vector>* signatures, bool* variable) { unsigned int ttd=0; // cerr<<"looking up "<< qname<<"|"+qt.getName()<<"\n"; @@ -54,6 +54,9 @@ int MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt, vec (qt.getCode()==QType::ADDR && (i->d_qtype == QType::A || i->d_qtype == QType::AAAA) )) && (i->d_netmask.empty() || i->d_netmask.match(who)) ) { + if(variable && !i->d_netmask.empty()) { + *variable=true; + } ttd = i->d_ttd; diff --git a/pdns/recursor_cache.hh b/pdns/recursor_cache.hh index 333257e9f..9434355da 100644 --- a/pdns/recursor_cache.hh +++ b/pdns/recursor_cache.hh @@ -53,7 +53,7 @@ public: } unsigned int size(); unsigned int bytes(); - int get(time_t, const DNSName &qname, const QType& qt, vector* res, const ComboAddress& who, vector>* signatures=0); + int get(time_t, const DNSName &qname, const QType& qt, vector* res, const ComboAddress& who, vector>* signatures=0, bool* variable=0); void replace(time_t, const DNSName &qname, const QType& qt, const vector& content, const vector>& signatures, bool auth, boost::optional ednsmask=boost::optional()); void doPrune(void); diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 2f44c25b7..f1542726c 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -713,7 +713,7 @@ bool SyncRes::doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector LOG(prefix< cset; vector> signatures; - if(t_RC->get(d_now.tv_sec, qname,QType(QType::CNAME), &cset, d_requestor, &signatures) > 0) { + if(t_RC->get(d_now.tv_sec, qname,QType(QType::CNAME), &cset, d_requestor, &signatures, &d_wasVariable) > 0) { for(auto j=cset.cbegin() ; j != cset.cend() ; ++j) { if(j->d_ttl>(unsigned int) d_now.tv_sec) { @@ -842,7 +842,7 @@ bool SyncRes::doCacheCheck(const DNSName &qname, const QType &qtype, vector> signatures; uint32_t ttl=0; - if(t_RC->get(d_now.tv_sec, sqname, sqt, &cset, d_requestor, d_doDNSSEC ? &signatures : 0) > 0) { + if(t_RC->get(d_now.tv_sec, sqname, sqt, &cset, d_requestor, d_doDNSSEC ? &signatures : 0, &d_wasVariable) > 0) { LOG(prefix<d_content->getZoneRepresentation()); -- 2.40.0