Style fixes in the external pref64 support.
- Address a code review comment to pass a variable by reference
instead of by pointer.
- Add two missed EXCLUDES() thread-safety annotations.
- Make "dumpsys dnsresolver" report externally-set prefixes
differently from discovered prefixes.
Bug: 156914456
Test: existing unit tests pass
Original-Change: https://android-review.googlesource.com/1316178
Merged-In: Ifcdb16cc66c9234a2bd5f8aac70be809fe0dd223
Change-Id: Ifcdb16cc66c9234a2bd5f8aac70be809fe0dd223
diff --git a/Dns64Configuration.cpp b/Dns64Configuration.cpp
index 5b3849b..115fc51 100644
--- a/Dns64Configuration.cpp
+++ b/Dns64Configuration.cpp
@@ -139,7 +139,8 @@
if (cfg.prefix64.length() == 0) {
dw.println("%s: no prefix yet discovered", kLabel);
} else {
- dw.println("%s: discovered prefix %s", kLabel, cfg.prefix64.toString().c_str());
+ dw.println("%s: %s prefix %s", kLabel, cfg.isFromPrefixDiscovery() ? "discovered" : "set",
+ cfg.prefix64.toString().c_str());
}
}
@@ -238,8 +239,8 @@
reportNat64PrefixStatus(cfg.netId, PREFIX_ADDED, cfg.prefix64);
}
-int Dns64Configuration::setPrefix64(unsigned netId, const IPPrefix* pfx) {
- if (pfx->isUninitialized() || pfx->family() != AF_INET6 || pfx->length() != 96) {
+int Dns64Configuration::setPrefix64(unsigned netId, const IPPrefix& pfx) {
+ if (pfx.isUninitialized() || pfx.family() != AF_INET6 || pfx.length() != 96) {
return -EINVAL;
}
@@ -256,7 +257,7 @@
}
Dns64Config cfg(kNoDiscoveryId, netId);
- cfg.prefix64 = *pfx;
+ cfg.prefix64 = pfx;
mDns64Configs.emplace(std::make_pair(netId, cfg));
return 0;
diff --git a/Dns64Configuration.h b/Dns64Configuration.h
index c06a6c1..387de78 100644
--- a/Dns64Configuration.h
+++ b/Dns64Configuration.h
@@ -82,8 +82,8 @@
void stopPrefixDiscovery(unsigned netId);
netdutils::IPPrefix getPrefix64(unsigned netId) const;
- int setPrefix64(unsigned netId, const netdutils::IPPrefix* pfx);
- int clearPrefix64(unsigned netId);
+ int setPrefix64(unsigned netId, const netdutils::IPPrefix& pfx) EXCLUDES(mMutex);
+ int clearPrefix64(unsigned netId) EXCLUDES(mMutex);
void dump(netdutils::DumpWriter& dw, unsigned netId);
diff --git a/DnsResolverService.cpp b/DnsResolverService.cpp
index 6f63333..becda28 100644
--- a/DnsResolverService.cpp
+++ b/DnsResolverService.cpp
@@ -253,7 +253,7 @@
return statusFromErrcode(-EINVAL);
}
- return statusFromErrcode(gDnsResolv->resolverCtrl.setPrefix64(netId, &prefix));
+ return statusFromErrcode(gDnsResolv->resolverCtrl.setPrefix64(netId, prefix));
}
::ndk::ScopedAStatus DnsResolverService::setLogSeverity(int32_t logSeverity) {
diff --git a/ResolverController.h b/ResolverController.h
index 06c0bbc..e81e1ed 100644
--- a/ResolverController.h
+++ b/ResolverController.h
@@ -54,7 +54,7 @@
void stopPrefix64Discovery(int32_t netId);
// Set or clear a NAT64 prefix discovered by other sources (e.g., RA).
- int setPrefix64(unsigned netId, const netdutils::IPPrefix* prefix) {
+ int setPrefix64(unsigned netId, const netdutils::IPPrefix& prefix) {
return mDns64Configuration.setPrefix64(netId, prefix);
}