|
|
9e1e64 |
From d1f0f7f4e3e3a372a51e64bdd88f8ddecde1fbbf Mon Sep 17 00:00:00 2001
|
|
|
9e1e64 |
Message-Id: <d1f0f7f4e3e3a372a51e64bdd88f8ddecde1fbbf.1633614399.git.aclaudi@redhat.com>
|
|
|
9e1e64 |
In-Reply-To: <650694eb0120722499207078f965442ef7343bb1.1633614399.git.aclaudi@redhat.com>
|
|
|
9e1e64 |
References: <650694eb0120722499207078f965442ef7343bb1.1633614399.git.aclaudi@redhat.com>
|
|
|
9e1e64 |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
9e1e64 |
Date: Tue, 28 Sep 2021 11:46:43 +0200
|
|
|
9e1e64 |
Subject: [PATCH] lib: bpf_legacy: fix bpffs mount when /sys/fs/bpf exists
|
|
|
9e1e64 |
MIME-Version: 1.0
|
|
|
9e1e64 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9e1e64 |
Content-Transfer-Encoding: 8bit
|
|
|
9e1e64 |
|
|
|
9e1e64 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1995082
|
|
|
9e1e64 |
Upstream Status: iproute2.git commit 2f5825cb
|
|
|
9e1e64 |
|
|
|
9e1e64 |
commit 2f5825cb38028a14961a79844a069be4e3057eca
|
|
|
9e1e64 |
Author: Andrea Claudi <aclaudi@redhat.com>
|
|
|
9e1e64 |
Date: Tue Sep 21 11:33:24 2021 +0200
|
|
|
9e1e64 |
|
|
|
9e1e64 |
lib: bpf_legacy: fix bpffs mount when /sys/fs/bpf exists
|
|
|
9e1e64 |
|
|
|
9e1e64 |
bpf selftests using iproute2 fails with:
|
|
|
9e1e64 |
|
|
|
9e1e64 |
$ ip link set dev veth0 xdp object ../bpf/xdp_dummy.o section xdp_dummy
|
|
|
9e1e64 |
Continuing without mounted eBPF fs. Too old kernel?
|
|
|
9e1e64 |
mkdir (null)/globals failed: No such file or directory
|
|
|
9e1e64 |
Unable to load program
|
|
|
9e1e64 |
|
|
|
9e1e64 |
This happens when the /sys/fs/bpf directory exists. In this case, mkdir
|
|
|
9e1e64 |
in bpf_mnt_check_target() fails with errno == EEXIST, and the function
|
|
|
9e1e64 |
returns -1. Thus bpf_get_work_dir() does not call bpf_mnt_fs() and the
|
|
|
9e1e64 |
bpffs is not mounted.
|
|
|
9e1e64 |
|
|
|
9e1e64 |
Fix this in bpf_mnt_check_target(), returning 0 when the mountpoint
|
|
|
9e1e64 |
exists.
|
|
|
9e1e64 |
|
|
|
9e1e64 |
Fixes: d4fcdbbec9df ("lib/bpf: Fix and simplify bpf_mnt_check_target()")
|
|
|
9e1e64 |
Reported-by: Mingyu Shi <mshi@redhat.com>
|
|
|
9e1e64 |
Reported-by: Jiri Benc <jbenc@redhat.com>
|
|
|
9e1e64 |
Suggested-by: Jiri Benc <jbenc@redhat.com>
|
|
|
9e1e64 |
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
|
|
|
9e1e64 |
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
|
|
|
9e1e64 |
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
|
|
|
9e1e64 |
---
|
|
|
9e1e64 |
lib/bpf_legacy.c | 5 ++++-
|
|
|
9e1e64 |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
9e1e64 |
|
|
|
9e1e64 |
diff --git a/lib/bpf_legacy.c b/lib/bpf_legacy.c
|
|
|
9e1e64 |
index 7ec9ce9d..f9dfad6e 100644
|
|
|
9e1e64 |
--- a/lib/bpf_legacy.c
|
|
|
9e1e64 |
+++ b/lib/bpf_legacy.c
|
|
|
9e1e64 |
@@ -513,9 +513,12 @@ static int bpf_mnt_check_target(const char *target)
|
|
|
9e1e64 |
int ret;
|
|
|
9e1e64 |
|
|
|
9e1e64 |
ret = mkdir(target, S_IRWXU);
|
|
|
9e1e64 |
- if (ret && errno != EEXIST)
|
|
|
9e1e64 |
+ if (ret) {
|
|
|
9e1e64 |
+ if (errno == EEXIST)
|
|
|
9e1e64 |
+ return 0;
|
|
|
9e1e64 |
fprintf(stderr, "mkdir %s failed: %s\n", target,
|
|
|
9e1e64 |
strerror(errno));
|
|
|
9e1e64 |
+ }
|
|
|
9e1e64 |
|
|
|
9e1e64 |
return ret;
|
|
|
9e1e64 |
}
|
|
|
9e1e64 |
--
|
|
|
9e1e64 |
2.31.1
|
|
|
9e1e64 |
|