From 2188dcc3e683f7f47275d066fea52aa36ec87fa4 Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Mon, 4 Feb 2008 22:32:49 +0000 Subject: [PATCH] reprime root hints using EDNS0, thanks to dns-operations AT mail.oarc.isc.org git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1130 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/lwres.cc | 7 ++++++- pdns/lwres.hh | 2 +- pdns/pdns_recursor.cc | 2 +- pdns/syncres.cc | 8 ++++++-- pdns/syncres.hh | 9 ++++++++- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/pdns/lwres.cc b/pdns/lwres.cc index 40165b0e37..50f8f6a890 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -40,7 +40,7 @@ //! returns -2 for OS limits error, -1 for permanent error that has to do with remote, 0 for timeout, 1 for success /** Never throws! */ -int asyncresolve(const ComboAddress& ip, const string& domain, int type, bool doTCP, struct timeval* now, LWResult *lwr) +int asyncresolve(const ComboAddress& ip, const string& domain, int type, bool doTCP, bool doEDNS0, struct timeval* now, LWResult *lwr) { int len; int bufsize=1500; @@ -50,6 +50,11 @@ int asyncresolve(const ComboAddress& ip, const string& domain, int type, bool do pw.getHeader()->rd=0; pw.getHeader()->id=Utility::random(); + + if(doEDNS0 && !doTCP) { + pw.addOpt(1200, 0, 0); // 1200 bytes answer size + pw.commit(); + } lwr->d_rcode=0; int ret; diff --git a/pdns/lwres.hh b/pdns/lwres.hh index d0d3a6546e..611340f1e8 100644 --- a/pdns/lwres.hh +++ b/pdns/lwres.hh @@ -63,6 +63,6 @@ public: uint32_t d_usec; }; -int asyncresolve(const ComboAddress& ip, const string& domain, int type, bool doTCP, struct timeval* now, LWResult* res); +int asyncresolve(const ComboAddress& ip, const string& domain, int type, bool doTCP, bool doEDNS0, struct timeval* now, LWResult* res); #endif // PDNS_LWRES_HH diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 16e59f0522..cc76d05cd0 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -33,7 +33,6 @@ #include #include #include -#include "htimer.hh" #include "mtasker.hh" #include @@ -1127,6 +1126,7 @@ try } if(now.tv_sec - last_rootupdate > 7200) { SyncRes sr(now); + sr.setDoEDNS0(true); vector ret; sr.setNoCache(); diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 74a3605d76..bfdd27559a 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -212,7 +212,7 @@ int SyncRes::doResolve(const string &qname, const QType &qtype, vector nameservers, string auth, s_tcpoutqueries++; d_tcpoutqueries++; } - resolveret=asyncresolve(*remoteIP, qname, qtype.getCode(), doTCP, &d_now, &lwr); // <- we go out on the wire! + resolveret=asyncresolve(*remoteIP, qname, qtype.getCode(), doTCP, d_doEDNS0, &d_now, &lwr); // <- we go out on the wire! if(resolveret != 1) { if(resolveret==0) { LOG< nameservers, string auth, // reap all answers from this packet that are acceptable for(LWResult::res_t::const_iterator i=lwr.d_result.begin();i != lwr.d_result.end();++i) { + if(i->qtype.getCode() == QType::OPT) { + LOG<qname<<"' from '"<qname<<"|"<qtype.getName()<<"|"<content<<"' from '"<qtype.getCode()==QType::ANY) { LOG<<"NO! - we don't accept 'ANY' data"<&ret); void setId(int id) { @@ -231,6 +231,12 @@ public: { d_nocache=state; } + + void setDoEDNS0(bool state=true) + { + d_doEDNS0=state; + } + static unsigned int s_queries; static unsigned int s_outgoingtimeouts; static unsigned int s_throttledqueries; @@ -372,6 +378,7 @@ private: static bool s_log; bool d_cacheonly; bool d_nocache; + bool d_doEDNS0; struct GetBestNSAnswer { -- 2.39.5