mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
Merge pull request #39 from chenhengqi/update-btf-example
Update btf example
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@ compile_commands.json
|
||||
*.ll
|
||||
*.o
|
||||
*.skel.h
|
||||
lib/libbpf-install/
|
||||
|
@@ -35,9 +35,9 @@ int print_all_levels(enum libbpf_print_level level,
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct btf *vmlinux_btf, *module_btf;
|
||||
struct btf *vmlinux_btf, *module_btf = NULL;
|
||||
int opt, longindex = 0;
|
||||
__s32 type_id;
|
||||
__s32 type_id;
|
||||
int err = 0;
|
||||
|
||||
/* Parse commands line args */
|
||||
@@ -46,7 +46,6 @@ int main(int argc, char **argv)
|
||||
switch (opt) {
|
||||
case 'd':
|
||||
libbpf_set_print(print_all_levels);
|
||||
// verifier_logs = true;
|
||||
break;
|
||||
default:
|
||||
pr_err("Unrecognized option '%s'\n", argv[optind - 1]);
|
||||
@@ -66,17 +65,25 @@ int main(int argc, char **argv)
|
||||
module_btf = btf__load_module_btf(module_name, vmlinux_btf);
|
||||
err = libbpf_get_error(module_btf);
|
||||
if (err) {
|
||||
pr_err("ERROR(%d): btf__load_module_btf() module_name:%s\n",
|
||||
pr_err("ERROR(%d): btf__load_module_btf() module_name: %s\n",
|
||||
err, module_name);
|
||||
goto out;
|
||||
}
|
||||
|
||||
type_id = btf__find_by_name(module_btf, symbol_name);
|
||||
type_id = btf__find_by_name(module_btf, symbol_name);
|
||||
if (type_id < 0) {
|
||||
err = type_id;
|
||||
pr_err("ERROR(%d): btf__find_by_name() symbol_name: %s\n",
|
||||
err, symbol_name);
|
||||
goto out;
|
||||
}
|
||||
|
||||
printf("Module:%s Symbol:%s have BTF id:%d\n",
|
||||
module_name, symbol_name, type_id);
|
||||
|
||||
out:
|
||||
btf__free(module_btf);
|
||||
btf__free(vmlinux_btf);
|
||||
if (err)
|
||||
return EXIT_FAILURE;
|
||||
return EXIT_SUCCESS;
|
||||
|
22
configure
vendored
22
configure
vendored
@@ -159,17 +159,17 @@ EOF
|
||||
|
||||
compile_err=$($CLANG -target bpf -c $TMPDIR/bpf_use_errno_test.c 2>&1)
|
||||
if [ "$?" -ne "0" ]; then
|
||||
echo "*** ERROR - Clang BPF-prog cannot include <errno.h>"
|
||||
echo " - Install missing userspace header file"
|
||||
echo ""
|
||||
echo "Compile error: $compile_err"
|
||||
echo ""
|
||||
echo " On Fedora install:"
|
||||
echo " dnf install glibc-devel.i686"
|
||||
echo " On Debian install:"
|
||||
echo " apt install libc6-dev-i386"
|
||||
echo ""
|
||||
exit 1
|
||||
echo "*** ERROR - Clang BPF-prog cannot include <errno.h>"
|
||||
echo " - Install missing userspace header file"
|
||||
echo ""
|
||||
echo "Compile error: $compile_err"
|
||||
echo ""
|
||||
echo " On Fedora install:"
|
||||
echo " dnf install glibc-devel.i686"
|
||||
echo " On Debian install:"
|
||||
echo " apt install libc6-dev-i386"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user