aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/lib/bpf/libbpf.c
diff options
context:
space:
mode:
authorRafael David Tinoco <rafaeldtinoco@ubuntu.com>2021-03-23 01:09:52 -0300
committerAlexei Starovoitov <ast@kernel.org>2021-03-25 19:23:27 -0700
commit155f556d64b1a48710f01305e14bb860734ed1e3 (patch)
tree6a719b790128b4142547560041bfc912cc7fe8c4 /tools/lib/bpf/libbpf.c
parentMerge branch 'add support for batched ops in LPM trie' (diff)
downloadwireguard-linux-155f556d64b1a48710f01305e14bb860734ed1e3.tar.xz
wireguard-linux-155f556d64b1a48710f01305e14bb860734ed1e3.zip
libbpf: Add bpf object kern_version attribute setter
Unfortunately some distros don't have their kernel version defined accurately in <linux/version.h> due to different long term support reasons. It is important to have a way to override the bpf kern_version attribute during runtime: some old kernels might still check for kern_version attribute during bpf_prog_load(). Signed-off-by: Rafael David Tinoco <rafaeldtinoco@ubuntu.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/20210323040952.2118241-1-rafaeldtinoco@ubuntu.com
Diffstat (limited to 'tools/lib/bpf/libbpf.c')
-rw-r--r--tools/lib/bpf/libbpf.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 10a0a67699f1..cebb0e852cf8 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -8270,6 +8270,16 @@ int bpf_object__btf_fd(const struct bpf_object *obj)
return obj->btf ? btf__fd(obj->btf) : -1;
}
+int bpf_object__set_kversion(struct bpf_object *obj, __u32 kern_version)
+{
+ if (obj->loaded)
+ return -EINVAL;
+
+ obj->kern_version = kern_version;
+
+ return 0;
+}
+
int bpf_object__set_priv(struct bpf_object *obj, void *priv,
bpf_object_clear_priv_t clear_priv)
{