From 6ed39e657b9152e41a85a777789ec71d60ba5f27 Mon Sep 17 00:00:00 2001 From: Handa Wang Date: Mon, 17 Mar 2025 22:08:44 +0800 Subject: [PATCH] [posix] add an option to disable `resolv.conf` on initialization (#11343) On Android we didn't have a chance to disable reading from `resolv.conf` at initialization of `Resolver`. This caused a logging line at critical level which could be confusing. --- src/posix/platform/openthread-posix-config.h | 9 +++++++++ src/posix/platform/resolver.hpp | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/posix/platform/openthread-posix-config.h b/src/posix/platform/openthread-posix-config.h index 1e85bd5d0..b8407cd08 100644 --- a/src/posix/platform/openthread-posix-config.h +++ b/src/posix/platform/openthread-posix-config.h @@ -435,4 +435,13 @@ #define OPENTHREAD_POSIX_CONFIG_TMP_STORAGE_ENABLE 1 #endif +/** + * @def OPENTHREAD_POSIX_CONFIG_RESOLV_CONF_ENABLED_INIT + * + * Define as 1 to enable reading from resolv.conf on initialization. + */ +#ifndef OPENTHREAD_POSIX_CONFIG_RESOLV_CONF_ENABLED_INIT +#define OPENTHREAD_POSIX_CONFIG_RESOLV_CONF_ENABLED_INIT (!OPENTHREAD_POSIX_CONFIG_ANDROID_ENABLE) +#endif + #endif // OPENTHREAD_PLATFORM_POSIX_CONFIG_H_ diff --git a/src/posix/platform/resolver.hpp b/src/posix/platform/resolver.hpp index 94830124d..db63ba1ac 100644 --- a/src/posix/platform/resolver.hpp +++ b/src/posix/platform/resolver.hpp @@ -123,7 +123,7 @@ private: void TryRefreshDnsServerList(void); void LoadDnsServerListFromConf(void); - bool mIsResolvConfEnabled = true; + bool mIsResolvConfEnabled = OPENTHREAD_POSIX_CONFIG_RESOLV_CONF_ENABLED_INIT; uint32_t mUpstreamDnsServerCount = 0; otIp6Address mUpstreamDnsServerList[kMaxUpstreamServerCount]; uint64_t mUpstreamDnsServerListFreshness = 0;