libbpf-tools: update solisten for libbpf 1.0
Switch to libbpf 1.0 mode and adapt libbpf API usage accordingly.
@@ -125,7 +125,6 @@ int main(int argc, char **argv)
.parser = parse_arg,
.doc = argp_program_doc,
};
- struct perf_buffer_opts pb_opts;
struct perf_buffer *pb = NULL;
struct solisten_bpf *obj;
int err;
@@ -134,11 +133,7 @@ int main(int argc, char **argv)
if (err)
return err;
- err = bump_memlock_rlimit();
- if (err) {
- warn("failed to increase rlimit: %d\n", err);
- return 1;
- }
+ libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
obj = solisten_bpf__open();
if (!obj) {
@@ -167,11 +162,10 @@ int main(int argc, char **argv)
goto cleanup;
}
- pb_opts.sample_cb = handle_event;
- pb_opts.lost_cb = handle_lost_events;
- pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES, &pb_opts);
- err = libbpf_get_error(pb);
- if (err) {
+ pb = perf_buffer__new(bpf_map__fd(obj->maps.events), PERF_BUFFER_PAGES,
+ handle_event, handle_lost_events, NULL, NULL);
+ if (!pb) {
+ err = -errno;
warn("failed to open perf buffer: %d\n", err);
goto cleanup;
}
@@ -189,8 +183,8 @@ int main(int argc, char **argv)
while (!exiting) {
err = perf_buffer__poll(pb, PERF_POLL_TIMEOUT_MS);
- if (err < 0 && errno != EINTR) {
- warn("error polling perf buffer: %s\n", strerror(errno));
+ if (err < 0 && err != -EINTR) {
+ warn("error polling perf buffer: %s\n", strerror(-err));
goto cleanup;
}
/* reset err to return 0 if exiting */
