Commit f74a53d9 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Daniel Borkmann

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: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent ea9b6362
...@@ -1053,7 +1053,7 @@ static int load_with_options(int argc, char **argv, bool first_prog_only) ...@@ -1053,7 +1053,7 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
j = 0; j = 0;
while (j < old_map_fds && map_replace[j].name) { while (j < old_map_fds && map_replace[j].name) {
i = 0; i = 0;
bpf_map__for_each(map, obj) { bpf_object__for_each_map(map, obj) {
if (!strcmp(bpf_map__name(map), map_replace[j].name)) { if (!strcmp(bpf_map__name(map), map_replace[j].name)) {
map_replace[j].idx = i; map_replace[j].idx = i;
break; break;
...@@ -1074,7 +1074,7 @@ static int load_with_options(int argc, char **argv, bool first_prog_only) ...@@ -1074,7 +1074,7 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
/* Set ifindex and name reuse */ /* Set ifindex and name reuse */
j = 0; j = 0;
idx = 0; idx = 0;
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))
bpf_map__set_ifindex(map, ifindex); bpf_map__set_ifindex(map, ifindex);
......
...@@ -2100,7 +2100,7 @@ int bpf_object__pin_maps(struct bpf_object *obj, const char *path) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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); ...@@ -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);
......
...@@ -1489,7 +1489,7 @@ apply_obj_config_object(struct bpf_object *obj) ...@@ -1489,7 +1489,7 @@ apply_obj_config_object(struct bpf_object *obj)
struct bpf_map *map; struct bpf_map *map;
int err; int err;
bpf_map__for_each(map, obj) { bpf_object__for_each_map(map, obj) {
err = apply_obj_config_map(map); err = apply_obj_config_map(map);
if (err) if (err)
return err; return err;
...@@ -1513,7 +1513,7 @@ int bpf__apply_obj_config(void) ...@@ -1513,7 +1513,7 @@ int bpf__apply_obj_config(void)
#define bpf__for_each_map(pos, obj, objtmp) \ #define bpf__for_each_map(pos, obj, objtmp) \
bpf_object__for_each_safe(obj, objtmp) \ bpf_object__for_each_safe(obj, objtmp) \
bpf_map__for_each(pos, obj) bpf_object__for_each_map(pos, obj)
#define bpf__for_each_map_named(pos, obj, objtmp, name) \ #define bpf__for_each_map_named(pos, obj, objtmp, name) \
bpf__for_each_map(pos, obj, objtmp) \ bpf__for_each_map(pos, obj, objtmp) \
......
...@@ -67,7 +67,7 @@ int test_walk_maps(struct bpf_object *obj, bool verbose) ...@@ -67,7 +67,7 @@ int test_walk_maps(struct bpf_object *obj, bool verbose)
struct bpf_map *map; struct bpf_map *map;
int cnt = 0; int cnt = 0;
bpf_map__for_each(map, obj) { bpf_object__for_each_map(map, obj) {
cnt++; cnt++;
if (verbose) if (verbose)
printf("Map (count:%d) name: %s\n", cnt, printf("Map (count:%d) name: %s\n", cnt,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment