Skip to contentSkip to conversation

libbpf 1.0: deprecate bpf_map__is_offload_neutral()

PATCH Applied Christy Lee 2 participants 2 messages Jan 5, 2022 – Jan 6, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libbpf 1.0: deprecate bpf_map__is_offload_neutral()

Deprecate bpf_map__is_offload_neutral(). It’s most probably broken already. PERF_EVENT_ARRAY isn’t the only map that’s not suitable for hardware offloading. Applications can directly check map type instead.

[0] Closes: https://github.com/libbpf/libbpf/issues/306

---
 tools/bpf/bpftool/prog.c | 2 +-
 tools/lib/bpf/libbpf.h   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
tools/bpf/bpftool/prog.c +1 -1
index f874896c4154..2a21d50516bc 100644
@@ -1655,7 +1655,7 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
 	j = 0;
 	idx = 0;
 	bpf_object__for_each_map(map, obj) {
-		if (!bpf_map__is_offload_neutral(map))
+		if (bpf_map__type(map) != BPF_MAP_TYPE_PERF_EVENT_ARRAY)
 			bpf_map__set_ifindex(map, ifindex);
 
 		if (j < old_map_fds && idx == map_replace[j].idx) {
tools/lib/bpf/libbpf.h +1 -0
index 85dfef88b3d2..ec4309cb9771 100644
@@ -744,6 +744,7 @@ LIBBPF_API void *bpf_map__priv(const struct bpf_map *map);
 LIBBPF_API int bpf_map__set_initial_value(struct bpf_map *map,
 					  const void *data, size_t size);
 LIBBPF_API const void *bpf_map__initial_value(struct bpf_map *map, size_t *psize);
+LIBBPF_DEPRECATED_SINCE(0, 8, "use bpf_map__type() instead")
 LIBBPF_API bool bpf_map__is_offload_neutral(const struct bpf_map *map);
 
 /**
Signature · 1 line
2.30.2
#1 lore raw
Quoted 10 lines · Christy Lee

Deprecate bpf_map__is_offload_neutral(). It’s most probably broken already. PERF_EVENT_ARRAY isn’t the only map that’s not suitable for hardware offloading. Applications can directly check map type instead.

[0] Closes: https://github.com/libbpf/libbpf/issues/306

---

Applied to bpf-next, thanks!

Quoted 32 lines
 tools/bpf/bpftool/prog.c | 2 +-
 tools/lib/bpf/libbpf.h   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
tools/bpf/bpftool/prog.c +1 -1
index f874896c4154..2a21d50516bc 100644
@@ -1655,7 +1655,7 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
        j = 0;
        idx = 0;
        bpf_object__for_each_map(map, obj) {
-               if (!bpf_map__is_offload_neutral(map))
+               if (bpf_map__type(map) != BPF_MAP_TYPE_PERF_EVENT_ARRAY)
                        bpf_map__set_ifindex(map, ifindex);
 
                if (j < old_map_fds && idx == map_replace[j].idx) {
tools/lib/bpf/libbpf.h +1 -1
index 85dfef88b3d2..ec4309cb9771 100644
@@ -744,6 +744,7 @@ LIBBPF_API void *bpf_map__priv(const struct bpf_map *map);
 LIBBPF_API int bpf_map__set_initial_value(struct bpf_map *map,
                                          const void *data, size_t size);
 LIBBPF_API const void *bpf_map__initial_value(struct bpf_map *map, size_t *psize);
+LIBBPF_DEPRECATED_SINCE(0, 8, "use bpf_map__type() instead")
 LIBBPF_API bool bpf_map__is_offload_neutral(const struct bpf_map *map);
 
 /**
--

2.30.2