From 07d3013b0de54d2d51b2bd37a47575b10601cbde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Sat, 23 Apr 2022 12:33:32 -0700 Subject: [PATCH] enable btf for offload.o & test.o MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The objdump -x visible changes between old and new versions of the mainline shipped .o files are really very minimal: just the inclusion of a new .BTF section and changes/removals of some 'l' entries from the symbol table. However, it turns out a change to symbol ordering is incompatible with BpfLoader Change-Id: Id658818d1d42763358747523615b7918d312588e --- Tethering/apex/Android.bp | 2 ++ bpf_progs/Android.bp | 22 ++++++++++++++++++++++ bpf_progs/offload.c | 8 ++++++++ bpf_progs/offload@btf.c | 1 + bpf_progs/test.c | 8 ++++++++ bpf_progs/test@btf.c | 1 + 6 files changed, 42 insertions(+) create mode 120000 bpf_progs/offload@btf.c create mode 120000 bpf_progs/test@btf.c diff --git a/Tethering/apex/Android.bp b/Tethering/apex/Android.bp index 4a4e6eee10..ee1063901e 100644 --- a/Tethering/apex/Android.bp +++ b/Tethering/apex/Android.bp @@ -88,7 +88,9 @@ apex { "dscp_policy.o", "netd.o", "offload.o", + "offload@btf.o", "test.o", + "test@btf.o", ], apps: [ "ServiceConnectivityResources", diff --git a/bpf_progs/Android.bp b/bpf_progs/Android.bp index 78fca29262..d9eb547742 100644 --- a/bpf_progs/Android.bp +++ b/bpf_progs/Android.bp @@ -91,6 +91,17 @@ bpf { ], } +bpf { + name: "offload@btf.o", + srcs: ["offload@btf.c"], + btf: true, + cflags: [ + "-Wall", + "-Werror", + "-DBTF", + ], +} + bpf { name: "test.o", srcs: ["test.c"], @@ -100,6 +111,17 @@ bpf { ], } +bpf { + name: "test@btf.o", + srcs: ["test@btf.c"], + btf: true, + cflags: [ + "-Wall", + "-Werror", + "-DBTF", + ], +} + bpf { name: "clatd.o", srcs: ["clatd.c"], diff --git a/bpf_progs/offload.c b/bpf_progs/offload.c index 2ec0792172..c71e881232 100644 --- a/bpf_progs/offload.c +++ b/bpf_progs/offload.c @@ -24,8 +24,16 @@ #define __kernel_udphdr udphdr #include +#ifdef BTF +// BTF is incompatible with bpfloaders < v0.10, hence for S (v0.2) we must +// ship a different file than for later versions, but we need bpfloader v0.25+ +// for obj@ver.o support +#define BPFLOADER_MIN_VER BPFLOADER_OBJ_AT_VER_VERSION +#else /* BTF */ // The resulting .o needs to load on the Android S bpfloader #define BPFLOADER_MIN_VER BPFLOADER_S_VERSION +#define BPFLOADER_MAX_VER BPFLOADER_OBJ_AT_VER_VERSION +#endif /* BTF */ #include "bpf_helpers.h" #include "bpf_net_helpers.h" diff --git a/bpf_progs/offload@btf.c b/bpf_progs/offload@btf.c new file mode 120000 index 0000000000..4092e0da16 --- /dev/null +++ b/bpf_progs/offload@btf.c @@ -0,0 +1 @@ +offload.c \ No newline at end of file diff --git a/bpf_progs/test.c b/bpf_progs/test.c index f2fcc8c86f..e22fe2a27d 100644 --- a/bpf_progs/test.c +++ b/bpf_progs/test.c @@ -18,8 +18,16 @@ #include #include +#ifdef BTF +// BTF is incompatible with bpfloaders < v0.10, hence for S (v0.2) we must +// ship a different file than for later versions, but we need bpfloader v0.25+ +// for obj@ver.o support +#define BPFLOADER_MIN_VER BPFLOADER_OBJ_AT_VER_VERSION +#else /* BTF */ // The resulting .o needs to load on the Android S bpfloader #define BPFLOADER_MIN_VER BPFLOADER_S_VERSION +#define BPFLOADER_MAX_VER BPFLOADER_OBJ_AT_VER_VERSION +#endif /* BTF */ #include "bpf_helpers.h" #include "bpf_net_helpers.h" diff --git a/bpf_progs/test@btf.c b/bpf_progs/test@btf.c new file mode 120000 index 0000000000..aeebb2626a --- /dev/null +++ b/bpf_progs/test@btf.c @@ -0,0 +1 @@ +test.c \ No newline at end of file