Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 016e344d authored by Ken Chen's avatar Ken Chen
Browse files

Allow setting values lower than MAX_ENTRIES_DEFAULT in max_cache_entries

Adjust the lower bound of max_cache_entries from
MAX_ENTRIES_DEFAULT(640) to 0. So we can do experiments with values
like 320.

Bug: 241953569
Test: atest resolv_unit_test
Change-Id: I4da710dccf4efe0edc625221b2519050069e0ba6
parent 607f74e7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -154,6 +154,7 @@ using std::span;
 * *****************************************
 */
const int MAX_ENTRIES_DEFAULT = 64 * 2 * 5;
const int MAX_ENTRIES_LOWER_BOUND = 0;
const int MAX_ENTRIES_UPPER_BOUND = 100 * 1000;
constexpr int DNSEVENT_SUBSAMPLING_MAP_DEFAULT_KEY = -1;

@@ -1007,7 +1008,7 @@ struct Cache {
                                                                        MAX_ENTRIES_DEFAULT);
        // Check both lower and upper bounds to prevent irrational values mistakenly pushed by
        // server.
        if (entries < MAX_ENTRIES_DEFAULT || entries > MAX_ENTRIES_UPPER_BOUND) {
        if (entries < MAX_ENTRIES_LOWER_BOUND || entries > MAX_ENTRIES_UPPER_BOUND) {
            LOG(ERROR) << "Misconfiguration on max_cache_entries " << entries;
            entries = MAX_ENTRIES_DEFAULT;
        }
+5 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ constexpr int DNS_PORT = 53;
// Constant values sync'd from res_cache.cpp
constexpr int DNS_HEADER_SIZE = 12;
constexpr int MAX_ENTRIES_DEFAULT = 64 * 2 * 5;
constexpr int MAX_ENTRIES_LOWER_BOUND = 0;
constexpr int MAX_ENTRIES_UPPER_BOUND = 100 * 1000;

namespace {
@@ -627,8 +628,11 @@ class ResolvCacheParameterizedTest : public ResolvCacheTest,
                                     public testing::WithParamInterface<int> {};

INSTANTIATE_TEST_SUITE_P(MaxCacheEntries, ResolvCacheParameterizedTest,
                         testing::Values(0, MAX_ENTRIES_UPPER_BOUND + 1),
                         testing::Values(MAX_ENTRIES_LOWER_BOUND - 1, MAX_ENTRIES_UPPER_BOUND + 1),
                         [](const testing::TestParamInfo<int>& info) {
                             if (info.param < 0) {  // '-' is an invalid character in test name
                                 return "negative_" + std::to_string(abs(info.param));
                             }
                             return std::to_string(info.param);
                         });