aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Chen <cken@google.com>2023-07-13 16:30:19 +0800
committerKen Chen <cken@google.com>2023-08-12 21:49:51 +0800
commit5e1de553b73024e6d32c190ecd030109cc703f1c (patch)
treeb3944060117eddf8a33c760378cacf1716869106
parentb7667e4baa893c69bcb841668cc4679e88c4efe7 (diff)
downloadDnsResolver-5e1de553b73024e6d32c190ecd030109cc703f1c.tar.gz
Set global limiter from INT_MAX to 2500 by default
Although the global limiter is currently pushed by server, many OEM devices do not login to the Google account to get the update before auto testing. This commit set the default value to 2500 in module code. This value is safe as google server has pushed the same value four months ago and no issue was reported. From statistical data, the issue this commit tries to fix happens only in OEM labs with extreme conditions. The issue is not observed in the field. So this is a fix for OEM lab testing only. Bug: 291016548 Test: atest Change-Id: If8d7ac9474e6682eb18659547ae7beca8f03a8f6
-rw-r--r--DnsProxyListener.cpp9
-rw-r--r--OperationLimiter.h9
2 files changed, 11 insertions, 7 deletions
diff --git a/DnsProxyListener.cpp b/DnsProxyListener.cpp
index 0de74939..8f49eef6 100644
--- a/DnsProxyListener.cpp
+++ b/DnsProxyListener.cpp
@@ -70,20 +70,19 @@ using std::span;
namespace android {
+using netdutils::MAX_QUERIES_IN_TOTAL;
+using netdutils::MAX_QUERIES_PER_UID;
using netdutils::ResponseCode;
using netdutils::Stopwatch;
namespace net {
namespace {
-// Limits the number of outstanding DNS queries by client UID.
-constexpr int MAX_QUERIES_PER_UID = 256;
-
android::netdutils::OperationLimiter<uid_t> queryLimiter(MAX_QUERIES_PER_UID);
bool startQueryLimiter(uid_t uid) {
- const int globalLimit =
- android::net::Experiments::getInstance()->getFlag("max_queries_global", INT_MAX);
+ const int globalLimit = android::net::Experiments::getInstance()->getFlag("max_queries_global",
+ MAX_QUERIES_IN_TOTAL);
return queryLimiter.start(uid, globalLimit);
}
diff --git a/OperationLimiter.h b/OperationLimiter.h
index 24f4dc3c..335ec5a3 100644
--- a/OperationLimiter.h
+++ b/OperationLimiter.h
@@ -28,6 +28,11 @@
namespace android {
namespace netdutils {
+// Limits the number of outstanding DNS queries by client UID.
+constexpr int MAX_QUERIES_PER_UID = 256;
+// Limits the total number of outstanding DNS queries.
+constexpr int MAX_QUERIES_IN_TOTAL = 2500;
+
// Tracks the number of operations in progress on behalf of a particular key or
// ID, rejecting further attempts to start new operations after a configurable
// limit has been reached.
@@ -56,11 +61,11 @@ class OperationLimiter {
//
// Note: each successful start(key) must be matched by exactly one call to
// finish(key).
- bool start(KeyType key, int globalLimit = INT_MAX) EXCLUDES(mMutex) {
+ bool start(KeyType key, int globalLimit = MAX_QUERIES_IN_TOTAL) EXCLUDES(mMutex) {
std::lock_guard lock(mMutex);
if (globalLimit < mLimitPerKey) {
LOG(ERROR) << "Misconfiguration on max_queries_global " << globalLimit;
- globalLimit = INT_MAX;
+ globalLimit = MAX_QUERIES_IN_TOTAL;
}
if (mGlobalCounter >= globalLimit) {
// Oh, no!