* [PATCH iproute2] lib: bpf_legacy: fix bpffs mount when /sys/fs/bpf exists
@ 2021-09-21 9:33 Andrea Claudi
2021-09-21 10:04 ` Toke Høiland-Jørgensen
0 siblings, 1 reply; 2+ messages in thread
From: Andrea Claudi @ 2021-09-21 9:33 UTC (permalink / raw)
To: netdev; +Cc: stephen, dsahern
bpf selftests using iproute2 fails with:
$ ip link set dev veth0 xdp object ../bpf/xdp_dummy.o section xdp_dummy
Continuing without mounted eBPF fs. Too old kernel?
mkdir (null)/globals failed: No such file or directory
Unable to load program
This happens when the /sys/fs/bpf directory exists. In this case, mkdir
in bpf_mnt_check_target() fails with errno == EEXIST, and the function
returns -1. Thus bpf_get_work_dir() does not call bpf_mnt_fs() and the
bpffs is not mounted.
Fix this in bpf_mnt_check_target(), returning 0 when the mountpoint
exists.
Fixes: d4fcdbbec9df ("lib/bpf: Fix and simplify bpf_mnt_check_target()")
Reported-by: Mingyu Shi <mshi@redhat.com>
Reported-by: Jiri Benc <jbenc@redhat.com>
Suggested-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
---
lib/bpf_legacy.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/bpf_legacy.c b/lib/bpf_legacy.c
index 91086aa2..275941dd 100644
--- a/lib/bpf_legacy.c
+++ b/lib/bpf_legacy.c
@@ -513,9 +513,12 @@ static int bpf_mnt_check_target(const char *target)
int ret;
ret = mkdir(target, S_IRWXU);
- if (ret && errno != EEXIST)
+ if (ret) {
+ if (errno == EEXIST)
+ return 0;
fprintf(stderr, "mkdir %s failed: %s\n", target,
strerror(errno));
+ }
return ret;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH iproute2] lib: bpf_legacy: fix bpffs mount when /sys/fs/bpf exists
2021-09-21 9:33 [PATCH iproute2] lib: bpf_legacy: fix bpffs mount when /sys/fs/bpf exists Andrea Claudi
@ 2021-09-21 10:04 ` Toke Høiland-Jørgensen
0 siblings, 0 replies; 2+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-09-21 10:04 UTC (permalink / raw)
To: Andrea Claudi, netdev; +Cc: stephen, dsahern
Andrea Claudi <aclaudi@redhat.com> writes:
> bpf selftests using iproute2 fails with:
>
> $ ip link set dev veth0 xdp object ../bpf/xdp_dummy.o section xdp_dummy
> Continuing without mounted eBPF fs. Too old kernel?
> mkdir (null)/globals failed: No such file or directory
> Unable to load program
>
> This happens when the /sys/fs/bpf directory exists. In this case, mkdir
> in bpf_mnt_check_target() fails with errno == EEXIST, and the function
> returns -1. Thus bpf_get_work_dir() does not call bpf_mnt_fs() and the
> bpffs is not mounted.
>
> Fix this in bpf_mnt_check_target(), returning 0 when the mountpoint
> exists.
>
> Fixes: d4fcdbbec9df ("lib/bpf: Fix and simplify bpf_mnt_check_target()")
> Reported-by: Mingyu Shi <mshi@redhat.com>
> Reported-by: Jiri Benc <jbenc@redhat.com>
> Suggested-by: Jiri Benc <jbenc@redhat.com>
> Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-21 10:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-21 9:33 [PATCH iproute2] lib: bpf_legacy: fix bpffs mount when /sys/fs/bpf exists Andrea Claudi
2021-09-21 10:04 ` Toke Høiland-Jørgensen
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.