mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:23:37 +00:00
Temporarily print the size of all
variable-length fields in StaLinkLayerStats.
Will be used to verify whether
abnormally large instances of this class
can cause getLinkLayerStats to fail with
an IllegalArgumentException.
Bug: 324519882
Test: Manual test:
1. Reboot device
2. Connect to wifi
3. Verify logged link layer stats
Change-Id: I9378c7e4c2befd98743eb0752fe00cd322110c0f
This commit is contained in:
@@ -1085,6 +1085,41 @@ bool convertLegacyLinkLayerStatsToAidl(const legacy_hal::LinkLayerStats& legacy_
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO (b/324519882): Remove logs after validating the structure size.
|
||||
void logAidlLinkLayerStatsSize(StaLinkLayerStats& aidl_stats) {
|
||||
unsigned long expectedMaxRadios = 5;
|
||||
unsigned long expectedMaxLinks = 5;
|
||||
unsigned long expectedMaxChannelStats = 512;
|
||||
unsigned long expectedMaxPeers = 3;
|
||||
unsigned long expectedMaxRateStats = 1024;
|
||||
|
||||
unsigned long maxChannelStats = 0, maxPeers = 0, maxRateStats = 0;
|
||||
for (size_t i = 0; i < aidl_stats.radios.size(); i++) {
|
||||
maxChannelStats =
|
||||
std::max(maxChannelStats, (unsigned long)aidl_stats.radios[i].channelStats.size());
|
||||
}
|
||||
for (size_t i = 0; i < aidl_stats.iface.links.size(); i++) {
|
||||
maxPeers = std::max(maxPeers, (unsigned long)aidl_stats.iface.links[i].peers.size());
|
||||
for (size_t j = 0; j < aidl_stats.iface.links[i].peers.size(); j++) {
|
||||
maxRateStats =
|
||||
std::max(maxRateStats,
|
||||
(unsigned long)aidl_stats.iface.links[i].peers[j].rateStats.size());
|
||||
}
|
||||
}
|
||||
|
||||
if (aidl_stats.radios.size() > expectedMaxRadios ||
|
||||
aidl_stats.iface.links.size() > expectedMaxLinks ||
|
||||
maxChannelStats > expectedMaxChannelStats || maxPeers > expectedMaxPeers ||
|
||||
maxRateStats > expectedMaxRateStats) {
|
||||
LOG(INFO) << "StaLinkLayerStats exceeds expected vector size";
|
||||
LOG(INFO) << " numRadios: " << aidl_stats.radios.size();
|
||||
LOG(INFO) << " numLinks: " << aidl_stats.iface.links.size();
|
||||
LOG(INFO) << " maxChannelStats: " << maxChannelStats;
|
||||
LOG(INFO) << " maxPeers: " << maxPeers;
|
||||
LOG(INFO) << " maxRateStats: " << maxRateStats;
|
||||
}
|
||||
}
|
||||
|
||||
bool convertLegacyPeerInfoStatsToAidl(const legacy_hal::WifiPeerInfo& legacy_peer_info_stats,
|
||||
StaPeerInfo* aidl_peer_info_stats) {
|
||||
if (!aidl_peer_info_stats) {
|
||||
|
||||
@@ -94,6 +94,7 @@ bool convertLegacyLinkLayerMlStatsToAidl(const legacy_hal::LinkLayerMlStats& leg
|
||||
StaLinkLayerStats* aidl_stats);
|
||||
bool convertLegacyLinkLayerStatsToAidl(const legacy_hal::LinkLayerStats& legacy_stats,
|
||||
StaLinkLayerStats* aidl_stats);
|
||||
void logAidlLinkLayerStatsSize(StaLinkLayerStats& aidl_stats);
|
||||
bool convertLegacyRoamingCapabilitiesToAidl(
|
||||
const legacy_hal::wifi_roaming_capabilities& legacy_caps,
|
||||
StaRoamingCapabilities* aidl_caps);
|
||||
|
||||
@@ -435,6 +435,7 @@ std::pair<StaLinkLayerStats, ndk::ScopedAStatus> WifiStaIface::getLinkLayerStats
|
||||
} else {
|
||||
return {StaLinkLayerStats{}, createWifiStatus(WifiStatusCode::ERROR_UNKNOWN)};
|
||||
}
|
||||
aidl_struct_util::logAidlLinkLayerStatsSize(aidl_stats);
|
||||
return {aidl_stats, ndk::ScopedAStatus::ok()};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user