mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-07 17:19:07 +08:00
tools: libbpf: add a correctly named define for map iteration
For historical reasons the helper to loop over maps in an object is called bpf_map__for_each while it really should be called bpf_object__for_each_map. Rename and add a correctly named define for backward compatibility. Switch all in-tree users to the correct name (Quentin). Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
committed by
yonghong-song
parent
7e447c35b7
commit
14fc408f9d
@@ -2100,7 +2100,7 @@ int bpf_object__pin_maps(struct bpf_object *obj, const char *path)
|
|||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
bpf_map__for_each(map, obj) {
|
bpf_object__for_each_map(map, obj) {
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
@@ -2147,7 +2147,7 @@ int bpf_object__unpin_maps(struct bpf_object *obj, const char *path)
|
|||||||
if (!obj)
|
if (!obj)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
bpf_map__for_each(map, obj) {
|
bpf_object__for_each_map(map, obj) {
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
@@ -2835,7 +2835,7 @@ bpf_object__find_map_by_name(struct bpf_object *obj, const char *name)
|
|||||||
{
|
{
|
||||||
struct bpf_map *pos;
|
struct bpf_map *pos;
|
||||||
|
|
||||||
bpf_map__for_each(pos, obj) {
|
bpf_object__for_each_map(pos, obj) {
|
||||||
if (pos->name && !strcmp(pos->name, name))
|
if (pos->name && !strcmp(pos->name, name))
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
@@ -2928,7 +2928,7 @@ int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr,
|
|||||||
first_prog = prog;
|
first_prog = prog;
|
||||||
}
|
}
|
||||||
|
|
||||||
bpf_map__for_each(map, obj) {
|
bpf_object__for_each_map(map, obj) {
|
||||||
if (!bpf_map__is_offload_neutral(map))
|
if (!bpf_map__is_offload_neutral(map))
|
||||||
map->map_ifindex = attr->ifindex;
|
map->map_ifindex = attr->ifindex;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,10 +278,11 @@ bpf_object__find_map_by_offset(struct bpf_object *obj, size_t offset);
|
|||||||
|
|
||||||
LIBBPF_API struct bpf_map *
|
LIBBPF_API struct bpf_map *
|
||||||
bpf_map__next(struct bpf_map *map, struct bpf_object *obj);
|
bpf_map__next(struct bpf_map *map, struct bpf_object *obj);
|
||||||
#define bpf_map__for_each(pos, obj) \
|
#define bpf_object__for_each_map(pos, obj) \
|
||||||
for ((pos) = bpf_map__next(NULL, (obj)); \
|
for ((pos) = bpf_map__next(NULL, (obj)); \
|
||||||
(pos) != NULL; \
|
(pos) != NULL; \
|
||||||
(pos) = bpf_map__next((pos), (obj)))
|
(pos) = bpf_map__next((pos), (obj)))
|
||||||
|
#define bpf_map__for_each bpf_object__for_each_map
|
||||||
|
|
||||||
LIBBPF_API struct bpf_map *
|
LIBBPF_API struct bpf_map *
|
||||||
bpf_map__prev(struct bpf_map *map, struct bpf_object *obj);
|
bpf_map__prev(struct bpf_map *map, struct bpf_object *obj);
|
||||||
|
|||||||
Reference in New Issue
Block a user