mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
libbpf: Deprecate bpf_objects_list
Add a flag to `enum libbpf_strict_mode' to disable the global `bpf_objects_list', preventing race conditions when concurrent threads call bpf_object__open() or bpf_object__close(). bpf_object__next() will return NULL if this option is set. Callers may achieve the same workflow by tracking bpf_objects in application code. [0] Closes: https://github.com/libbpf/libbpf/issues/293 Signed-off-by: Joe Burton <jevburton@google.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211026223528.413950-1-jevburton.kernel@gmail.com
This commit is contained in:
parent
20d1b54a52
commit
689624f037
3 changed files with 15 additions and 2 deletions
|
@ -1148,6 +1148,7 @@ static struct bpf_object *bpf_object__new(const char *path,
|
|||
size_t obj_buf_sz,
|
||||
const char *obj_name)
|
||||
{
|
||||
bool strict = (libbpf_mode & LIBBPF_STRICT_NO_OBJECT_LIST);
|
||||
struct bpf_object *obj;
|
||||
char *end;
|
||||
|
||||
|
@ -1188,7 +1189,8 @@ static struct bpf_object *bpf_object__new(const char *path,
|
|||
obj->loaded = false;
|
||||
|
||||
INIT_LIST_HEAD(&obj->list);
|
||||
list_add(&obj->list, &bpf_objects_list);
|
||||
if (!strict)
|
||||
list_add(&obj->list, &bpf_objects_list);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
@ -7935,6 +7937,10 @@ struct bpf_object *
|
|||
bpf_object__next(struct bpf_object *prev)
|
||||
{
|
||||
struct bpf_object *next;
|
||||
bool strict = (libbpf_mode & LIBBPF_STRICT_NO_OBJECT_LIST);
|
||||
|
||||
if (strict)
|
||||
return NULL;
|
||||
|
||||
if (!prev)
|
||||
next = list_first_entry(&bpf_objects_list,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue