From 8bec43b3a28df7d31a4bb464dd043d7ec9caeab0 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. --- pdns/recursor_cache.cc | 6 ++++-- pdns/recursor_cache.hh | 2 +- pdns/syncres.cc | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pdns/recursor_cache.cc b/pdns/recursor_cache.cc index bc483e9df8..6d0eb5eb61 100644 --- a/pdns/recursor_cache.cc +++ b/pdns/recursor_cache.cc @@ -34,7 +34,7 @@ unsigned int MemRecursorCache::bytes() } // returns -1 for no hits -int32_t MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt, vector* res, const ComboAddress& who, vector>* signatures) +int32_t MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt, vector* res, const ComboAddress& who, vector>* signatures, bool* variable) { time_t ttd=0; // cerr<<"looking up "<< qname<<"|"+qt.getName()<<"\n"; @@ -56,7 +56,9 @@ int32_t MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt, (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; // cerr<<"Looking at "<d_records.size()<<" records for this name"<d_records.begin(); k != i->d_records.end(); ++k) { diff --git a/pdns/recursor_cache.hh b/pdns/recursor_cache.hh index 8999335f9a..c6da875174 100644 --- a/pdns/recursor_cache.hh +++ b/pdns/recursor_cache.hh @@ -53,7 +53,7 @@ public: } unsigned int size(); unsigned int bytes(); - int32_t get(time_t, const DNSName &qname, const QType& qt, vector* res, const ComboAddress& who, vector>* signatures=0); + int32_t 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 4652fb1754..279ad956f7 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -794,7 +794,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) { @@ -913,7 +913,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.47.2