Commit Graph

10 Commits

Author SHA1 Message Date
Steven Moreland
79e97166a8 Merge "NetworkStatsFactory.cpp: IWYU" 2020-01-16 21:22:46 +00:00
Steven Moreland
7b2c9ab255 NetworkStatsFactory.cpp: IWYU
Bug: 140330870
Test: N/A
Change-Id: Id6107c8a83b22ac56f4da61a5d5757d29ecb07ac
2020-01-14 09:25:32 -08:00
Maciej Żenczykowski
ed3ee3702b minor change to keep it building
This is part of 3 commits in 3 diff git repos, the main one is:
  https://android-review.googlesource.com/c/platform/system/netd/+/1200479
  "share eBPF struct definitions between ebpf and C++ netd"

as a side effect of which 'android::bpf::Stats' becomes simply '::Stats'

Test: builds
Bug: 146787904
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8548b27d1d8a7938f96c9fd9a185dae882e406f6
2020-01-06 23:25:49 +00:00
Maciej Żenczykowski
4421b2b9c2 convert 'Stats stats; memset(&stats, 0, sizeof(Stats));' to 'Stats stats = {};'
Not only is it more concise, but it's also just a tad more correct:
since it really should have been 'sizeof(stats)' not 'sizeof(Stats)'.

Test: builds, atest
Bug: 146787904
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6cf0295878c7b34cedfe3ae44ff7410ef419f8b9
2019-12-30 20:49:36 +00:00
Maciej Żenczykowski
3a4cc11de3 remove spurious 'struct' on Stats
Test: builds, atest
Bug: 146787904
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I824daf0ebdddbac1b11cabfcb248ee4134586768
2019-12-30 20:49:27 +00:00
Chenbo Feng
45fff45471 Move NetworkStatsFactory into service directory
In order to notify netd to swap eBPF maps before pulling the
networkStats from eBPF maps, NetworkStatsFactory need to use the
NetdServices to issue binder calls. So it need to be moved from
framework/base/core to framework/base/service since object in
framework/base/core cannot get any system services. This change is also
necessary for setting up a lock inside NetworkStatsFactory to prevent
racing between two netstats caller since the lock need to be hold before
netd trigger the map swap.

Also fix the compile problem caused by moving the NetworkStatsFactory
and the related tests. Rename the packages and the jni functions to a
more proper name.

Bug: 124764595
Bug: 128900919
Test: NetworkStatsFactoryTest
      android.app.usage.cts.NetworkUsageStatsTest
      android.net.cts.TrafficStatsTest

Merged-In: Ifcfe4df81caf8ede2e4e66a76552cb3200378fa8
Change-Id: Ifcfe4df81caf8ede2e4e66a76552cb3200378fa8
2019-04-03 11:33:40 -07:00
Chenbo Feng
f9eff38d9b Delete unused import
The hasBpfSupport() check from BpfUtils is not used by the native helper
in framework. Remove them.

Bug: 111441138
Test: Build without failure.
Change-Id: Icdd01bf1a03efd7883e4939d0d730303ec1004e7
2018-12-13 00:46:20 +00:00
Chenbo Feng
4a259ab940 Move bpf project to system/bpf
The bpf project now have a new project directory in system/bpf instead
of inside netd. The network related bpf library is renamed to
libnetdbpf. Fix the dependency issue in framework to make sure no
regression.

Test: -m CtsNetTestCases -t android.net.cts.TrafficStatsTest
Bug: 112334572
Change-Id: Ibd477bf17d18d516aa520fb1569f4a395ef9abf0
2018-10-17 03:46:35 +00:00
Chenbo Feng
7d2d414fd8 Add BPF support for NetworkStatsService
Add the native implementation for NetworkStatsService to read the
uidStatsMap and tagStatsMap to get the network traffic information.
Currently the implementation only try to get the data from bpf for a
reference but the final value returned is still from old xt_qtaguid
module. So the result will not be effected. The bpf implementation is
depending on libbpf inside netd.

Bug: 30950746
Test: CtsNetTestCases -t android.net.cts.TrafficStatsTest

Change-Id: Ia85e4d4d602f6bd536739d89085e6dc37ad82e15
2018-01-22 23:25:11 -08:00
Chenbo Feng
aa7ba31c8e Use NetworkStatsService to get stats for apps
Move the native implementation of TrafficStats to NetworkStatsService
and apps need to get the NetworkStatsService binder interface from
system_server in order to get the network usage stats since boot. This
implementation can hide the detail of retrieving network traffic
information from apps and the NetworkStatsService can choose which
methoed it use to get the data depending on the kernel version of the
device.

Bug: 30950746
Test: CtsNetTestCases -t android.net.cts.TrafficStatsTest
Change-Id: I53bbefd19aa0b783b9b4b42ea4d76db3e9ec07a3
2017-12-19 19:57:44 -08:00