Filter debug entries for each vpn

NetworkStats calculation needs to filter out debug entries to
prevent over counting. While NetworkStatsFactory migrates data
usage over a VPN to the TUN network, NetworkStatsFactory does
not filter out debug entries per vpn which will cause debug
entries left and cause exception.

Bug: 152678151
Test: atest com.android.server.net.NetworkStatsFactoryTest
      and verify no exception
Change-Id: I3525edc385b07858b48c7add2d331c4b5a2e84ad
This commit is contained in:
Chiachang Wang
2020-04-28 22:15:56 +08:00
parent ba714fa495
commit 87ba308377

View File

@@ -385,10 +385,9 @@ public class NetworkStatsFactory {
// Migrate data usage over a VPN to the TUN network. // Migrate data usage over a VPN to the TUN network.
for (VpnInfo info : vpnArray) { for (VpnInfo info : vpnArray) {
delta.migrateTun(info.ownerUid, info.vpnIface, info.underlyingIfaces); delta.migrateTun(info.ownerUid, info.vpnIface, info.underlyingIfaces);
}
// Filter out debug entries as that may lead to over counting. // Filter out debug entries as that may lead to over counting.
delta.filterDebugEntries(); delta.filterDebugEntries();
}
// Update mTunAnd464xlatAdjustedStats with migrated delta. // Update mTunAnd464xlatAdjustedStats with migrated delta.
mTunAnd464xlatAdjustedStats.combineAllValues(delta); mTunAnd464xlatAdjustedStats.combineAllValues(delta);