OSDN Git Service

NetworkStatsFactory: fix double accounting on IPv6 only networks
authorHugo Benichi <hugobenichi@google.com>
Fri, 7 Apr 2017 06:20:56 +0000 (15:20 +0900)
committerHugo Benichi <hugobenichi@google.com>
Tue, 9 May 2017 13:46:14 +0000 (22:46 +0900)
commite1bb3a14d1ee1aba2f92e5bccf659774699eaffe
treee1b0d6fe960efc470ba609ef3d7c6f92bbde30ec
parentd308803b82f5317eebafdf3a97baff3bcd460e60
NetworkStatsFactory: fix double accounting on IPv6 only networks

For 464xlat scenarios on IPv6 networks, the clatd interface setup
introduces double counting of apps ipv4 traffic. NetworkStatsFactory was
accounting for this on the tx path, but not on the rx path. Also it did
not accounted for the 20 bytes added by the IPv6 header.

This patch subtract correctly the rx and tx traffic from the root uid on
the underlying interface, and also adds correctly the 20 bytes cost per
packet on the stacked interface for 464xlat traffic.

Test: added several new unit tests, based on synthetic data and real
      data also.
Bug: 33681750
Change-Id: I2675643b220acbc6110179fa937d4c313b6f5e32
core/java/com/android/internal/net/NetworkStatsFactory.java
tests/net/java/com/android/internal/net/NetworkStatsFactoryTest.java
tests/net/res/raw/xt_qtaguid_with_clat [new file with mode: 0644]
tests/net/res/raw/xt_qtaguid_with_clat_100mb_download_after [new file with mode: 0644]
tests/net/res/raw/xt_qtaguid_with_clat_100mb_download_before [new file with mode: 0644]
tests/net/res/raw/xt_qtaguid_with_clat_simple [new file with mode: 0644]