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

Commit f8bb6821 authored by Luke Huang's avatar Luke Huang Committed by Automerger Merge Worker
Browse files

Merge "Enlarge the DoH query timeout and the server probe timeout" am:...

Merge "Enlarge the DoH query timeout and the server probe timeout" am: b6e255d1 am: e772785d am: ad99c35c

Original change: https://android-review.googlesource.com/c/platform/packages/modules/DnsResolver/+/1795393

Change-Id: I1f73fa4084045aad43cc75069245726be4e0fb45
parents 7cec976a ad99c35c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ class Experiments {
            "dot_validation_latency_factor",
            "dot_validation_latency_offset_ms",
            "doh",
            "doh_query_timeout_ms",
            "doh_probe_timeout_ms",
            "mdns_resolution",
    };
    // This value is used in updateInternal as the default value if any flags can't be found.
+6 −1
Original line number Diff line number Diff line
@@ -462,8 +462,13 @@ int PrivateDnsConfiguration::setDoh(int32_t netId, uint32_t mark,
        mPrivateDnsLog.push(std::move(record));
        LOG(INFO) << __func__ << ": Upgrading server to DoH: " << name;

        int probeTimeout = Experiments::getInstance()->getFlag("doh_probe_timeout_ms",
                                                               kDohProbeDefaultTimeoutMs);
        if (probeTimeout < 1000) {
            probeTimeout = 1000;
        }
        return doh_net_new(mDohDispatcher, netId, dohId.httpsTemplate.c_str(), dohId.host.c_str(),
                           dohId.ipAddr.c_str(), mark, caCert.c_str(), 3000);
                           dohId.ipAddr.c_str(), mark, caCert.c_str(), probeTimeout);
    }

    LOG(INFO) << __func__ << ": No suitable DoH server found";
+3 −0
Original line number Diff line number Diff line
@@ -60,6 +60,9 @@ struct PrivateDnsStatus {

class PrivateDnsConfiguration {
  public:
    static constexpr int kDohQueryDefaultTimeoutMs = 30000;
    static constexpr int kDohProbeDefaultTimeoutMs = 60000;

    struct ServerIdentity {
        const netdutils::IPSockAddr sockaddr;
        const std::string provider;
+7 −1
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ using android::net::DnsQueryEvent;
using android::net::DnsTlsDispatcher;
using android::net::DnsTlsServer;
using android::net::DnsTlsTransport;
using android::net::Experiments;
using android::net::IpVersion;
using android::net::IV_IPV4;
using android::net::IV_IPV6;
@@ -1393,7 +1394,12 @@ ssize_t res_doh_send(ResState* statp, const Slice query, const Slice answer, int
    const unsigned netId = statp->netid;
    LOG(INFO) << __func__ << ": performing query over Https";
    Stopwatch queryStopwatch;
    ssize_t result = privateDnsConfiguration.dohQuery(netId, query, answer, /*timeoutMs*/ 2000);
    int queryTimeout = Experiments::getInstance()->getFlag(
            "doh_query_timeout_ms", PrivateDnsConfiguration::kDohQueryDefaultTimeoutMs);
    if (queryTimeout < 1000) {
        queryTimeout = 1000;
    }
    ssize_t result = privateDnsConfiguration.dohQuery(netId, query, answer, queryTimeout);
    LOG(INFO) << __func__ << ": Https query result: " << result;

    if (result == RESULT_CAN_NOT_SEND) return RESULT_CAN_NOT_SEND;
+11 −2
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ using android::netdutils::Stopwatch;
using std::chrono::milliseconds;

const std::string kDohFlag("persist.device_config.netd_native.doh");
const std::string kDohQueryTimeoutFlag("persist.device_config.netd_native.doh_query_timeout_ms");
const std::string kDohProbeTimeoutFlag("persist.device_config.netd_native.doh_probe_timeout_ms");

namespace {

@@ -153,6 +155,11 @@ class BasePrivateDnsTest : public BaseTest {
  protected:
    void SetUp() override {
        mDohScopedProp = make_unique<ScopedSystemProperties>(kDohFlag, "1");
        mDohQueryTimeoutScopedProp =
                make_unique<ScopedSystemProperties>(kDohQueryTimeoutFlag, "1000");
        unsigned int expectedProbeTimeout = kExpectedDohValidationTimeWhenTimeout.count();
        mDohProbeTimeoutScopedProp = make_unique<ScopedSystemProperties>(
                kDohProbeTimeoutFlag, std::to_string(expectedProbeTimeout));
        BaseTest::SetUp();

        static const std::vector<DnsRecord> records = {
@@ -195,7 +202,7 @@ class BasePrivateDnsTest : public BaseTest {
        std::this_thread::sleep_for(kExpectedDohValidationTimeWhenServerUnreachable);
    }

    static constexpr milliseconds kExpectedDohValidationTimeWhenTimeout{3000};
    static constexpr milliseconds kExpectedDohValidationTimeWhenTimeout{1000};
    static constexpr milliseconds kExpectedDohValidationTimeWhenServerUnreachable{1000};
    static constexpr char kQueryHostname[] = "TransportParameterizedTest.example.com.";
    static constexpr char kQueryAnswerA[] = "1.2.3.4";
@@ -207,8 +214,10 @@ class BasePrivateDnsTest : public BaseTest {
    test::DNSResponder doh_backend{"127.0.1.3", "53"};
    test::DNSResponder dot_backend{"127.0.2.3", "53"};

    // Used to enable DoH during the tests.
    // Used to enable DoH during the tests and set up a shorter timeout.
    std::unique_ptr<ScopedSystemProperties> mDohScopedProp;
    std::unique_ptr<ScopedSystemProperties> mDohQueryTimeoutScopedProp;
    std::unique_ptr<ScopedSystemProperties> mDohProbeTimeoutScopedProp;
};

// Parameterized test for the combination of DoH and DoT.