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