From f426b2b28726628fa5b5f5f50324351de7295a18 Mon Sep 17 00:00:00 2001 From: Ken Chen Date: Sun, 23 Jan 2022 15:39:13 +0800 Subject: [PATCH] Rename libnetdbpf to libnetworkstats Two reason for renaming: 1. Avoid module name collision in sc-mainline-prod branch. 2. The libnetdbpf was misnamed before. Bug: 202086915 Test: atest libnetworkstats_test FrameworksNetTests ConnectivityCoverageTests FrameworksNetSmokeTests CtsAppOpsTestCases Change-Id: I87fcf4b1a9d58780a45743a9aa91b9b936e54266 --- TEST_MAPPING | 9 +++++ bpf_progs/Android.bp | 3 +- bpf_progs/bpf_shared.h | 1 - bpf_progs/netd.c | 1 + .../Android.bp | 38 +++++++++++-------- .../BpfNetworkStats.cpp | 0 .../BpfNetworkStatsTest.cpp | 1 - .../include/netdbpf/BpfNetworkStats.h | 0 service/native/TrafficController.cpp | 1 + tests/unit/Android.bp | 2 +- tests/unit/jni/Android.bp | 2 +- 11 files changed, 37 insertions(+), 21 deletions(-) rename service-t/native/libs/{libnetdbpf => libnetworkstats}/Android.bp (66%) rename service-t/native/libs/{libnetdbpf => libnetworkstats}/BpfNetworkStats.cpp (100%) rename service-t/native/libs/{libnetdbpf => libnetworkstats}/BpfNetworkStatsTest.cpp (99%) rename service-t/native/libs/{libnetdbpf => libnetworkstats}/include/netdbpf/BpfNetworkStats.h (100%) diff --git a/TEST_MAPPING b/TEST_MAPPING index ffbd1fc8fc..780ba267a3 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -26,6 +26,9 @@ }, { "name": "traffic_controller_unit_test" + }, + { + "name": "libnetworkstats_test" } ], "postsubmit": [ @@ -42,6 +45,9 @@ { "name": "traffic_controller_unit_test", "keywords": ["netd-device-kernel-4.9", "netd-device-kernel-4.14"] + }, + { + "name": "libnetworkstats_test" } ], "mainline-presubmit": [ @@ -61,6 +67,9 @@ }, { "name": "traffic_controller_unit_test[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex]" + }, + { + "name": "libnetworkstats_test[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex]" } ], "mainline-postsubmit": [ diff --git a/bpf_progs/Android.bp b/bpf_progs/Android.bp index e228df0c13..a7155fd8fb 100644 --- a/bpf_progs/Android.bp +++ b/bpf_progs/Android.bp @@ -44,9 +44,8 @@ cc_library_headers { "//frameworks/base/services/core/jni", "//packages/modules/Connectivity/Tethering", "//packages/modules/Connectivity/service/native", + "//packages/modules/Connectivity/service-t/native/libs/libnetworkstats", "//packages/modules/Connectivity/tests/unit/jni", - // TODO: remove system/netd/* when all BPF code is moved out of Netd. - "//system/netd/libnetdbpf", "//system/netd/server", "//system/netd/tests", ], diff --git a/bpf_progs/bpf_shared.h b/bpf_progs/bpf_shared.h index 8577d9d819..f0df97baf2 100644 --- a/bpf_progs/bpf_shared.h +++ b/bpf_progs/bpf_shared.h @@ -20,7 +20,6 @@ #include #include #include -#include // This header file is shared by eBPF kernel programs (C) and netd (C++) and // some of the maps are also accessed directly from Java mainline module code. diff --git a/bpf_progs/netd.c b/bpf_progs/netd.c index 72ee431fb4..f0af8b4112 100644 --- a/bpf_progs/netd.c +++ b/bpf_progs/netd.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include "bpf_net_helpers.h" diff --git a/service-t/native/libs/libnetdbpf/Android.bp b/service-t/native/libs/libnetworkstats/Android.bp similarity index 66% rename from service-t/native/libs/libnetdbpf/Android.bp rename to service-t/native/libs/libnetworkstats/Android.bp index d586d680c7..bceeefaddd 100644 --- a/service-t/native/libs/libnetdbpf/Android.bp +++ b/service-t/native/libs/libnetworkstats/Android.bp @@ -15,16 +15,11 @@ // package { - // See: http://go/android-license-faq - // A large-scale-change added 'default_applicable_licenses' to import - // all of the 'license_kinds' from "system_netd_license" - // to get the below license kinds: - // SPDX-license-identifier-Apache-2.0 - default_applicable_licenses: ["system_netd_license"], + default_applicable_licenses: ["Android-Apache-2.0"], } cc_library { - name: "libnetdbpf", + name: "libnetworkstats", vendor_available: false, host_supported: false, header_libs: ["bpf_connectivity_headers"], @@ -34,30 +29,43 @@ cc_library { shared_libs: [ "libbase", "liblog", - "libnetdutils", ], export_include_dirs: ["include"], - defaults: ["netd_defaults"], + cflags: [ + "-Wall", + "-Werror", + "-Wno-unused-parameter", + "-Wthread-safety", + ], sanitize: { cfi: true, }, + apex_available: [ + "//apex_available:platform", + "com.android.tethering", + ], + min_sdk_version: "30", } cc_test { - name: "libnetdbpf_test", - test_suites: ["device-tests"], - require_root: true, + name: "libnetworkstats_test", + test_suites: ["general-tests"], + require_root: true, // required by setrlimitForTest() header_libs: ["bpf_connectivity_headers"], srcs: [ "BpfNetworkStatsTest.cpp", ], - defaults: ["netd_defaults"], + cflags: [ + "-Wall", + "-Werror", + "-Wno-unused-parameter", + "-Wthread-safety", + ], static_libs: ["libgmock"], shared_libs: [ "libbase", "liblog", - "libnetdbpf", - "libnetdutils", + "libnetworkstats", "libutils", ], } diff --git a/service-t/native/libs/libnetdbpf/BpfNetworkStats.cpp b/service-t/native/libs/libnetworkstats/BpfNetworkStats.cpp similarity index 100% rename from service-t/native/libs/libnetdbpf/BpfNetworkStats.cpp rename to service-t/native/libs/libnetworkstats/BpfNetworkStats.cpp diff --git a/service-t/native/libs/libnetdbpf/BpfNetworkStatsTest.cpp b/service-t/native/libs/libnetworkstats/BpfNetworkStatsTest.cpp similarity index 99% rename from service-t/native/libs/libnetdbpf/BpfNetworkStatsTest.cpp rename to service-t/native/libs/libnetworkstats/BpfNetworkStatsTest.cpp index fb8f0ec6ea..03e6016065 100644 --- a/service-t/native/libs/libnetdbpf/BpfNetworkStatsTest.cpp +++ b/service-t/native/libs/libnetworkstats/BpfNetworkStatsTest.cpp @@ -33,7 +33,6 @@ #include #include -#include #include "bpf/BpfMap.h" #include "bpf/BpfUtils.h" #include "netdbpf/BpfNetworkStats.h" diff --git a/service-t/native/libs/libnetdbpf/include/netdbpf/BpfNetworkStats.h b/service-t/native/libs/libnetworkstats/include/netdbpf/BpfNetworkStats.h similarity index 100% rename from service-t/native/libs/libnetdbpf/include/netdbpf/BpfNetworkStats.h rename to service-t/native/libs/libnetworkstats/include/netdbpf/BpfNetworkStats.h diff --git a/service/native/TrafficController.cpp b/service/native/TrafficController.cpp index cac545d4bc..97fcc43194 100644 --- a/service/native/TrafficController.cpp +++ b/service/native/TrafficController.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include diff --git a/tests/unit/Android.bp b/tests/unit/Android.bp index 48751f4383..f95e79fb7b 100644 --- a/tests/unit/Android.bp +++ b/tests/unit/Android.bp @@ -38,8 +38,8 @@ java_defaults { "liblog", "liblzma", "libnativehelper", - "libnetdbpf", "libnetdutils", + "libnetworkstats", "libnetworkstatsfactorytestjni", "libpackagelistparser", "libpcre2", diff --git a/tests/unit/jni/Android.bp b/tests/unit/jni/Android.bp index fe971e7f3b..0f71c1357d 100644 --- a/tests/unit/jni/Android.bp +++ b/tests/unit/jni/Android.bp @@ -24,7 +24,7 @@ cc_library_shared { "libbpf_android", "liblog", "libnativehelper", - "libnetdbpf", "libnetdutils", + "libnetworkstats", ], }