time_t d_ctime{0}; //!< last known ctime of the file on disk
time_t d_lastcheck{0}; //!< last time domain was checked for freshness
uint32_t d_lastnotified{0}; //!< Last serial number we notified our secondaries of
- unsigned int d_id{0}; //!< internal id of the domain
+ domainid_t d_id{0}; //!< internal id of the domain
mutable bool d_checknow; //!< if this domain has been flagged for a check
bool d_loaded{false}; //!< if a domain is loaded
bool d_wasRejectedLastReload{false}; //!< if the domain was rejected during Bind2Backend::queueReloadAndStore
// end of DNSSEC
typedef multi_index_container<BB2DomainInfo,
- indexed_by<ordered_unique<member<BB2DomainInfo, unsigned int, &BB2DomainInfo::d_id>>,
+ indexed_by<ordered_unique<member<BB2DomainInfo, domainid_t, &BB2DomainInfo::d_id>>,
ordered_unique<tag<NameTag>, member<BB2DomainInfo, ZoneName, &BB2DomainInfo::d_name>>>>
state_t;
static SharedLockGuarded<state_t> s_state;
}
// called from ueberbackend
-bool AuthQueryCache::getEntry(const DNSName &qname, const QType& qtype, vector<DNSZoneRecord>& value, int zoneID)
+bool AuthQueryCache::getEntry(const DNSName &qname, const QType& qtype, vector<DNSZoneRecord>& value, domainid_t zoneID)
{
cleanupIfNeeded();
}
}
-void AuthQueryCache::insert(const DNSName &qname, const QType& qtype, vector<DNSZoneRecord>&& value, uint32_t ttl, int zoneID)
+void AuthQueryCache::insert(const DNSName &qname, const QType& qtype, vector<DNSZoneRecord>&& value, uint32_t ttl, domainid_t zoneID)
{
cleanupIfNeeded();
}
}
-bool AuthQueryCache::getEntryLocked(const cmap_t& map, const DNSName &qname, uint16_t qtype, vector<DNSZoneRecord>& value, int zoneID, time_t now)
+bool AuthQueryCache::getEntryLocked(const cmap_t& map, const DNSName &qname, uint16_t qtype, vector<DNSZoneRecord>& value, domainid_t zoneID, time_t now)
{
auto& idx = boost::multi_index::get<HashTag>(map);
auto iter = idx.find(std::tie(qname, qtype, zoneID));
public:
AuthQueryCache(size_t mapsCount=1024);
- void insert(const DNSName &qname, const QType& qtype, vector<DNSZoneRecord>&& content, uint32_t ttl, int zoneID);
+ void insert(const DNSName &qname, const QType& qtype, vector<DNSZoneRecord>&& value, uint32_t ttl, domainid_t zoneID);
- bool getEntry(const DNSName &qname, const QType& qtype, vector<DNSZoneRecord>& entry, int zoneID);
+ bool getEntry(const DNSName &qname, const QType& qtype, vector<DNSZoneRecord>& value, domainid_t zoneID);
size_t size() { return *d_statnumentries; } //!< number of entries in the cache
void cleanup(); //!< force the cache to preen itself from expired queries
mutable vector<DNSZoneRecord> drs;
mutable time_t ttd{0};
uint16_t qtype{0};
- int zoneID{-1};
+ domainid_t zoneID{UnknownDomainID};
};
struct HashTag{};
return d_maps[qname.hash() % d_maps.size()];
}
- bool getEntryLocked(const cmap_t& map, const DNSName &content, uint16_t qtype, vector<DNSZoneRecord>& entry, int zoneID, time_t now);
+ bool getEntryLocked(const cmap_t& map, const DNSName &qname, uint16_t qtype, vector<DNSZoneRecord>& value, domainid_t zoneID, time_t now);
void cleanupIfNeeded();
AtomicCounter d_ops{0};
}
}
-void AuthZoneCache::replace(const vector<std::tuple<ZoneName, int>>& zone_indices)
+void AuthZoneCache::replace(const vector<std::tuple<ZoneName, domainid_t>>& zone_indices)
{
if (!d_refreshinterval)
return;
views->swap(viewsmap);
}
-void AuthZoneCache::add(const ZoneName& zone, const int zoneId)
+void AuthZoneCache::add(const ZoneName& zone, const domainid_t zoneId)
{
if (!d_refreshinterval)
return;
CacheValue val;
val.zoneId = zoneId;
- int mapIndex = getMapIndex(zone);
+ auto mapIndex = getMapIndex(zone);
{
auto& mc = d_maps[mapIndex];
auto map = mc.d_map.write_lock();
{
auto pending = d_pending.lock();
if (pending->d_replacePending) {
- pending->d_pendingUpdates.emplace_back(zone, -1, false);
+ pending->d_pendingUpdates.emplace_back(zone, UnknownDomainID, false);
}
}
- int mapIndex = getMapIndex(zone);
+ auto mapIndex = getMapIndex(zone);
{
auto& mc = d_maps[mapIndex];
auto map = mc.d_map.write_lock();
using ViewsMap = std::map<std::string, std::map<DNSName, std::string>>;
// Zone maintainance
- void replace(const vector<std::tuple<ZoneName, int>>& zone);
+ void replace(const vector<std::tuple<ZoneName, domainid_t>>& zone);
void replace(NetmaskTree<string> nettree);
void replace(ViewsMap viewsmap);
- void add(const ZoneName& zone, const int zoneId);
+ void add(const ZoneName& zone, const domainid_t zoneId);
void remove(const ZoneName& zone);
void setReplacePending(); //!< call this when data collection for the subsequent replace() call starts.
struct CacheValue
{
- int zoneId{-1};
+ domainid_t zoneId{UnknownDomainID};
};
typedef std::unordered_map<ZoneName, CacheValue, std::hash<ZoneName>> cmap_t;
struct PendingData
{
- std::vector<std::tuple<ZoneName, int, bool>> d_pendingUpdates;
+ std::vector<std::tuple<ZoneName, domainid_t, bool>> d_pendingUpdates;
bool d_replacePending{false};
};
LockGuarded<PendingData> d_pending;
}
zoneId = domaininfo.id;
}
- // Safe for zoneId to be -1 here - it won't be the case for variants, see above
+ // Safe for zoneId to be UnknownDomainID here - it won't be the case for variants, see above
this->lookup(QType(QType::SOA), domain.operator const DNSName&(), zoneId);
S.inc("backend-queries");
return ranked.begin()->second[dns_random(ranked.begin()->second.size())];
}
-static std::vector<DNSZoneRecord> lookup(const DNSName& name, uint16_t qtype, int zoneid)
+static std::vector<DNSZoneRecord> lookup(const DNSName& name, uint16_t qtype, domainid_t zoneid)
{
static LockGuarded<UeberBackend> s_ub;
}
}
-static std::vector<std::shared_ptr<EntryHashesHolder>> getCHashedEntries(const int zoneId, const std::string& queryName, const std::vector<std::pair<int, std::string>>& items)
+static std::vector<std::shared_ptr<EntryHashesHolder>> getCHashedEntries(const domainid_t zoneId, const std::string& queryName, const std::vector<std::pair<int, std::string>>& items)
{
std::vector<std::shared_ptr<EntryHashesHolder>> result{};
std::map<zone_hashes_key_t, std::shared_ptr<EntryHashesHolder>> newEntries{};
return false;
}
-bool UeberBackend::fillSOAFromZoneRecord(ZoneName& shorter, const int zoneId, SOAData* const soaData)
+bool UeberBackend::fillSOAFromZoneRecord(ZoneName& shorter, const domainid_t zoneId, SOAData* const soaData)
{
// Zone exists in zone cache, directly look up SOA.
lookup(QType(QType::SOA), shorter.operator const DNSName&(), zoneId, nullptr);
while (first || shorter.chopOff()) {
first = false;
- int zoneId{-1};
+ domainid_t zoneId{UnknownDomainID};
if (cachedOk && g_zoneCache.isEnabled()) {
std::string variant = g_zoneCache.getVariantFromView(shorter, view);
{
d_question.qtype = QType::SOA;
d_question.qname = domain.operator const DNSName&();
- d_question.zoneId = -1;
+ d_question.zoneId = UnknownDomainID;
for (auto& backend : backends) {
// Do not risk passing variant zones to variant-unaware backends.
}
// this handle is more magic than most
-void UeberBackend::lookup(const QType& qtype, const DNSName& qname, int zoneId, DNSPacket* pkt_p)
+void UeberBackend::lookup(const QType& qtype, const DNSName& qname, domainid_t zoneId, DNSPacket* pkt_p)
{
if (d_stale) {
g_log << Logger::Error << "Stale ueberbackend received question, signalling that we want to be recycled" << endl;
//! Index of the current backend within the backends vector
unsigned int i{0};
QType qtype;
- int zoneId{-1};
+ domainid_t zoneId{UnknownDomainID};
private:
static AtomicCounter instances;
};
- void lookup(const QType& qtype, const DNSName& qname, int zoneId, DNSPacket* pkt_p = nullptr);
+ void lookup(const QType& qtype, const DNSName& qname, domainid_t zoneId, DNSPacket* pkt_p = nullptr);
/** Read a single record from a lookup(...) result. */
bool get(DNSZoneRecord& resourceRecord);
/** Close state created by lookup(...). */
struct Question
{
DNSName qname;
- int zoneId;
+ domainid_t zoneId;
QType qtype;
} d_question;
void addNegCache(const Question& question) const;
void addCache(const Question& question, vector<DNSZoneRecord>&& rrs) const;
- bool fillSOAFromZoneRecord(ZoneName& shorter, int zoneId, SOAData* soaData);
+ bool fillSOAFromZoneRecord(ZoneName& shorter, domainid_t zoneId, SOAData* soaData);
CacheResult fillSOAFromCache(SOAData* soaData, ZoneName& shorter);
};