While developing this I found it useful to always have the log
output when dealing with bpftool. This is a quick hack to enable
it but we should add a '-v' option shortly.

Then add a set of good and bad loop examples to test with. These
are all very basic at the moment but will get better soon.

Signed-off-by: John Fastabend <john.fastab...@gmail.com>
---
 tools/lib/bpf/bpf.c    |    2 +-
 tools/lib/bpf/libbpf.c |    7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 9ddc89d..b1d2199 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -200,7 +200,7 @@ int bpf_load_program_xattr(const struct 
bpf_load_program_attr *load_attr,
        attr.license = ptr_to_u64(load_attr->license);
        attr.log_buf = ptr_to_u64(NULL);
        attr.log_size = 0;
-       attr.log_level = 0;
+       attr.log_level = 1;
        attr.kern_version = load_attr->kern_version;
        attr.prog_ifindex = load_attr->prog_ifindex;
        memcpy(attr.prog_name, load_attr->name,
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index b1a60ac..34ff173 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1304,6 +1304,13 @@ static int bpf_object__collect_reloc(struct bpf_object 
*obj)
        if (ret >= 0) {
                *pfd = ret;
                ret = 0;
+
+               pr_warning("load bpf program succesful\n");
+               if (log_buf && log_buf[0] != '\0') {
+                       pr_warning("-- BEGIN DUMP LOG ---\n");
+                       pr_warning("\n%s\n", log_buf);
+                       pr_warning("-- END LOG --\n");
+               }
                goto out;
        }
 

Reply via email to