summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-09 07:22:39 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-09 07:22:39 +0000
commitafce3baabe78cda8661ff84ecf2d675803914bf0 (patch)
tree734c56465f8cbbb712358d13f8e4b8d2055ca3ee
parent83a708ddea7f119afb95ca8726a198c934d0dabf (diff)
parent0e0e43bb5cb6479983df328bc5911fd6a4b1ce51 (diff)
downloadwificond-aml_uwb_331310030.tar.gz
Snap for 8701348 from 0e0e43bb5cb6479983df328bc5911fd6a4b1ce51 to mainline-uwb-releaseaml_uwb_331310030aml_uwb_331115000aml_uwb_331015040aml_uwb_330810010
Change-Id: I2b993930ffb6036b3eef2c3fb98dc3cb54366f79
-rw-r--r--net/netlink_manager.cpp7
-rw-r--r--net/netlink_utils.cpp6
-rw-r--r--scanning/scanner_impl.cpp20
-rw-r--r--server.cpp15
4 files changed, 36 insertions, 12 deletions
diff --git a/net/netlink_manager.cpp b/net/netlink_manager.cpp
index 22154a7..64db5d8 100644
--- a/net/netlink_manager.cpp
+++ b/net/netlink_manager.cpp
@@ -48,7 +48,7 @@ namespace {
// netlink.h suggests NLMSG_GOODSIZE to be at most 8192 bytes.
constexpr int kReceiveBufferSize = 8 * 1024;
constexpr uint32_t kBroadcastSequenceNumber = 0;
-constexpr int kMaximumNetlinkMessageWaitMilliSeconds = 300;
+constexpr int kMaximumNetlinkMessageWaitMilliSeconds = 1000;
uint8_t ReceiveBuffer[kReceiveBufferSize];
void AppendPacket(vector<unique_ptr<const NL80211Packet>>* vec,
@@ -99,7 +99,8 @@ uint32_t NetlinkManager::GetSequenceNumber() {
void NetlinkManager::ReceivePacketAndRunHandler(int fd) {
ssize_t len = read(fd, ReceiveBuffer, kReceiveBufferSize);
if (len == -1) {
- LOG(ERROR) << "Failed to read packet from buffer";
+ LOG(ERROR) << "Failed to read packet from buffer on fd: " << fd;
+ perror(" netlink error ");
return;
}
if (len == 0) {
@@ -307,7 +308,7 @@ bool NetlinkManager::SendMessageAndGetResponses(
time_remaining);
if (poll_return == 0) {
- LOG(ERROR) << "Failed to poll netlink fd: time out ";
+ LOG(ERROR) << "Failed to poll netlink fd:" << sync_netlink_fd_.get() << "time out ";
message_handlers_.erase(sequence);
return false;
} else if (poll_return == -1) {
diff --git a/net/netlink_utils.cpp b/net/netlink_utils.cpp
index 73901ca..dc2e4be 100644
--- a/net/netlink_utils.cpp
+++ b/net/netlink_utils.cpp
@@ -135,8 +135,9 @@ bool NetlinkUtils::GetWiphyIndex(uint32_t* out_wiphy_index,
netlink_manager_->GetSequenceNumber(),
getpid());
get_wiphy.AddFlag(NLM_F_DUMP);
+ int ifindex;
if (!iface_name.empty()) {
- int ifindex = if_nametoindex(iface_name.c_str());
+ ifindex = if_nametoindex(iface_name.c_str());
if (ifindex == 0) {
PLOG(ERROR) << "Can't get " << iface_name << " index";
return false;
@@ -145,7 +146,8 @@ bool NetlinkUtils::GetWiphyIndex(uint32_t* out_wiphy_index,
}
vector<unique_ptr<const NL80211Packet>> response;
if (!netlink_manager_->SendMessageAndGetResponses(get_wiphy, &response)) {
- LOG(ERROR) << "NL80211_CMD_GET_WIPHY dump failed";
+ LOG(ERROR) << "NL80211_CMD_GET_WIPHY dump failed, ifindex: "
+ << ifindex << " and name: " << iface_name.c_str();
return false;
}
if (response.empty()) {
diff --git a/scanning/scanner_impl.cpp b/scanning/scanner_impl.cpp
index bba3417..c7857df 100644
--- a/scanning/scanner_impl.cpp
+++ b/scanning/scanner_impl.cpp
@@ -225,6 +225,18 @@ void ScannerImpl::ParsePnoSettings(const PnoSettings& pno_settings,
vector<vector<uint8_t>> skipped_match_ssids;
std::set<int32_t> unique_frequencies;
int num_networks_no_freqs = 0;
+ // Get the list of supported frequencies
+ const auto band_2g = client_interface_->GetBandInfo().band_2g;
+ const auto band_5g = client_interface_->GetBandInfo().band_5g;
+ const auto band_dfs = client_interface_->GetBandInfo().band_dfs;
+ const auto band_6g = client_interface_->GetBandInfo().band_6g;
+ const auto band_60g = client_interface_->GetBandInfo().band_60g;
+ std::set<uint32_t> all_freqs;
+ all_freqs.insert(band_2g.begin(), band_2g.end());
+ all_freqs.insert(band_5g.begin(), band_5g.end());
+ all_freqs.insert(band_dfs.begin(), band_dfs.end());
+ all_freqs.insert(band_6g.begin(), band_6g.end());
+ all_freqs.insert(band_60g.begin(), band_60g.end());
for (auto& network : pno_settings.pno_networks_) {
// Add hidden network ssid.
if (network.is_hidden_) {
@@ -245,7 +257,11 @@ void ScannerImpl::ParsePnoSettings(const PnoSettings& pno_settings,
// build the set of unique frequencies to scan for.
for (const auto& frequency : network.frequencies_) {
- unique_frequencies.insert(frequency);
+ if (all_freqs.find(frequency) != all_freqs.end()) {
+ unique_frequencies.insert(frequency);
+ } else {
+ LOG(INFO) << "filtered out invalid frequency " << frequency;
+ }
}
if (network.frequencies_.empty()) {
num_networks_no_freqs++;
@@ -256,14 +272,12 @@ void ScannerImpl::ParsePnoSettings(const PnoSettings& pno_settings,
// networks don't have frequency data.
if (num_networks_no_freqs * 100 > kPercentNetworksWithFreq * match_ssids->size()) {
// Filter out frequencies not supported by chip.
- const auto band_2g = client_interface_->GetBandInfo().band_2g;
for (const auto frequency : kPnoScanDefaultFreqs2G) {
if (std::find(band_2g.begin(), band_2g.end(), frequency) != band_2g.end()) {
unique_frequencies.insert(frequency);
}
}
// Note: kPnoScanDefaultFreqs5G doesn't contain DFS frequencies.
- const auto band_5g = client_interface_->GetBandInfo().band_5g;
for (const auto frequency : kPnoScanDefaultFreqs5G) {
if (std::find(band_5g.begin(), band_5g.end(), frequency) != band_5g.end()) {
unique_frequencies.insert(frequency);
diff --git a/server.cpp b/server.cpp
index 1c40185..1fd10dd 100644
--- a/server.cpp
+++ b/server.cpp
@@ -488,12 +488,19 @@ bool Server::SetupInterface(const std::string& iface_name,
}
void Server::OnRegDomainChanged(uint32_t wiphy_index, std::string& country_code) {
+ string current_country_code;
if (country_code.empty()) {
- LOG(INFO) << "Regulatory domain changed";
+ LOG(DEBUG) << "Regulatory domain changed with empty country code (world mode?)";
+ if (!netlink_utils_->GetCountryCode(&current_country_code)) {
+ LOG(ERROR) << "Fail to get country code on wiphy_index:" << wiphy_index;
+ }
} else {
- LOG(INFO) << "Regulatory domain changed to country: " << country_code
- << " on wiphy_index: " << wiphy_index;
- BroadcastRegDomainChanged(country_code);
+ current_country_code = country_code;
+ }
+ if (!current_country_code.empty()) {
+ LOG(INFO) << "Regulatory domain changed to country: " << current_country_code
+ << " on wiphy_index: " << wiphy_index;
+ BroadcastRegDomainChanged(current_country_code);
}
// Sometimes lower layer sends stale wiphy index when there are no
// interfaces. So update band - wiphy index mapping only if an