From 13dacc771accd53b087b2b14060afacaf2969802 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 16 Apr 2018 17:12:27 +0200 Subject: [PATCH] rec: Stop the obsolete RPZ threads after a Lua configuration reload --- pdns/rec-lua-conf.cc | 2 +- pdns/rec-lua-conf.hh | 4 ++-- pdns/rpzloader.cc | 13 +++++++++++-- pdns/rpzloader.hh | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pdns/rec-lua-conf.cc b/pdns/rec-lua-conf.cc index 2098fbfa0..5f8d1d2eb 100644 --- a/pdns/rec-lua-conf.cc +++ b/pdns/rec-lua-conf.cc @@ -199,7 +199,7 @@ void loadRecursorLuaConfig(const std::string& fname, bool checkOnly) try { if (!checkOnly) { - std::thread t(RPZIXFRTracker, master, defpol, maxTTL, zoneIdx, tt, maxReceivedXFRMBytes * 1024 * 1024, localAddress, zone, axfrTimeout); + std::thread t(RPZIXFRTracker, master, defpol, maxTTL, zoneIdx, tt, maxReceivedXFRMBytes * 1024 * 1024, localAddress, zone, axfrTimeout, lci.generation); t.detach(); } } diff --git a/pdns/rec-lua-conf.hh b/pdns/rec-lua-conf.hh index 2d3ef4185..a502a2093 100644 --- a/pdns/rec-lua-conf.hh +++ b/pdns/rec-lua-conf.hh @@ -43,11 +43,11 @@ public: DNSFilterEngine dfe; map dsAnchors; map negAnchors; + ProtobufExportConfig protobufExportConfig; + ProtobufExportConfig outgoingProtobufExportConfig; /* we need to increment this every time the configuration is reloaded, so we know if we need to reload the protobuf remote loggers */ - ProtobufExportConfig protobufExportConfig; - ProtobufExportConfig outgoingProtobufExportConfig; uint64_t generation{0}; uint8_t protobufMaskV4{32}; uint8_t protobufMaskV6{128}; diff --git a/pdns/rpzloader.cc b/pdns/rpzloader.cc index 0473ceac1..79aa90dd7 100644 --- a/pdns/rpzloader.cc +++ b/pdns/rpzloader.cc @@ -283,7 +283,7 @@ static void setRPZZoneNewState(const std::string& zone, uint32_t serial, uint64_ stats->d_numberOfRecords = numberOfRecords; } -void RPZIXFRTracker(const ComboAddress& master, boost::optional defpol, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, std::shared_ptr zone, const uint16_t axfrTimeout) +void RPZIXFRTracker(const ComboAddress& master, boost::optional defpol, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, std::shared_ptr zone, const uint16_t axfrTimeout, uint64_t configGeneration) { uint32_t refresh = zone->getRefresh(); DNSName zoneName = zone->getDomain(); @@ -317,12 +317,22 @@ void RPZIXFRTracker(const ComboAddress& master, boost::optionalgeneration != configGeneration) { + /* the configuration has been reloaded, meaning that a new thread + has been started to handle that zone and we are now obsolete. + */ + g_log<(dr)->d_st.serial<, vector > > deltas; @@ -341,7 +351,6 @@ void RPZIXFRTracker(const ComboAddress& master, boost::optional oldZone = luaconfsLocal->dfe.getZone(zoneIdx); /* we need to make a _full copy_ of the zone we are going to work on */ std::shared_ptr newZone = std::make_shared(*oldZone); diff --git a/pdns/rpzloader.hh b/pdns/rpzloader.hh index ac47bfb22..465bc8765 100644 --- a/pdns/rpzloader.hh +++ b/pdns/rpzloader.hh @@ -29,7 +29,7 @@ extern bool g_logRPZChanges; void loadRPZFromFile(const std::string& fname, std::shared_ptr zone, boost::optional defpol, uint32_t maxTTL); std::shared_ptr loadRPZFromServer(const ComboAddress& master, const DNSName& zoneName, std::shared_ptr zone, boost::optional defpol, uint32_t maxTTL, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout); void RPZRecordToPolicy(const DNSRecord& dr, std::shared_ptr zone, bool addOrRemove, boost::optional defpol, uint32_t maxTTL); -void RPZIXFRTracker(const ComboAddress& master, boost::optional defpol, uint32_t maxTTL, size_t polZone, const TSIGTriplet &tt, size_t maxReceivedBytes, const ComboAddress& localAddress, std::shared_ptr zone, uint16_t axfrTimeout); +void RPZIXFRTracker(const ComboAddress& master, boost::optional defpol, uint32_t maxTTL, size_t polZone, const TSIGTriplet &tt, size_t maxReceivedBytes, const ComboAddress& localAddress, std::shared_ptr zone, uint16_t axfrTimeout, uint64_t configGeneration); struct rpzStats { -- 2.40.0