Hack and ship: NetworkStats edition.
Some devices use clatd for catching raw IPv4 traffic when running on a pure-IPv6 carrier network. In those situations, the per-UID stats are accounted against the clat iface, so framework users need to combine both the "base" and "stacked" iface usage together. This also means that policy rules (like restricting background data or battery saver) need to apply to the stacked ifaces. Finally, we need to massage stats data slightly: -- Currently xt_qtaguid double-counts the clatd traffic *leaving* the device; both against the original UID on the clat iface, and against UID 0 on the final egress interface. -- All clatd traffic *arriving* at the device is missing the extra IPv6 packet header overhead when accounted against the final UID. Bug: 12249687, 15459248, 16296564 Change-Id: I0ee59d96831f52782de7a980e4cce9b061902fff
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.net.ProxyInfo;
|
import android.net.ProxyInfo;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
@@ -24,7 +25,6 @@ import android.text.TextUtils;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet4Address;
|
||||||
import java.net.Inet6Address;
|
import java.net.Inet6Address;
|
||||||
|
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -480,7 +480,10 @@ public final class LinkProperties implements Parcelable {
|
|||||||
* Returns all the links stacked on top of this link.
|
* Returns all the links stacked on top of this link.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public List<LinkProperties> getStackedLinks() {
|
public @NonNull List<LinkProperties> getStackedLinks() {
|
||||||
|
if (mStackedLinks.isEmpty()) {
|
||||||
|
return Collections.EMPTY_LIST;
|
||||||
|
}
|
||||||
List<LinkProperties> stacked = new ArrayList<LinkProperties>();
|
List<LinkProperties> stacked = new ArrayList<LinkProperties>();
|
||||||
for (LinkProperties link : mStackedLinks.values()) {
|
for (LinkProperties link : mStackedLinks.values()) {
|
||||||
stacked.add(new LinkProperties(link));
|
stacked.add(new LinkProperties(link));
|
||||||
|
|||||||
@@ -119,7 +119,9 @@ import android.util.Xml;
|
|||||||
|
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
|
import com.android.internal.app.IBatteryStats;
|
||||||
import com.android.internal.net.LegacyVpnInfo;
|
import com.android.internal.net.LegacyVpnInfo;
|
||||||
|
import com.android.internal.net.NetworkStatsFactory;
|
||||||
import com.android.internal.net.VpnConfig;
|
import com.android.internal.net.VpnConfig;
|
||||||
import com.android.internal.net.VpnProfile;
|
import com.android.internal.net.VpnProfile;
|
||||||
import com.android.internal.telephony.DctConstants;
|
import com.android.internal.telephony.DctConstants;
|
||||||
@@ -4476,12 +4478,23 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
// TODO - read the tcp buffer size config string from somewhere
|
// TODO - read the tcp buffer size config string from somewhere
|
||||||
// updateNetworkSettings();
|
// updateNetworkSettings();
|
||||||
}
|
}
|
||||||
// notify battery stats service about this network
|
|
||||||
|
// Notify battery stats service about this network, both the normal
|
||||||
|
// interface and any stacked links.
|
||||||
try {
|
try {
|
||||||
BatteryStatsService.getService().noteNetworkInterfaceType(
|
final IBatteryStats bs = BatteryStatsService.getService();
|
||||||
newNetwork.linkProperties.getInterfaceName(),
|
final int type = newNetwork.networkInfo.getType();
|
||||||
newNetwork.networkInfo.getType());
|
|
||||||
} catch (RemoteException e) { }
|
final String baseIface = newNetwork.linkProperties.getInterfaceName();
|
||||||
|
bs.noteNetworkInterfaceType(baseIface, type);
|
||||||
|
for (LinkProperties stacked : newNetwork.linkProperties.getStackedLinks()) {
|
||||||
|
final String stackedIface = stacked.getInterfaceName();
|
||||||
|
bs.noteNetworkInterfaceType(stackedIface, type);
|
||||||
|
NetworkStatsFactory.noteStackedIface(stackedIface, baseIface);
|
||||||
|
}
|
||||||
|
} catch (RemoteException ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
notifyNetworkCallbacks(newNetwork, ConnectivityManager.CALLBACK_AVAILABLE);
|
notifyNetworkCallbacks(newNetwork, ConnectivityManager.CALLBACK_AVAILABLE);
|
||||||
} else {
|
} else {
|
||||||
if (DBG && newNetwork.networkRequests.size() != 0) {
|
if (DBG && newNetwork.networkRequests.size() != 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user