All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf] libbpf: restore errno return for functions that were already returning it
@ 2021-07-06 12:23 Toke Høiland-Jørgensen
  2021-07-07  4:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-07-06 12:23 UTC (permalink / raw)
  To: Andrii Nakryiko; +Cc: bpf, netdev, Toke Høiland-Jørgensen

The update to streamline libbpf error reporting intended to change all
functions to return the errno as a negative return value if
LIBBPF_STRICT_DIRECT_ERRS is set. However, if the flag is *not* set, the
return value changes for the two functions that were already returning a
negative errno unconditionally: bpf_link__unpin() and perf_buffer__poll().

This is a user-visible API change that breaks applications; so let's revert
these two functions back to unconditionally returning a negative errno
value.

Fixes: e9fc3ce99b34 ("libbpf: Streamline error reporting for high-level APIs")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 tools/lib/bpf/libbpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 1e04ce724240..6f5e2757bb3c 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -10136,7 +10136,7 @@ int bpf_link__unpin(struct bpf_link *link)
 
 	err = unlink(link->pin_path);
 	if (err != 0)
-		return libbpf_err_errno(err);
+		return -errno;
 
 	pr_debug("link fd=%d: unpinned from %s\n", link->fd, link->pin_path);
 	zfree(&link->pin_path);
@@ -11197,7 +11197,7 @@ int perf_buffer__poll(struct perf_buffer *pb, int timeout_ms)
 
 	cnt = epoll_wait(pb->epoll_fd, pb->events, pb->cpu_cnt, timeout_ms);
 	if (cnt < 0)
-		return libbpf_err_errno(cnt);
+		return -errno;
 
 	for (i = 0; i < cnt; i++) {
 		struct perf_cpu_buf *cpu_buf = pb->events[i].data.ptr;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf] libbpf: restore errno return for functions that were already returning it
  2021-07-06 12:23 [PATCH bpf] libbpf: restore errno return for functions that were already returning it Toke Høiland-Jørgensen
@ 2021-07-07  4:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-07-07  4:30 UTC (permalink / raw)
  To: =?utf-8?b?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2VuIDx0b2tlQHJlZGhhdC5jb20+?=
  Cc: andrii, bpf, netdev

Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

On Tue,  6 Jul 2021 14:23:55 +0200 you wrote:
> The update to streamline libbpf error reporting intended to change all
> functions to return the errno as a negative return value if
> LIBBPF_STRICT_DIRECT_ERRS is set. However, if the flag is *not* set, the
> return value changes for the two functions that were already returning a
> negative errno unconditionally: bpf_link__unpin() and perf_buffer__poll().
> 
> This is a user-visible API change that breaks applications; so let's revert
> these two functions back to unconditionally returning a negative errno
> value.
> 
> [...]

Here is the summary with links:
  - [bpf] libbpf: restore errno return for functions that were already returning it
    https://git.kernel.org/bpf/bpf/c/af0efa050caa

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-07  4:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 12:23 [PATCH bpf] libbpf: restore errno return for functions that were already returning it Toke Høiland-Jørgensen
2021-07-07  4:30 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.