#endif
}
- const bool intoPC = g_packetCache && !variableAnswer && !resolver.wasVariable();
+ const bool intoPC = g_packetCache && !variableAnswer && !resolver.wasVariable() && (RecursorPacketCache::s_maxEntrySize == 0 || packet.size() <= RecursorPacketCache::s_maxEntrySize);
if (intoPC) {
minTTL = capPacketCacheTTL(*packetWriter.getHeader(), minTTL, seenAuthSOA);
g_packetCache->insertResponsePacket(comboWriter->d_tag, comboWriter->d_qhash, std::move(comboWriter->d_query), comboWriter->d_mdp.d_qname,
pdns::RecResolve::setInstanceParameters(arg()["server-id"], ttl, interval, selfResolveCheck, []() { reloadZoneConfiguration(g_yamlSettings); });
}
+ MemRecursorCache::s_maxEntrySize = ::arg().asNum("max-recordcache-entry-size");
+ RecursorPacketCache::s_maxEntrySize = ::arg().asNum("max-packetcache-entry-size");
g_recCache = std::make_unique<MemRecursorCache>(::arg().asNum("record-cache-shards"));
g_negCache = std::make_unique<NegCache>(::arg().asNum("record-cache-shards") / 8);
if (!::arg().mustDo("disable-packetcache")) {
''',
'versionchanged': ('4.1.0', 'The minimum value of this setting is 15. i.e. setting this to lower than 15 will make this value 15.')
},
+ {
+ 'name' : 'max_entry_size',
+ 'section' : 'recordcache',
+ 'oldname': 'max-recordcache-entry-size',
+ 'type' : LType.Uint64,
+ 'default' : '8192',
+ 'help' : 'maximum storage size of a recordset stored in record cache',
+ 'doc' : '''
+Maximum size of storage used by a single record cache entry. Entries larger than this number will not be stored.
+Zero means no limit.
+''',
+ 'versionadded': ['5.1.10', '5.2.8', '5.3.5', '5.4.0'],
+ },
{
'name' : 'max_concurrent_requests_per_tcp_connection',
'section' : 'incoming',
''',
'runtime': 'set-max-packetcache-entries',
},
+ {
+ 'name' : 'max_entry_size',
+ 'section' : 'packetcache',
+ 'oldname' : 'max-packetcache-entry-size',
+ 'type' : LType.Uint64,
+ 'default' : '8192',
+ 'help' : 'maximum size of a packet stored in the the packet cache',
+ 'doc' : '''
+Maximum size of packets stored in the packet cache. Packets larger than this number will not be stored.
+Zero means no limit.
+''',
+ 'versionadded': ['5.1.10', '5.2.8', '5.3.5', '5.4.0'],
+ },
{
'name' : 'max_qperq',
'section' : 'outgoing',
#include "rec-taskqueue.hh"
unsigned int RecursorPacketCache::s_refresh_ttlperc{0};
+uint32_t RecursorPacketCache::s_maxEntrySize{8192};
void RecursorPacketCache::setShardSizes(size_t shardSize)
{
{
public:
static unsigned int s_refresh_ttlperc;
+ static uint32_t s_maxEntrySize;
struct PBData
{
uint16_t MemRecursorCache::s_maxServedStaleExtensions;
uint16_t MemRecursorCache::s_maxRRSetSize = 256;
bool MemRecursorCache::s_limitQTypeAny = true;
+uint32_t MemRecursorCache::s_maxEntrySize = 8192;
const MemRecursorCache::AuthRecs MemRecursorCache::s_emptyAuthRecs = std::make_shared<MemRecursorCache::AuthRecsVec>();
const MemRecursorCache::SigRecs MemRecursorCache::s_emptySigRecs = std::make_shared<MemRecursorCache::SigRecsVec>();
SyncRes::s_minimumTTL = 0;
s_maxRRSetSize = 256;
s_limitQTypeAny = true;
+ s_maxEntrySize = 8192;
}
MemRecursorCache::MemRecursorCache(size_t mapsCount) :
}
}
+ auto storeSize = cacheEntry.sizeEstimate();
+ if (s_maxEntrySize > 0 && storeSize > s_maxEntrySize) {
+ return;
+ }
if (!isNew) {
moveCacheItemToBack<SequencedTag>(lockedShard->d_map, stored);
}
// but mark it as too big. Subsequent gets will cause an ImmediateServFailException to be thrown.
static uint16_t s_maxRRSetSize;
static bool s_limitQTypeAny;
+ static uint32_t s_maxEntrySize;
[[nodiscard]] size_t size() const;
[[nodiscard]] size_t bytes();
BOOST_AUTO_TEST_CASE(test_RecursorCacheBig)
{
MemRecursorCache::resetStaticsForTests();
+ MemRecursorCache::s_maxEntrySize = 64 * 1024;
MemRecursorCache MRC;
std::vector<DNSRecord> records;