bpf_map_def: increase BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE from 32 to 66

will allow us to store full pin location, longest we currently have is 64 + NULL:
  $ adb shell find /sys/fs/bpf | egrep net | egrep '.{64}'
  /sys/fs/bpf/netd_shared/prog_netd_cgroupsockrelease_inet_release
  $ adb shell find /sys/fs/bpf | egrep net | egrep '.{65}'
  <nothing>

Choose small value so we don't needlessly bloat the .o's.
This can be trivially increased on demand.

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I62015d2703fdee004fb7279d8f9ca83f7462a4df
This commit is contained in:
Maciej Żenczykowski 2025-07-29 17:27:11 -07:00
commit 5765db482c
2 changed files with 4 additions and 4 deletions

View file

@ -120,7 +120,7 @@ void validatePinDir(const char s[BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE]) {
if (!strncmp(s, "netd_shared/", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE)) return;
if (!strncmp(s, "loader/", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE)) return;
}
ALOGE("unrecognized pin_subdir '%-32s'", s);
ALOGE("unrecognized pin_subdir '%-*s'", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE, s);
// Note: we *can* just abort() here as we only load bpf .o files shipped
// in the same mainline module / apex as NetBpfLoad itself.
abort();

View file

@ -105,7 +105,7 @@ struct optional_bool { bool optional; };
// Length of strings (incl. selinux_context and pin_subdir)
// in the bpf_map_def and bpf_prog_def structs.
#define BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE 32
#define BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE 66 // must be even for alignment sanity
/*
* Map structure to be used by Android eBPF C programs. The Android eBPF loader
@ -152,7 +152,7 @@ struct bpf_map_def {
// This needs to be updated whenever the above structure definition is expanded.
// These asserts are here to make sure we have cross-6-arch consistency.
_Static_assert(sizeof(struct bpf_map_def) == 112, "sizeof struct bpf_map_def != 112");
_Static_assert(sizeof(struct bpf_map_def) == 48 + 2 * BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE, "wrong sizeof struct bpf_map_def");
_Static_assert(__alignof__(struct bpf_map_def) == 4, "__alignof__ struct bpf_map_def != 4");
_Static_assert(_Alignof(struct bpf_map_def) == 4, "_Alignof struct bpf_map_def != 4");
@ -177,6 +177,6 @@ struct bpf_prog_def {
// This needs to be updated whenever the above structure definition is expanded.
// These asserts are here to make sure we have cross-6-arch consistency.
_Static_assert(sizeof(struct bpf_prog_def) == 92, "sizeof struct bpf_prog_def != 92");
_Static_assert(sizeof(struct bpf_prog_def) == 28 + 2 * BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE, "wrong sizeof struct bpf_prog_def");
_Static_assert(__alignof__(struct bpf_prog_def) == 4, "__alignof__ struct bpf_prog_def != 4");
_Static_assert(_Alignof(struct bpf_prog_def) == 4, "_Alignof struct bpf_prog_def != 4");