mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
BTF-playground: Stop opening vmlinux as it was a dead end
Signed-off-by: Jesper Dangaard Brouer <netoptimizer@brouer.com>
This commit is contained in:
@@ -118,7 +118,6 @@ int __btf_obj_info_via_fd(int fd, struct bpf_btf_info *info)
|
|||||||
#undef SZ
|
#undef SZ
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct btf *open_vmlinux_btf(void)
|
struct btf *open_vmlinux_btf(void)
|
||||||
{
|
{
|
||||||
struct btf* btf_obj;
|
struct btf* btf_obj;
|
||||||
@@ -127,6 +126,11 @@ struct btf *open_vmlinux_btf(void)
|
|||||||
//btf_obj = btf_load_vmlinux_from_kernel();
|
//btf_obj = btf_load_vmlinux_from_kernel();
|
||||||
btf_obj = btf__load_vmlinux_btf();
|
btf_obj = btf__load_vmlinux_btf();
|
||||||
|
|
||||||
|
/* *** DOES NOT WORK ***
|
||||||
|
*
|
||||||
|
* The struct btf object returned by btf__load_vmlinux_btf() doesn't
|
||||||
|
* have a file descriptor set we can use.
|
||||||
|
*/
|
||||||
fd = btf__fd(btf_obj);
|
fd = btf__fd(btf_obj);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
pr_err("WARN: BTF-obj miss FD(%d)\n", fd);
|
pr_err("WARN: BTF-obj miss FD(%d)\n", fd);
|
||||||
@@ -255,7 +259,7 @@ static const char *module_name = "tun";
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct btf *vmlinux_btf;
|
// struct btf *vmlinux_btf;
|
||||||
int opt, longindex = 0;
|
int opt, longindex = 0;
|
||||||
int module_btf_id;
|
int module_btf_id;
|
||||||
int module_btf_sz;
|
int module_btf_sz;
|
||||||
@@ -276,7 +280,7 @@ int main(int argc, char **argv)
|
|||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
vmlinux_btf = open_vmlinux_btf();
|
// vmlinux_btf = open_vmlinux_btf();
|
||||||
|
|
||||||
// err = walk_all_ids();
|
// err = walk_all_ids();
|
||||||
|
|
||||||
@@ -289,7 +293,7 @@ int main(int argc, char **argv)
|
|||||||
module_btf_id, module_name);
|
module_btf_id, module_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
btf__free(vmlinux_btf);
|
// btf__free(vmlinux_btf);
|
||||||
if (err)
|
if (err)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|||||||
Reference in New Issue
Block a user