From fad62be2d21637d3e29ab2ee0c087887e90c77bb Mon Sep 17 00:00:00 2001 From: Kangping Dong Date: Thu, 5 Dec 2024 17:40:06 +0800 Subject: [PATCH] [Thread] allow disabling SRP server wait for border routing It's default enabled that it waits for border routing establishment before starting the SRP server. But there are also use cases where the user may want to know what are the devices in the Thread network before actually reach to the devices, or it doesn't depend on border routing to reach to a Thread device. Given that, this commit adds the support of starting SRP server without waiting for border routing by adding a new Runtime Resource Overlay configuration parameter: config_thread_srp_server_wait_for_border_routing_enabled Test: it's difficult to assert on the SRP server starts up timing. But manually verified that the SRP server starts without waiting for the routing manager when the RRO config is flipped: ``` 01-09 20:18:35.835 7555 7555 I ot-daemon: [I] RoutingManager: RsSender: Sent RS 1/3 01-09 20:18:35.835 7555 7555 I ot-daemon: [I] RoutingManager: Received RS from fe80:0:0:0:98af:44ff:fe2e:fa80 on infra netif 17 01-09 20:18:35.835 7555 7555 I ot-daemon: [I] RoutingManager: Will evaluate routing policy in 00:00.150 (150 msec) 01-09 20:18:35.926 7555 7555 I ot-daemon: [I] NetDataPublshr: DNS/SRP service - State: Adding -> Added 01-09 20:18:35.926 7555 7555 I ot-daemon: [I] SrpServer-----: Start listening on port 53536 01-09 20:18:35.926 7555 7555 I ot-daemon: [I] NetworkData---: Sent ServerData 01-09 20:18:35.926 7555 7555 I ot-daemon: [I] NetworkData---: Received ServerData 01-09 20:18:35.926 7555 7555 I ot-daemon: [I] NetworkData---: Allocated Service ID = 1 01-09 20:18:35.926 7555 7555 I ot-daemon: [I] NetworkData---: Sent ServerData ack 01-09 20:18:35.926 7555 7555 I ot-daemon: [I] Notifier------: StateChanged (0x00000200) [NetData] 01-09 20:18:35.926 7555 7555 I ot-daemon: [I] Mle-----------: Send Data Response (ff02:0:0:0:0:0:0:1) 01-09 20:18:35.926 7555 7555 I ot-daemon: [I] BbrLeader-----: PBBR state: Unchanged 01-09 20:18:35.926 7555 7555 I ot-daemon: [I] BbrLeader-----: Rloc16:0x8800, seqno:69, delay:5, timeout:3600 01-09 20:18:35.926 7555 7555 I ot-daemon: [I] RoutingManager: Will evaluate routing policy in 00:03.558 (3558 msec) 01-09 20:18:35.926 7555 7555 I ot-daemon: [I] NetDataPublshr: DNS/SRP service (state:Added) in netdata - total:1, preferred:0, desired:2 ``` Bug: 378587036 Change-Id: Ib768014f3c44dca89390cec823a1c2acac38ab0d --- .../res/values/config_thread.xml | 8 ++++++++ .../res/values/overlayable.xml | 1 + .../server/thread/ThreadNetworkControllerService.java | 6 ++++-- .../server/thread/ThreadNetworkControllerServiceTest.java | 7 +++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/service/ServiceConnectivityResources/res/values/config_thread.xml b/service/ServiceConnectivityResources/res/values/config_thread.xml index 40270388ad..3627157f0a 100644 --- a/service/ServiceConnectivityResources/res/values/config_thread.xml +++ b/service/ServiceConnectivityResources/res/values/config_thread.xml @@ -71,4 +71,12 @@ --> + + + true diff --git a/service/ServiceConnectivityResources/res/values/overlayable.xml b/service/ServiceConnectivityResources/res/values/overlayable.xml index fbaae05361..121cbc4826 100644 --- a/service/ServiceConnectivityResources/res/values/overlayable.xml +++ b/service/ServiceConnectivityResources/res/values/overlayable.xml @@ -52,6 +52,7 @@ + diff --git a/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java b/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java index c55096b1b4..c2959f4d8c 100644 --- a/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java +++ b/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java @@ -623,12 +623,14 @@ final class ThreadNetworkControllerService extends IThreadNetworkController.Stub mNat64CidrController.maybeUpdateNat64Cidr(); } - private static OtDaemonConfiguration newOtDaemonConfig( - @NonNull ThreadConfiguration threadConfig) { + private OtDaemonConfiguration newOtDaemonConfig(ThreadConfiguration threadConfig) { + int srpServerConfig = R.bool.config_thread_srp_server_wait_for_border_routing_enabled; + boolean srpServerWaitEnabled = mResources.get().getBoolean(srpServerConfig); return new OtDaemonConfiguration.Builder() .setBorderRouterEnabled(threadConfig.isBorderRouterEnabled()) .setNat64Enabled(threadConfig.isNat64Enabled()) .setDhcpv6PdEnabled(threadConfig.isDhcpv6PdEnabled()) + .setSrpServerWaitForBorderRoutingEnabled(srpServerWaitEnabled) .build(); } diff --git a/thread/tests/unit/src/com/android/server/thread/ThreadNetworkControllerServiceTest.java b/thread/tests/unit/src/com/android/server/thread/ThreadNetworkControllerServiceTest.java index dcbb3f51e0..1d44ccb0bd 100644 --- a/thread/tests/unit/src/com/android/server/thread/ThreadNetworkControllerServiceTest.java +++ b/thread/tests/unit/src/com/android/server/thread/ThreadNetworkControllerServiceTest.java @@ -231,6 +231,9 @@ public final class ThreadNetworkControllerServiceTest { when(mConnectivityResources.get()).thenReturn(mResources); when(mResources.getBoolean(eq(R.bool.config_thread_default_enabled))).thenReturn(true); + when(mResources.getBoolean( + eq(R.bool.config_thread_srp_server_wait_for_border_routing_enabled))) + .thenReturn(true); when(mResources.getString(eq(R.string.config_thread_vendor_name))) .thenReturn(TEST_VENDOR_NAME); when(mResources.getString(eq(R.string.config_thread_vendor_oui))) @@ -285,6 +288,9 @@ public final class ThreadNetworkControllerServiceTest { @Test public void initialize_resourceOverlayValuesAreSetToOtDaemon() throws Exception { + when(mResources.getBoolean( + eq(R.bool.config_thread_srp_server_wait_for_border_routing_enabled))) + .thenReturn(false); when(mResources.getString(eq(R.string.config_thread_vendor_name))) .thenReturn(TEST_VENDOR_NAME); when(mResources.getString(eq(R.string.config_thread_vendor_oui))) @@ -297,6 +303,7 @@ public final class ThreadNetworkControllerServiceTest { mService.initialize(); mTestLooper.dispatchAll(); + assertThat(mFakeOtDaemon.getConfiguration().srpServerWaitForBorderRoutingEnabled).isFalse(); MeshcopTxtAttributes meshcopTxts = mFakeOtDaemon.getOverriddenMeshcopTxtAttributes(); assertThat(meshcopTxts.vendorName).isEqualTo(TEST_VENDOR_NAME); assertThat(meshcopTxts.vendorOui).isEqualTo(TEST_VENDOR_OUI_BYTES);