From 74ff3ee50106f94e9848cbd347694c86a32c9cc5 Mon Sep 17 00:00:00 2001 From: Ken Chen Date: Thu, 14 Jul 2022 16:46:39 +0800 Subject: [PATCH] Rename dscp_policy.o to dscpPolicy.o Underscore character may cause bpf prog/map naming collision. For example, x.o with map y_z and x_y.o with map z both result in x_y_z prog/map name, which should be prevented during compile-time. aosp/2147825 will prohibit underscore character in bpf source name (source name derives the obj name). Existing bpf modules with underscore characters in source name need to be updated accordingly. Bug: 236706995 Test: atest bpf_existence_test Test: adb root; adb shell ls -l sys/fs/bpf/net_shared | grep dscpPolicy Change-Id: Ibe98944d09d42bd11b78b5e9ae35ded48c70416d --- Tethering/apex/Android.bp | 4 ++-- bpf_progs/Android.bp | 4 ++-- bpf_progs/{dscp_policy.c => dscpPolicy.c} | 2 +- bpf_progs/{dscp_policy.h => dscpPolicy.h} | 0 .../server/connectivity/DscpPolicyTracker.java | 8 ++++---- tests/mts/bpf_existence_test.cpp | 18 +++++++++--------- 6 files changed, 18 insertions(+), 18 deletions(-) rename bpf_progs/{dscp_policy.c => dscpPolicy.c} (99%) rename bpf_progs/{dscp_policy.h => dscpPolicy.h} (100%) diff --git a/Tethering/apex/Android.bp b/Tethering/apex/Android.bp index 770c092b9e..a7028b7c02 100644 --- a/Tethering/apex/Android.bp +++ b/Tethering/apex/Android.bp @@ -85,7 +85,7 @@ apex { bpfs: [ "block.o", "clatd.o", - "dscp_policy.o", + "dscpPolicy.o", "netd.o", "offload.o", "offload@btf.o", @@ -209,7 +209,7 @@ override_apex { bpfs: [ "block.o", "clatd.o", - "dscp_policy.o", + "dscpPolicy.o", "netd.o", "offload@inprocess.o", "test@inprocess.o", diff --git a/bpf_progs/Android.bp b/bpf_progs/Android.bp index 6ab5281723..c2e28f4e01 100644 --- a/bpf_progs/Android.bp +++ b/bpf_progs/Android.bp @@ -72,8 +72,8 @@ bpf { } bpf { - name: "dscp_policy.o", - srcs: ["dscp_policy.c"], + name: "dscpPolicy.o", + srcs: ["dscpPolicy.c"], btf: true, cflags: [ "-Wall", diff --git a/bpf_progs/dscp_policy.c b/bpf_progs/dscpPolicy.c similarity index 99% rename from bpf_progs/dscp_policy.c rename to bpf_progs/dscpPolicy.c index e45c1d402a..25abd2bcc6 100644 --- a/bpf_progs/dscp_policy.c +++ b/bpf_progs/dscpPolicy.c @@ -31,7 +31,7 @@ #define BPFLOADER_MIN_VER BPFLOADER_T_BETA3_VERSION #include "bpf_helpers.h" -#include "dscp_policy.h" +#include "dscpPolicy.h" #define ECN_MASK 3 #define IP4_OFFSET(field, header) (header + offsetof(struct iphdr, field)) diff --git a/bpf_progs/dscp_policy.h b/bpf_progs/dscpPolicy.h similarity index 100% rename from bpf_progs/dscp_policy.h rename to bpf_progs/dscpPolicy.h diff --git a/service/src/com/android/server/connectivity/DscpPolicyTracker.java b/service/src/com/android/server/connectivity/DscpPolicyTracker.java index 7829d1a3c7..0e9b459729 100644 --- a/service/src/com/android/server/connectivity/DscpPolicyTracker.java +++ b/service/src/com/android/server/connectivity/DscpPolicyTracker.java @@ -52,12 +52,12 @@ public class DscpPolicyTracker { private static final String TAG = DscpPolicyTracker.class.getSimpleName(); private static final String PROG_PATH = - "/sys/fs/bpf/net_shared/prog_dscp_policy_schedcls_set_dscp"; + "/sys/fs/bpf/net_shared/prog_dscpPolicy_schedcls_set_dscp"; // Name is "map + *.o + map_name + map". Can probably shorten this private static final String IPV4_POLICY_MAP_PATH = makeMapPath( - "dscp_policy_ipv4_dscp_policies"); + "dscpPolicy_ipv4_dscp_policies"); private static final String IPV6_POLICY_MAP_PATH = makeMapPath( - "dscp_policy_ipv6_dscp_policies"); + "dscpPolicy_ipv6_dscp_policies"); private static final int MAX_POLICIES = 16; private static String makeMapPath(String which) { @@ -213,7 +213,7 @@ public class DscpPolicyTracker { } /** - * Add the provided DSCP policy to the bpf map. Attach bpf program dscp_policy to iface + * Add the provided DSCP policy to the bpf map. Attach bpf program dscpPolicy to iface * if not already attached. Response will be sent back to nai with status. * * DSCP_POLICY_STATUS_SUCCESS - if policy was added successfully diff --git a/tests/mts/bpf_existence_test.cpp b/tests/mts/bpf_existence_test.cpp index 2613363f37..67b4f42f4f 100644 --- a/tests/mts/bpf_existence_test.cpp +++ b/tests/mts/bpf_existence_test.cpp @@ -87,13 +87,13 @@ static const set MAINLINE_FOR_T_PLUS = { SHARED "map_block_blocked_ports_map", SHARED "map_clatd_clat_egress4_map", SHARED "map_clatd_clat_ingress6_map", - SHARED "map_dscp_policy_ipv4_dscp_policies_map", - SHARED "map_dscp_policy_ipv4_socket_to_policies_map_A", - SHARED "map_dscp_policy_ipv4_socket_to_policies_map_B", - SHARED "map_dscp_policy_ipv6_dscp_policies_map", - SHARED "map_dscp_policy_ipv6_socket_to_policies_map_A", - SHARED "map_dscp_policy_ipv6_socket_to_policies_map_B", - SHARED "map_dscp_policy_switch_comp_map", + SHARED "map_dscpPolicy_ipv4_dscp_policies_map", + SHARED "map_dscpPolicy_ipv4_socket_to_policies_map_A", + SHARED "map_dscpPolicy_ipv4_socket_to_policies_map_B", + SHARED "map_dscpPolicy_ipv6_dscp_policies_map", + SHARED "map_dscpPolicy_ipv6_socket_to_policies_map_A", + SHARED "map_dscpPolicy_ipv6_socket_to_policies_map_B", + SHARED "map_dscpPolicy_switch_comp_map", NETD "map_netd_app_uid_stats_map", NETD "map_netd_configuration_map", NETD "map_netd_cookie_tag_map", @@ -126,8 +126,8 @@ static const set MAINLINE_FOR_T_5_4_PLUS = { // Provided by *current* mainline module for T+ devices with 5.15+ kernels static const set MAINLINE_FOR_T_5_15_PLUS = { - SHARED "prog_dscp_policy_schedcls_set_dscp_ether", - SHARED "prog_dscp_policy_schedcls_set_dscp_raw_ip", + SHARED "prog_dscpPolicy_schedcls_set_dscp_ether", + SHARED "prog_dscpPolicy_schedcls_set_dscp_raw_ip", }; void addAll(set* a, const set& b) {