NetBpfLoad: add self-check for bpfGetNext{Prog,Map}Id()
This detects some kernel bugs, particularly on Xiaomi devices. Bug: 414570528 Test: TreeHugger Flag: EXEMPT mainline Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ic099c53dc1ad5f01bfebfddd29b1024f5b936fe5
This commit is contained in:
parent
e2fe8648d4
commit
18523cb5f3
1 changed files with 56 additions and 0 deletions
|
|
@ -251,6 +251,18 @@ inline int runProgram(const borrowed_fd &prog_fd, const void *data,
|
|||
});
|
||||
}
|
||||
|
||||
// 4.14+: returns next id > prog_id, or 0 (and sets errno)
|
||||
inline uint32_t bpfGetNextProgId(const uint32_t prog_id) {
|
||||
bpf_attr arg = { .start_id = prog_id };
|
||||
return bpf(BPF_PROG_GET_NEXT_ID, &arg) ? 0 : arg.next_id;
|
||||
}
|
||||
|
||||
// 4.14+: returns next id > map_id, or 0 (and sets errno)
|
||||
inline uint32_t bpfGetNextMapId(const uint32_t map_id) {
|
||||
bpf_attr arg = { .start_id = map_id };
|
||||
return bpf(BPF_MAP_GET_NEXT_ID, &arg) ? 0 : arg.next_id;
|
||||
}
|
||||
|
||||
// BPF_OBJ_GET_INFO_BY_FD requires 4.14+ kernel
|
||||
//
|
||||
// Note: some fields are only defined in newer kernels (ie. the map_info struct grows
|
||||
|
|
|
|||
Loading…
Reference in a new issue