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

Commit e9c85326 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7991789 from c9560286 to mainline-permission-release

Change-Id: If978a8d87766d8641d8b07d88875d5cae9398228
parents 52f8b300 c9560286
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -17,10 +17,10 @@
#pragma once
#pragma once


#include <climits>
#include <climits>
#include <map>
#include <mutex>
#include <mutex>
#include <string>
#include <string>
#include <string_view>
#include <string_view>
#include <unordered_map>


#include <android-base/thread_annotations.h>
#include <android-base/thread_annotations.h>
#include <netdutils/DumpWriter.h>
#include <netdutils/DumpWriter.h>
@@ -45,7 +45,7 @@ class Experiments {
    Experiments() = delete;
    Experiments() = delete;
    void updateInternal() EXCLUDES(mMutex);
    void updateInternal() EXCLUDES(mMutex);
    mutable std::mutex mMutex;
    mutable std::mutex mMutex;
    std::unordered_map<std::string_view, int> mFlagsMapInt GUARDED_BY(mMutex);
    std::map<std::string_view, int> mFlagsMapInt GUARDED_BY(mMutex);
    // TODO: Migrate other experiment flags to here.
    // TODO: Migrate other experiment flags to here.
    // (retry_count, retransmission_time_interval)
    // (retry_count, retransmission_time_interval)
    static constexpr const char* const kExperimentFlagKeyList[] = {
    static constexpr const char* const kExperimentFlagKeyList[] = {
@@ -64,6 +64,7 @@ class Experiments {
            "doh",
            "doh",
            "doh_query_timeout_ms",
            "doh_query_timeout_ms",
            "doh_probe_timeout_ms",
            "doh_probe_timeout_ms",
            "doh_idle_timeout_ms",
            "mdns_resolution",
            "mdns_resolution",
    };
    };
    // This value is used in updateInternal as the default value if any flags can't be found.
    // This value is used in updateInternal as the default value if any flags can't be found.
+4 −4
Original line number Original line Diff line number Diff line
@@ -14,10 +14,10 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#include <map>
#include <mutex>
#include <mutex>
#include <string>
#include <string>
#include <string_view>
#include <string_view>
#include <unordered_map>


#include <android-base/format.h>
#include <android-base/format.h>
#include <android-base/test_utils.h>
#include <android-base/test_utils.h>
@@ -72,7 +72,7 @@ class ExperimentsTest : public ::testing::Test {
    }
    }


    void expectGetDnsExperimentFlagInt() {
    void expectGetDnsExperimentFlagInt() {
        std::unordered_map<std::string_view, int> tempMap;
        std::map<std::string_view, int> tempMap;
        for (const auto& key : Experiments::kExperimentFlagKeyList) {
        for (const auto& key : Experiments::kExperimentFlagKeyList) {
            tempMap[key] = mExperiments.getFlag(key, 0);
            tempMap[key] = mExperiments.getFlag(key, 0);
        }
        }
@@ -102,11 +102,11 @@ class ExperimentsTest : public ::testing::Test {
        EXPECT_EQ(dumpString.substr(startPos), "\n");
        EXPECT_EQ(dumpString.substr(startPos), "\n");
    }
    }


    static std::unordered_map<std::string_view, int> sFakeFlagsMapInt;
    static std::map<std::string_view, int> sFakeFlagsMapInt;
    Experiments mExperiments;
    Experiments mExperiments;
};
};


std::unordered_map<std::string_view, int> ExperimentsTest::sFakeFlagsMapInt;
std::map<std::string_view, int> ExperimentsTest::sFakeFlagsMapInt;


TEST_F(ExperimentsTest, update) {
TEST_F(ExperimentsTest, update) {
    std::vector<int> testValues = {50, 3, 5, 0};
    std::vector<int> testValues = {50, 3, 5, 0};
+2 −1
Original line number Original line Diff line number Diff line
include platform/system/netd:/OWNERS
set noparent
file:platform/packages/modules/Connectivity:master:/OWNERS_core_networking
+15 −6
Original line number Original line Diff line number Diff line
@@ -444,6 +444,15 @@ int PrivateDnsConfiguration::setDoh(int32_t netId, uint32_t mark,
        return 0;
        return 0;
    }
    }


    const auto getTimeoutFromFlag = [&](const std::string_view key, int defaultValue) -> uint64_t {
        static constexpr int kMinTimeoutMs = 1000;
        uint64_t timeout = Experiments::getInstance()->getFlag(key, defaultValue);
        if (timeout < kMinTimeoutMs) {
            timeout = kMinTimeoutMs;
        }
        return timeout;
    };

    // Sort the input servers to ensure that we could get the server vector at the same order.
    // Sort the input servers to ensure that we could get the server vector at the same order.
    std::vector<std::string> sortedServers = servers;
    std::vector<std::string> sortedServers = servers;
    // Prefer ipv6.
    // Prefer ipv6.
@@ -481,13 +490,13 @@ int PrivateDnsConfiguration::setDoh(int32_t netId, uint32_t mark,
        LOG(INFO) << __func__ << ": Upgrading server to DoH: " << name;
        LOG(INFO) << __func__ << ": Upgrading server to DoH: " << name;
        resolv_stats_set_addrs(netId, PROTO_DOH, {dohId.ipAddr}, kDohPort);
        resolv_stats_set_addrs(netId, PROTO_DOH, {dohId.ipAddr}, kDohPort);


        int probeTimeout = Experiments::getInstance()->getFlag("doh_probe_timeout_ms",
        auto probeTimeout = getTimeoutFromFlag("doh_probe_timeout_ms", kDohProbeDefaultTimeoutMs);
                                                               kDohProbeDefaultTimeoutMs);
        auto idleTimeout = getTimeoutFromFlag("doh_idle_timeout_ms", kDohIdleDefaultTimeoutMs);
        if (probeTimeout < 1000) {
        LOG(DEBUG) << __func__ << ": probeTimeout " << probeTimeout << ", idleTimeout "
            probeTimeout = 1000;
                   << idleTimeout;
        }

        return doh_net_new(mDohDispatcher, netId, dohId.httpsTemplate.c_str(), dohId.host.c_str(),
        return doh_net_new(mDohDispatcher, netId, dohId.httpsTemplate.c_str(), dohId.host.c_str(),
                           dohId.ipAddr.c_str(), mark, caCert.c_str(), probeTimeout);
                           dohId.ipAddr.c_str(), mark, caCert.c_str(), probeTimeout, idleTimeout);
    }
    }


    LOG(INFO) << __func__ << ": No suitable DoH server found";
    LOG(INFO) << __func__ << ": No suitable DoH server found";
+3 −0
Original line number Original line Diff line number Diff line
@@ -63,6 +63,9 @@ class PrivateDnsConfiguration {
    static constexpr int kDohQueryDefaultTimeoutMs = 30000;
    static constexpr int kDohQueryDefaultTimeoutMs = 30000;
    static constexpr int kDohProbeDefaultTimeoutMs = 60000;
    static constexpr int kDohProbeDefaultTimeoutMs = 60000;


    // The default value for QUIC max_idle_timeout.
    static constexpr int kDohIdleDefaultTimeoutMs = 55000;

    struct ServerIdentity {
    struct ServerIdentity {
        const netdutils::IPSockAddr sockaddr;
        const netdutils::IPSockAddr sockaddr;
        const std::string provider;
        const std::string provider;
Loading