From 22c1a3aa1fce505bfb5564304c06f5e411bf9bc6 Mon Sep 17 00:00:00 2001 From: markchien Date: Tue, 18 Jan 2022 18:51:00 +0800 Subject: [PATCH] Use U32 from shared library There is U32 added in frameworks/libs/net. Use shared one to avoid duplicated code. Bug: 215095957 Test: m Change-Id: I861bc2f65ea947a908de2ec83e9b137d3342c8ce --- .../networkstack/tethering/BpfCoordinator.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Tethering/src/com/android/networkstack/tethering/BpfCoordinator.java b/Tethering/src/com/android/networkstack/tethering/BpfCoordinator.java index 64365ccc16..2ef1d5b820 100644 --- a/Tethering/src/com/android/networkstack/tethering/BpfCoordinator.java +++ b/Tethering/src/com/android/networkstack/tethering/BpfCoordinator.java @@ -65,7 +65,7 @@ import com.android.net.module.util.BpfMap; import com.android.net.module.util.CollectionUtils; import com.android.net.module.util.InterfaceParams; import com.android.net.module.util.NetworkStackConstants; -import com.android.net.module.util.Struct; +import com.android.net.module.util.Struct.U32; import com.android.net.module.util.bpf.Tether4Key; import com.android.net.module.util.bpf.Tether4Value; import com.android.net.module.util.netlink.ConntrackMessage; @@ -1177,22 +1177,13 @@ public class BpfCoordinator { } } - /** - * Simple struct that only contains a u32. Must be public because Struct needs access to it. - * TODO: make this a public inner class of Struct so anyone can use it as, e.g., Struct.U32? - */ - public static class U32Struct extends Struct { - @Struct.Field(order = 0, type = Struct.Type.U32) - public long val; - } - private void dumpCounters(@NonNull IndentingPrintWriter pw) { if (!mDeps.isAtLeastS()) { pw.println("No counter support"); return; } - try (BpfMap map = new BpfMap<>(TETHER_ERROR_MAP_PATH, - BpfMap.BPF_F_RDONLY, U32Struct.class, U32Struct.class)) { + try (BpfMap map = new BpfMap<>(TETHER_ERROR_MAP_PATH, BpfMap.BPF_F_RDONLY, + U32.class, U32.class)) { map.forEach((k, v) -> { String counterName;