mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-23 07:23:12 +02:00
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
This commit is contained in:
parent
3ac3f314c3
commit
155f556d64
|
@ -8270,6 +8270,16 @@ int bpf_object__btf_fd(const struct bpf_object *obj)
|
||||||
return obj->btf ? btf__fd(obj->btf) : -1;
|
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,
|
int bpf_object__set_priv(struct bpf_object *obj, void *priv,
|
||||||
bpf_object_clear_priv_t clear_priv)
|
bpf_object_clear_priv_t clear_priv)
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,6 +143,7 @@ LIBBPF_API int bpf_object__unload(struct bpf_object *obj);
|
||||||
|
|
||||||
LIBBPF_API const char *bpf_object__name(const struct bpf_object *obj);
|
LIBBPF_API const char *bpf_object__name(const struct bpf_object *obj);
|
||||||
LIBBPF_API unsigned int bpf_object__kversion(const struct bpf_object *obj);
|
LIBBPF_API unsigned int bpf_object__kversion(const struct bpf_object *obj);
|
||||||
|
LIBBPF_API int bpf_object__set_kversion(struct bpf_object *obj, __u32 kern_version);
|
||||||
|
|
||||||
struct btf;
|
struct btf;
|
||||||
LIBBPF_API struct btf *bpf_object__btf(const struct bpf_object *obj);
|
LIBBPF_API struct btf *bpf_object__btf(const struct bpf_object *obj);
|
||||||
|
|
|
@ -359,4 +359,5 @@ LIBBPF_0.4.0 {
|
||||||
bpf_linker__finalize;
|
bpf_linker__finalize;
|
||||||
bpf_linker__free;
|
bpf_linker__free;
|
||||||
bpf_linker__new;
|
bpf_linker__new;
|
||||||
|
bpf_object__set_kversion;
|
||||||
} LIBBPF_0.3.0;
|
} LIBBPF_0.3.0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user