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

Commit 882eeb91 authored by Mike Yu's avatar Mike Yu
Browse files

DoH: Make session resumption as a flag

Use a flag, doh_session_resumption, to control whether or not to
enable session resumption. If the flag is unset, session resumption
is disabled.

Because the value of the flag is cached in the DoH client, if
there are some networks existing before setting a new value to
the flag, those network will still use the old value of the flag
rather than the new one until private DNS settings changes.

Bug: 205922811
Test: cd packages/modules/DnsResolver && atest
Test: changed the flag and checked that DnsResolver behaved as
      expected
Change-Id: I6fb24d4251b6e0fc163d169bb9cc68703bb76812
parent 75bef416
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ class Experiments {
            "doh_query_timeout_ms",
            "doh_probe_timeout_ms",
            "doh_idle_timeout_ms",
            "doh_session_resumption",
            "mdns_resolution",
    };
    // This value is used in updateInternal as the default value if any flags can't be found.
+4 −1
Original line number Diff line number Diff line
@@ -505,9 +505,12 @@ int PrivateDnsConfiguration::setDoh(int32_t netId, uint32_t mark,
                        getTimeoutFromFlag("doh_probe_timeout_ms", kDohProbeDefaultTimeoutMs),
                .idle_timeout_ms =
                        getTimeoutFromFlag("doh_idle_timeout_ms", kDohIdleDefaultTimeoutMs),
                .use_session_resumption =
                        Experiments::getInstance()->getFlag("doh_session_resumption", 0) == 1,
        };
        LOG(DEBUG) << __func__ << ": probe_timeout_ms=" << flags.probe_timeout_ms
                   << ", idle_timeout_ms=" << flags.idle_timeout_ms;
                   << ", idle_timeout_ms=" << flags.idle_timeout_ms
                   << ", use_session_resumption=" << flags.use_session_resumption;

        return doh_net_new(mDohDispatcher, netId, dohId.httpsTemplate.c_str(), dohId.host.c_str(),
                           dohId.ipAddr.c_str(), mark, caCert.c_str(), &flags);
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ struct DohDispatcher;
struct FeatureFlags {
    uint64_t probe_timeout_ms;
    uint64_t idle_timeout_ms;
    bool use_session_resumption;
};

using ValidationCallback = void (*)(uint32_t net_id, bool success, const char* ip_addr,
+3 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ pub type TagSocketCallback = extern "C" fn(sock: RawFd);
pub struct FeatureFlags {
    probe_timeout_ms: uint64_t,
    idle_timeout_ms: uint64_t,
    use_session_resumption: bool,
}

fn wrap_validation_callback(validation_fn: ValidationCallback) -> ValidationReporter {
@@ -231,6 +232,7 @@ pub unsafe extern "C" fn doh_net_new(
            sk_mark,
            cert_path,
            idle_timeout_ms: flags.idle_timeout_ms,
            use_session_resumption: flags.use_session_resumption,
        },
        timeout: Duration::from_millis(flags.probe_timeout_ms),
    };
@@ -381,6 +383,7 @@ mod tests {
            sk_mark: 0,
            cert_path: None,
            idle_timeout_ms: 0,
            use_session_resumption: true,
        };

        wrap_validation_callback(success_cb)(&info, true).await;
+2 −1
Original line number Diff line number Diff line
@@ -185,7 +185,8 @@ impl Driver {
        }

        if !self.connection.wait_for_live().await {
            let session = self.connection.session();
            let session =
                if self.info.use_session_resumption { self.connection.session() } else { None };
            // Try reconnecting
            self.connection =
                build_connection(&self.info, &self.tag_socket, &mut self.config, session).await?;
Loading