From b33c246294e8489e56c0532ff2a84cf0df2904dc Mon Sep 17 00:00:00 2001 From: bert hubert Date: Thu, 26 Nov 2015 09:20:49 +0100 Subject: [PATCH] add setting edns-outgoing-bufsize for setting the default EDNS bufsize in recursor for outgoing queries --- pdns/lwres.cc | 4 ++-- pdns/pdns_recursor.cc | 5 +++-- pdns/syncres.hh | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pdns/lwres.cc b/pdns/lwres.cc index b8f657fde3..6bd17220ad 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -56,7 +56,7 @@ int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, LWResult *lwr) { int len; - int bufsize=1500; + int bufsize=g_outgoingEDNSBufsize; scoped_array buf(new unsigned char[bufsize]); vector vpacket; // string mapped0x20=dns0x20(domain); @@ -77,7 +77,7 @@ int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool d srcmask=boost::optional(); // this is also our return value } - pw.addOpt(1200, 0, EDNSOpts::DNSSECOK, opts); // 1200 bytes answer size + pw.addOpt(g_outgoingEDNSBufsize, 0, EDNSOpts::DNSSECOK, opts); pw.commit(); } lwr->d_rcode = 0; diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 81ccf24150..bcd6d45c96 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -88,7 +88,7 @@ unsigned int g_networkTimeoutMsec; uint64_t g_latencyStatSize; bool g_logCommonErrors; bool g_anyToTcp; -uint16_t g_udpTruncationThreshold; +uint16_t g_udpTruncationThreshold, g_outgoingEDNSBufsize; __thread shared_ptr* t_pdl; __thread addrringbuf_t* t_remotes, *t_servfailremotes, *t_largeanswerremotes; @@ -2163,7 +2163,7 @@ int serviceMain(int argc, char*argv[]) } setupDelegationOnly(); - + g_outgoingEDNSBufsize=::arg().asNum("edns-outgoing-bufsize"); if(::arg()["trace"]=="fail") { SyncRes::setDefaultLogMode(SyncRes::Store); @@ -2552,6 +2552,7 @@ int main(int argc, char **argv) ::arg().setSwitch( "root-nx-trust", "If set, believe that an NXDOMAIN from the root means the TLD does not exist")="no"; ::arg().setSwitch( "any-to-tcp","Answer ANY queries with tc=1, shunting to TCP" )="no"; ::arg().set("udp-truncation-threshold", "Maximum UDP response size before we truncate")="1680"; + ::arg().set("edns-outgoing-bufsize", "Outgoing EDNS buffer size")="1680"; ::arg().set("minimum-ttl-override", "Set under adverse conditions, a minimum TTL")="0"; ::arg().set("max-qperq", "Maximum outgoing queries per query")="50"; ::arg().set("max-total-msec", "Maximum total wall-clock time per query in milliseconds, 0 for unlimited")="7000"; diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 35c3a32d0c..313db996a8 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -633,6 +633,7 @@ void parseACLs(); extern RecursorStats g_stats; extern unsigned int g_numThreads; extern SuffixMatchNode g_delegationOnly; +extern uint16_t g_outgoingEDNSBufsize; std::string reloadAuthAndForwards(); ComboAddress parseIPAndPort(const std::string& input, uint16_t port); ComboAddress getQueryLocalAddress(int family, uint16_t port); -- 2.47.2