From: Remi Gacogne Date: Tue, 8 Dec 2020 18:32:22 +0000 (+0100) Subject: rec: Use protozero for outgoing queries Protocol Buffer operations X-Git-Tag: rec-4.5.0-alpha1~38^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=00b3e94a21b5465092537cb6b56bb23f56fc9ee9;p=thirdparty%2Fpdns.git rec: Use protozero for outgoing queries Protocol Buffer operations --- diff --git a/m4/pdns_check_dnstap.m4 b/m4/pdns_check_dnstap.m4 index cd6dc49f46..1be83c676f 100644 --- a/m4/pdns_check_dnstap.m4 +++ b/m4/pdns_check_dnstap.m4 @@ -1,5 +1,4 @@ AC_DEFUN([PDNS_CHECK_DNSTAP], [ - AC_REQUIRE([PDNS_WITH_PROTOBUF]) AC_MSG_CHECKING([whether we will have dnstap]) AC_ARG_ENABLE([dnstap], AS_HELP_STRING([--enable-dnstap],[enable dnstap support @<:@default=$1@:>@]), @@ -28,8 +27,5 @@ AC_DEFUN([PDNS_CHECK_DNSTAP], [ AS_IF([test x"$FSTRM_LIBS" = "x"], [ AC_MSG_ERROR([dnstap requested but libfstrm was not found]) ]) - AS_IF([test "x$PROTOBUF_LIBS" = "x" -o x"$PROTOC" = "x"], [ - AC_MSG_ERROR([dnstap requested but protobuf was not found]) - ]) ]) ]) diff --git a/pdns/lwres.cc b/pdns/lwres.cc index fca41db91a..b9e1c0a0b8 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -49,8 +49,7 @@ #include "ednssubnet.hh" #include "query-local-address.hh" -#ifdef HAVE_PROTOBUF - +#include "rec-protozero.hh" #include "uuid-utils.hh" #ifdef HAVE_FSTRM @@ -121,7 +120,7 @@ static void logFstreamResponse(const std::shared_ptr>>& outgoingLoggers, boost::optional& message, boost::optional initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes, boost::optional& srcmask) +static void logOutgoingQuery(const std::shared_ptr>>& outgoingLoggers, boost::optional initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes, boost::optional& srcmask) { if (!outgoingLoggers) { return; @@ -139,29 +138,37 @@ static void logOutgoingQuery(const std::shared_ptrsetServerIdentity(SyncRes::s_serverID); + static thread_local std::string buffer; + buffer.clear(); + pdns::ProtoZero::Message m{buffer}; + m.setType(3); + m.setMessageIdentity(uuid); + m.setSocketFamily(ip.sin4.sin_family); + m.setSocketProtocol(doTCP); + m.setTo(ip); + m.setInBytes(bytes); + m.setTime(); + m.setId(qid); + m.setQuestion(domain, type, QClass::IN); + m.setToPort(ip.getPort()); + m.setServerIdentity(SyncRes::s_serverID); if (initialRequestId) { - message->setInitialRequestID(*initialRequestId); + m.setInitialRequestID(*initialRequestId); } if (srcmask) { - message->setEDNSSubnet(*srcmask); + m.setEDNSSubnet(*srcmask, 128); } -// cerr <serialize(str); - for (auto& logger : *outgoingLoggers) { if (logger->logQueries()) { - logger->queueData(str); + logger->queueData(buffer); } } } -static void logIncomingResponse(const std::shared_ptr>>& outgoingLoggers, boost::optional& message, boost::optional initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, boost::optional& srcmask, size_t bytes, int rcode, const std::vector& records, const struct timeval& queryTime, const std::set& exportTypes) +static void logIncomingResponse(const std::shared_ptr>>& outgoingLoggers, boost::optional initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, boost::optional& srcmask, size_t bytes, int rcode, const std::vector& records, const struct timeval& queryTime, const std::set& exportTypes) { if (!outgoingLoggers) { return; @@ -179,44 +186,49 @@ static void logIncomingResponse(const std::shared_ptrsetServerIdentity(SyncRes::s_serverID); - - if (initialRequestId) { - message->setInitialRequestID(*initialRequestId); - } + static thread_local std::string buffer; + buffer.clear(); + pdns::ProtoZero::RecMessage m{buffer}; + m.setType(4); + m.setMessageIdentity(uuid); + m.setSocketFamily(ip.sin4.sin_family); + m.setSocketProtocol(doTCP); + m.setTo(ip); + m.setInBytes(bytes); + m.setTime(); + m.setId(qid); + m.setQuestion(domain, type, QClass::IN); + m.setToPort(ip.getPort()); + m.setServerIdentity(SyncRes::s_serverID); - if (srcmask) { - message->setEDNSSubnet(*srcmask); - } + if (initialRequestId) { + m.setInitialRequestID(*initialRequestId); } - else { - message->updateTime(); - message->setType(DNSProtoBufMessage::IncomingResponse); - message->setBytes(bytes); + + if (srcmask) { + m.setEDNSSubnet(*srcmask, 128); } - message->setQueryTime(queryTime.tv_sec, queryTime.tv_usec); + m.startResponse(); + m.setQueryTime(queryTime.tv_sec, queryTime.tv_usec); if (rcode == -1) { - message->setNetworkErrorResponseCode(); + m.setNetworkErrorResponseCode(); } else { - message->setResponseCode(rcode); + m.setResponseCode(rcode); } - message->addRRs(records, exportTypes); -// cerr <serialize(str); + for (const auto& record : records) { + m.addRR(record, exportTypes, false); + } + m.commitResponse(); for (auto& logger : *outgoingLoggers) { if (logger->logResponses()) { - logger->queueData(str); + logger->queueData(buffer); } } } -#endif /* HAVE_PROTOBUF */ /** lwr is only filled out in case 1 was returned, and even when returning 1 for 'success', lwr might contain DNS errors Never throws! @@ -273,16 +285,14 @@ LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& domain, int dt.set(); *now=dt.getTimeval(); -#ifdef HAVE_PROTOBUF boost::uuids::uuid uuid; const struct timeval queryTime = *now; - boost::optional pbMessage = boost::none; if (outgoingLoggers) { uuid = getUniqueID(); - logOutgoingQuery(outgoingLoggers, pbMessage, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, vpacket.size(), srcmask); + logOutgoingQuery(outgoingLoggers, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, vpacket.size(), srcmask); } -#endif /* HAVE_PROTOBUF */ + #ifdef HAVE_FSTRM if (isEnabledForQueries(fstrmLoggers)) { logFstreamQuery(fstrmLoggers, queryTime, ip, doTCP, context ? context->d_auth : boost::none, vpacket); @@ -361,11 +371,9 @@ LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& domain, int *now=dt.getTimeval(); if (ret != LWResult::Result::Success) { // includes 'timeout' -#ifdef HAVE_PROTOBUF if (outgoingLoggers) { - logIncomingResponse(outgoingLoggers, pbMessage, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, srcmask, 0, -1, {}, queryTime, exportTypes); + logIncomingResponse(outgoingLoggers, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, srcmask, 0, -1, {}, queryTime, exportTypes); } -#endif return ret; } @@ -386,11 +394,9 @@ LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& domain, int lwr->d_rcode=mdp.d_header.rcode; if(mdp.d_header.rcode == RCode::FormErr && mdp.d_qname.empty() && mdp.d_qtype == 0 && mdp.d_qclass == 0) { -#ifdef HAVE_PROTOBUF if(outgoingLoggers) { - logIncomingResponse(outgoingLoggers, pbMessage, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, srcmask, len, lwr->d_rcode, lwr->d_records, queryTime, exportTypes); + logIncomingResponse(outgoingLoggers, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, srcmask, len, lwr->d_rcode, lwr->d_records, queryTime, exportTypes); } -#endif lwr->d_validpacket = true; return LWResult::Result::Success; // this is "success", the error is set in lwr->d_rcode } @@ -432,11 +438,9 @@ LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& domain, int } } -#ifdef HAVE_PROTOBUF if(outgoingLoggers) { - logIncomingResponse(outgoingLoggers, pbMessage, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, srcmask, len, lwr->d_rcode, lwr->d_records, queryTime, exportTypes); + logIncomingResponse(outgoingLoggers, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, srcmask, len, lwr->d_rcode, lwr->d_records, queryTime, exportTypes); } -#endif lwr->d_validpacket = true; return LWResult::Result::Success; @@ -450,11 +454,9 @@ LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& domain, int lwr->d_validpacket = false; g_stats.serverParseError++; -#ifdef HAVE_PROTOBUF if(outgoingLoggers) { - logIncomingResponse(outgoingLoggers, pbMessage, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, srcmask, len, lwr->d_rcode, lwr->d_records, queryTime, exportTypes); + logIncomingResponse(outgoingLoggers, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, srcmask, len, lwr->d_rcode, lwr->d_records, queryTime, exportTypes); } -#endif return LWResult::Result::Success; // success - oddly enough } diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 71b67b572d..11f426c80c 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -98,7 +98,6 @@ #endif /* NOD_ENABLED */ #include "query-local-address.hh" -#include "rec-protobuf.hh" #include "rec-snmp.hh" #ifdef HAVE_SYSTEMD @@ -107,10 +106,8 @@ #include "namespaces.hh" -#ifdef HAVE_PROTOBUF #include "uuid-utils.hh" #include "rec-protozero.hh" -#endif /* HAVE_PROTOBUF */ #include "xpf.hh" @@ -120,12 +117,10 @@ static thread_local std::shared_ptr t_pdl; static thread_local unsigned int t_id = 0; static thread_local std::shared_ptr t_traceRegex; static thread_local std::unique_ptr t_tcpClientCounts; -#ifdef HAVE_PROTOBUF static thread_local std::shared_ptr>> t_protobufServers{nullptr}; static thread_local uint64_t t_protobufServersGeneration; static thread_local std::shared_ptr>> t_outgoingProtobufServers{nullptr}; static thread_local uint64_t t_outgoingProtobufServersGeneration; -#endif /* HAVE_PROTOBUF */ #ifdef HAVE_FSTRM static thread_local std::shared_ptr>> t_frameStreamServers{nullptr}; @@ -330,13 +325,11 @@ struct DNSComboWriter { d_local holds our own. */ ComboAddress d_local; ComboAddress d_destination; -#ifdef HAVE_PROTOBUF boost::uuids::uuid d_uuid; string d_requestorId; string d_deviceId; string d_deviceName; struct timeval d_kernelTimestamp{0,0}; -#endif std::string d_query; std::unordered_set d_policyTags; std::string d_routingTag; @@ -883,7 +876,6 @@ catch(...) return "Exception making error message for exception"; } -#ifdef HAVE_PROTOBUF static void protobufLogQuery(uint8_t maskV4, uint8_t maskV6, const boost::uuids::uuid& uniqueId, const ComboAddress& remote, const ComboAddress& local, const Netmask& ednssubnet, bool tcp, uint16_t id, size_t len, const DNSName& qname, uint16_t qtype, uint16_t qclass, const std::unordered_set& policyTags, const std::string& requestorId, const std::string& deviceId, const std::string& deviceName) { if (!t_protobufServers) { @@ -924,7 +916,6 @@ static void protobufLogResponse(pdns::ProtoZero::RecMessage& message) server->queueData(msg); } } -#endif /** * Chases the CNAME provided by the PolicyCustom RPZ policy. @@ -1050,7 +1041,6 @@ static PolicyResult handlePolicyHit(const DNSFilterEngine::Policy& appliedPolicy return PolicyResult::NoAction; } -#ifdef HAVE_PROTOBUF static std::shared_ptr>> startProtobufServers(const ProtobufExportConfig& config) { auto result = std::make_shared>>(); @@ -1203,7 +1193,6 @@ static bool checkFrameStreamExport(LocalStateHolder& luaconfsLoc return true; } #endif /* HAVE_FSTRM */ -#endif /* HAVE_PROTOBUF */ #ifdef NOD_ENABLED static bool nodCheckNewDomain(const DNSName& dname) @@ -1434,7 +1423,6 @@ static void startDoResolve(void *p) // Used to tell syncres later on if we should apply NSDNAME and NSIP RPZ triggers for this query bool wantsRPZ(true); RecursorPacketCache::OptPBData pbDataForCache; -#ifdef HAVE_PROTOBUF pdns::ProtoZero::RecMessage pbMessage; if (checkProtobufExport(luaconfsLocal)) { pbMessage.reserve(128, 128); // It's a bit of a guess... @@ -1443,7 +1431,6 @@ static void startDoResolve(void *p) // RRSets added below } -#endif /* HAVE_PROTOBUF */ #ifdef HAVE_FSTRM checkFrameStreamExport(luaconfsLocal); @@ -1501,10 +1488,8 @@ static void startDoResolve(void *p) } sr.setDNSSECValidationRequested(g_dnssecmode == DNSSECMode::ValidateAll || g_dnssecmode==DNSSECMode::ValidateForLog || ((dc->d_mdp.d_header.ad || DNSSECOK) && g_dnssecmode==DNSSECMode::Process)); -#ifdef HAVE_PROTOBUF sr.setInitialRequestId(dc->d_uuid); sr.setOutgoingProtobufServers(t_outgoingProtobufServers); -#endif #ifdef HAVE_FSTRM sr.setFrameStreamServers(t_frameStreamServers); #endif @@ -1528,11 +1513,9 @@ static void startDoResolve(void *p) dq.currentRecords = &ret; dq.dh = &dc->d_mdp.d_header; dq.data = dc->d_data; -#ifdef HAVE_PROTOBUF dq.requestorId = dc->d_requestorId; dq.deviceId = dc->d_deviceId; dq.deviceName = dc->d_deviceName; -#endif dq.proxyProtocolValues = &dc->d_proxyProtocolValues; dq.extendedErrorCode = &dc->d_extendedErrorCode; dq.extendedErrorExtra = &dc->d_extendedErrorExtra; @@ -1844,11 +1827,9 @@ static void startDoResolve(void *p) } #endif /* NOD ENABLED */ -#ifdef HAVE_PROTOBUF if (t_protobufServers) { pbMessage.addRR(*i, luaconfsLocal->protobufExportConfig.exportTypes, udr); } -#endif } if(needCommit) pw.commit(); @@ -1965,7 +1946,6 @@ static void startDoResolve(void *p) } } #endif /* NOD_ENABLED */ -#ifdef HAVE_PROTOBUF if (t_protobufServers && !(luaconfsLocal->protobufExportConfig.taggedOnly && appliedPolicy.getName().empty() && dc->d_policyTags.empty())) { // Start constructing embedded DNSResponse object pbMessage.setResponseCode(pw.getHeader()->rcode); @@ -2025,7 +2005,7 @@ static void startDoResolve(void *p) protobufLogResponse(pbMessage); } } -#endif /* HAVE_PROTOBUF */ + if(!dc->d_tcp) { struct msghdr msgh; struct iovec iov; @@ -2476,14 +2456,13 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var) string deviceId; string deviceName; bool logQuery = false; -#ifdef HAVE_PROTOBUF + auto luaconfsLocal = g_luaconfs.getLocal(); if (checkProtobufExport(luaconfsLocal)) { needECS = true; } logQuery = t_protobufServers && luaconfsLocal->protobufExportConfig.logQueries; dc->d_logResponse = t_protobufServers && luaconfsLocal->protobufExportConfig.logResponses; -#endif /* HAVE_PROTOBUF */ #ifdef HAVE_FSTRM checkFrameStreamExport(luaconfsLocal); @@ -2527,7 +2506,6 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var) const struct dnsheader* dh = reinterpret_cast(&conn->data[0]); -#ifdef HAVE_PROTOBUF if(t_protobufServers || t_outgoingProtobufServers) { dc->d_requestorId = requestorId; dc->d_deviceId = deviceId; @@ -2548,7 +2526,7 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var) } } } -#endif + if (t_pdl) { if (t_pdl->ipfilter(dc->d_source, dc->d_destination, *dh)) { if (!g_quiet) { @@ -2711,7 +2689,6 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr string routingTag; bool logQuery = false; bool logResponse = false; -#ifdef HAVE_PROTOBUF boost::uuids::uuid uniqueId; auto luaconfsLocal = g_luaconfs.getLocal(); if (checkProtobufExport(luaconfsLocal)) { @@ -2722,7 +2699,6 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr } logQuery = t_protobufServers && luaconfsLocal->protobufExportConfig.logQueries; logResponse = t_protobufServers && luaconfsLocal->protobufExportConfig.logResponses; -#endif #ifdef HAVE_FSTRM checkFrameStreamExport(luaconfsLocal); #endif @@ -2796,13 +2772,12 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr bool cacheHit = false; RecursorPacketCache::OptPBData pbData{boost::none}; -#ifdef HAVE_PROTOBUF + if (t_protobufServers) { if (logQuery && !(luaconfsLocal->protobufExportConfig.taggedOnly && policyTags.empty())) { protobufLogQuery(luaconfsLocal->protobufMaskV4, luaconfsLocal->protobufMaskV6, uniqueId, source, destination, ednssubnet.source, false, dh->id, question.size(), qname, qtype, qclass, policyTags, requestorId, deviceId, deviceName); } } -#endif /* HAVE_PROTOBUF */ /* It might seem like a good idea to skip the packet cache lookup if we know that the answer is not cacheable, but it means that the hash would not be computed. If some script decides at a later time to mark back the answer @@ -2823,8 +2798,7 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr t_bogusqueryring->push_back(make_pair(qname, qtype)); } -#ifdef HAVE_PROTOBUF - if(t_protobufServers && logResponse && !(luaconfsLocal->protobufExportConfig.taggedOnly && pbData && !pbData->d_tagged)) { // XXX + if (t_protobufServers && logResponse && !(luaconfsLocal->protobufExportConfig.taggedOnly && pbData && !pbData->d_tagged)) { // XXX pdns::ProtoZero::RecMessage pbMessage(pbData ? pbData->d_message : "", pbData ? pbData->d_response : "", 64, 10); // The extra bytes we are going to add if (pbData) { // We take the inmutable string from the cache and are appending a few values @@ -2863,7 +2837,7 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr #endif protobufLogResponse(pbMessage); } -#endif /* HAVE_PROTOBUF */ + if(!g_quiet) g_log<d_followCNAMERecords = followCNAMEs; dc->d_rcode = rcode; dc->d_logResponse = logResponse; -#ifdef HAVE_PROTOBUF if (t_protobufServers || t_outgoingProtobufServers) { dc->d_uuid = std::move(uniqueId); } @@ -2943,7 +2916,6 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr dc->d_deviceId = deviceId; dc->d_deviceName = deviceName; dc->d_kernelTimestamp = tv; -#endif dc->d_proxyProtocolValues = std::move(proxyProtocolValues); dc->d_routingTag = std::move(routingTag); dc->d_extendedErrorCode = extendedErrorCode; @@ -4996,9 +4968,6 @@ static int serviceMain(int argc, char*argv[]) } } -#ifdef HAVE_PROTOBUF - google::protobuf::ShutdownProtobufLibrary(); -#endif /* HAVE_PROTOBUF */ return ret; } @@ -5076,12 +5045,10 @@ try MT=std::unique_ptr >(new MTasker(::arg().asNum("stack-size"))); threadInfo.mt = MT.get(); -#ifdef HAVE_PROTOBUF /* start protobuf export threads if needed */ auto luaconfsLocal = g_luaconfs.getLocal(); checkProtobufExport(luaconfsLocal); checkOutgoingProtobufExport(luaconfsLocal); -#endif /* HAVE_PROTOBUF */ #ifdef HAVE_FSTRM checkFrameStreamExport(luaconfsLocal); #endif diff --git a/pdns/protozero.hh b/pdns/protozero.hh index 7a767af1be..7d4f49ed30 100644 --- a/pdns/protozero.hh +++ b/pdns/protozero.hh @@ -127,11 +127,9 @@ namespace pdns { } } - void setInitialRequesId(const std::string& id) + void setInitialRequestID(const boost::uuids::uuid& uniqueId) { - if (!id.empty()) { - d_message.add_string(16, id); - } + d_message.add_bytes(16, reinterpret_cast(uniqueId.begin()), uniqueId.size()); } void setDeviceId(const std::string& id) @@ -178,6 +176,12 @@ namespace pdns { d_response.add_uint32(1, rcode); } + void setNetworkErrorResponseCode() + { + /* special code meaning 'network error', like a timeout */ + d_response.add_uint32(1, 65536); + } + void setAppliedPolicy(const std::string& policy) { d_response.add_string(3, policy); diff --git a/pdns/rec-lua-conf.cc b/pdns/rec-lua-conf.cc index 7532c8a487..fa6a4c13bd 100644 --- a/pdns/rec-lua-conf.cc +++ b/pdns/rec-lua-conf.cc @@ -109,7 +109,6 @@ static void parseRPZParameters(rpzOptions_t& have, std::shared_ptr > > > protobufOptions_t; static void parseProtobufOptions(boost::optional vars, ProtobufExportConfig& config) @@ -168,7 +167,6 @@ static void parseProtobufOptions(boost::optional vars, Protob } } } -#endif /* HAVE_PROTOBUF */ #ifdef HAVE_FSTRM typedef std::unordered_map > > > frameStreamOptions_t; @@ -487,7 +485,6 @@ void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& de updateTrustAnchorsFromFile(fnamearg, lci.dsAnchors); }); -#if HAVE_PROTOBUF Lua.writeFunction("setProtobufMasks", [&lci](const uint8_t maskV4, uint8_t maskV6) { lci.protobufMaskV4 = maskV4; lci.protobufMaskV6 = maskV6; @@ -556,7 +553,6 @@ void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& de g_log<> servers, boost::optional vars) { diff --git a/pdns/recpacketcache.cc b/pdns/recpacketcache.cc index a938c12cd5..bbccffd26d 100644 --- a/pdns/recpacketcache.cc +++ b/pdns/recpacketcache.cc @@ -71,7 +71,7 @@ bool RecursorPacketCache::checkResponseMatches(std::pair(d_packetCache, iter); -#ifdef HAVE_PROTOBUF + if (pbdata != nullptr) { if (iter->d_pbdata) { *pbdata = iter->d_pbdata; @@ -79,7 +79,7 @@ bool RecursorPacketCache::checkResponseMatches(std::paird_ttd = now + ttl; iter->d_creation = now; iter->d_vstate = valState; -#ifdef HAVE_PROTOBUF + if (pbdata) { iter->d_pbdata = std::move(*pbdata); } -#endif break; } @@ -176,11 +175,11 @@ void RecursorPacketCache::insertResponsePacket(unsigned int tag, uint32_t qhash, e.d_creation = now; e.d_tag = tag; e.d_vstate = valState; -#ifdef HAVE_PROTOBUF + if (pbdata) { e.d_pbdata = std::move(*pbdata); } -#endif + d_packetCache.insert(e); } } diff --git a/pdns/recpacketcache.hh b/pdns/recpacketcache.hh index 75400b14b4..aae60d9549 100644 --- a/pdns/recpacketcache.hh +++ b/pdns/recpacketcache.hh @@ -38,8 +38,6 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "rec-protobuf.hh" - using namespace ::boost::multi_index; @@ -86,9 +84,7 @@ private: DNSName d_name; mutable std::string d_packet; // "I know what I am doing" mutable std::string d_query; -#ifdef HAVE_PROTOBUF mutable OptPBData d_pbdata; -#endif mutable time_t d_ttd; mutable time_t d_creation; // so we can 'age' our packets uint32_t d_qhash; diff --git a/pdns/recursordist/Makefile.am b/pdns/recursordist/Makefile.am index 16ea652280..8f7f0ac05a 100644 --- a/pdns/recursordist/Makefile.am +++ b/pdns/recursordist/Makefile.am @@ -143,7 +143,6 @@ pdns_recursor_SOURCES = \ pdns_recursor.cc \ pdnsexception.hh \ pollmplexer.cc \ - protobuf.cc protobuf.hh \ protozero.cc protozero.hh \ proxy-protocol.cc proxy-protocol.hh \ pubsuffix.hh pubsuffix.cc \ @@ -153,7 +152,6 @@ pdns_recursor_SOURCES = \ rcpgenerator.cc rcpgenerator.hh \ rec-carbon.cc \ rec-lua-conf.hh rec-lua-conf.cc \ - rec-protobuf.cc rec-protobuf.hh \ rec-protozero.cc rec-protozero.hh \ rec-snmp.hh rec-snmp.cc \ rec_channel.cc rec_channel.hh rec_metrics.hh \ @@ -257,11 +255,9 @@ testrunner_SOURCES = \ opensslsigners.cc opensslsigners.hh \ pdnsexception.hh \ pollmplexer.cc \ - protobuf.cc protobuf.hh \ qtype.cc qtype.hh \ query-local-address.hh query-local-address.cc \ rcpgenerator.cc \ - rec-protobuf.cc rec-protobuf.hh \ recpacketcache.cc recpacketcache.hh \ recursor_cache.cc recursor_cache.hh \ resolver.hh resolver.cc \ @@ -394,24 +390,6 @@ testrunner_SOURCES += \ portsmplexer.cc endif -if HAVE_PROTOBUF -if HAVE_PROTOC -dnsmessage.pb.cc: dnsmessage.proto - $(AM_V_GEN)$(PROTOC) --cpp_out=./ $< - -BUILT_SOURCES += dnsmessage.pb.cc -pdns_recursor_LDADD += $(PROTOBUF_LIBS) -nodist_pdns_recursor_SOURCES = dnsmessage.pb.cc dnsmessage.pb.h -nodist_testrunner_SOURCES = dnsmessage.pb.cc dnsmessage.pb.h - -pdns_recursor.$(OBJEXT): dnsmessage.pb.cc -testrunner$(OBJEXT): dnsmessage.pb.cc - -testrunner_LDADD += $(PROTOBUF_LIBS) - -endif -endif - if FSTRM pdns_recursor_SOURCES += \ dnstap.cc dnstap.hh diff --git a/pdns/recursordist/configure.ac b/pdns/recursordist/configure.ac index f5f525ad5e..950b3d48d5 100644 --- a/pdns/recursordist/configure.ac +++ b/pdns/recursordist/configure.ac @@ -42,8 +42,6 @@ PTHREAD_SET_NAME PDNS_CHECK_CLOCK_GETTIME -PDNS_WITH_PROTOBUF - BOOST_REQUIRE([1.42]) # Check against flat_set header that requires boost >= 1.48 @@ -206,10 +204,9 @@ AS_IF([test "x$LIBDECAF_LIBS" != "x" || test "x$libcrypto_ed448" = "xyes"], [AC_MSG_NOTICE([ed448: yes])], [AC_MSG_NOTICE([ed448: no])] ) -AS_IF([test "x$PROTOBUF_LIBS" != "x" -a x"$PROTOC" != "x"], - [AC_MSG_NOTICE([Protobuf: yes])], - [AC_MSG_NOTICE([Protobuf: no])] -) + +AC_MSG_NOTICE([Protobuf: yes]) + AS_IF([test "x$NET_SNMP_LIBS" != "x"], [AC_MSG_NOTICE([SNMP: yes])], [AC_MSG_NOTICE([SNMP: no])] diff --git a/pdns/recursordist/m4/pdns_with_protobuf.m4 b/pdns/recursordist/m4/pdns_with_protobuf.m4 deleted file mode 120000 index bdfe381da6..0000000000 --- a/pdns/recursordist/m4/pdns_with_protobuf.m4 +++ /dev/null @@ -1 +0,0 @@ -../../../m4/pdns_with_protobuf.m4 \ No newline at end of file diff --git a/pdns/recursordist/rec-protozero.hh b/pdns/recursordist/rec-protozero.hh index 74f208651f..42eba70ad2 100644 --- a/pdns/recursordist/rec-protozero.hh +++ b/pdns/recursordist/rec-protozero.hh @@ -33,6 +33,12 @@ namespace pdns { { d_response = protozero::pbf_writer(d_rspbuf); } + + RecMessage(std::string& buffer): Message(buffer) + { + d_response = protozero::pbf_writer(buffer); + } + // Start a new messagebuf, containing separate data for the response part RecMessage(std::string::size_type sz1, std::string::size_type sz2): RecMessage() { diff --git a/pdns/resolve-context.hh b/pdns/resolve-context.hh index 7ad9bf553b..5782961249 100644 --- a/pdns/resolve-context.hh +++ b/pdns/resolve-context.hh @@ -2,10 +2,8 @@ #include "config.h" -#ifdef HAVE_PROTOBUF #include #include -#endif struct ResolveContext { ResolveContext() @@ -15,9 +13,7 @@ struct ResolveContext { ResolveContext(const ResolveContext& ctx) = delete; ResolveContext & operator=(const ResolveContext&) = delete; -#ifdef HAVE_PROTOBUF boost::optional d_initialRequestId; -#endif #ifdef HAVE_FSTRM boost::optional d_auth; #endif diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 87d26e4e7d..cfc8ad56f2 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -574,9 +574,7 @@ LWResult::Result SyncRes::asyncresolveWrapper(const ComboAddress& ip, bool ednsM int EDNSLevel = 0; auto luaconfsLocal = g_luaconfs.getLocal(); ResolveContext ctx; -#ifdef HAVE_PROTOBUF ctx.d_initialRequestId = d_initialRequestId; -#endif #ifdef HAVE_FSTRM ctx.d_auth = auth; #endif diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 8581459b8a..f1a3212865 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -56,12 +56,10 @@ #include "config.h" #endif -#ifdef HAVE_PROTOBUF #include #ifdef HAVE_FSTRM #include "fstrm_logger.hh" #endif /* HAVE_FSTRM */ -#endif extern GlobalStateHolder g_dontThrottleNames; extern GlobalStateHolder g_dontThrottleNetmasks; @@ -684,7 +682,6 @@ public: void setQuerySource(const ComboAddress& requestor, boost::optional incomingECS); -#ifdef HAVE_PROTOBUF void setInitialRequestId(boost::optional initialRequestId) { d_initialRequestId = initialRequestId; @@ -694,7 +691,6 @@ public: { d_outgoingProtobufServers = servers; } -#endif #ifdef HAVE_FSTRM void setFrameStreamServers(std::shared_ptr>>& servers) @@ -875,9 +871,7 @@ private: boost::optional d_outgoingECSNetwork; std::shared_ptr>> d_outgoingProtobufServers{nullptr}; std::shared_ptr>> d_frameStreamServers{nullptr}; -#ifdef HAVE_PROTOBUF boost::optional d_initialRequestId; -#endif asyncresolve_t d_asyncResolve{nullptr}; struct timeval d_now; string d_prefix; diff --git a/pdns/version.cc b/pdns/version.cc index 2b7a513ec5..7b6d154753 100644 --- a/pdns/version.cc +++ b/pdns/version.cc @@ -122,9 +122,7 @@ void showBuildConfiguration() #ifdef HAVE_P11KIT1 "PKCS#11 " << #endif -#ifdef HAVE_PROTOBUF "protobuf " << -#endif #ifdef HAVE_FSTRM "dnstap-framestream " << #endif