netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fejes Ferenc <fejes@inf.elte.hu>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Error when loading BPF_CGROUP_INET_EGRESS program with bpftool
Date: Mon, 12 Aug 2019 08:57:46 +0000	[thread overview]
Message-ID: <CAAej5NbkQDpDXEtsROmLmNidSP8qN3VRE56s3z91zHw9XjtNZA@mail.gmail.com> (raw)

Greetings!

I found a strange error when I tried to load a BPF_CGROUP_INET_EGRESS
prog with bpftool. Loading the same program from C code with
bpf_prog_load_xattr works without problem.

The error message I got:
bpftool prog loadall hbm_kern.o /sys/fs/bpf/hbm type cgroup/skb
libbpf: load bpf program failed: Invalid argument
libbpf: -- BEGIN DUMP LOG ---
libbpf:
; return ALLOW_PKT | REDUCE_CW;
0: (b7) r0 = 3
1: (95) exit
At program exit the register R0 has value (0x3; 0x0) should have been
in (0x0; 0x1)
processed 2 insns (limit 1000000) max_states_per_insn 0 total_states 0
peak_states 0 mark_read 0

libbpf: -- END LOG --
libbpf: failed to load program 'cgroup_skb/egress'
libbpf: failed to load object 'hbm_kern.o'
Error: failed to load object file


My environment: 5.3-rc3 / net-next master (both producing the error).
Libbpf and bpftool installed from the kernel source (cleaned and
reinstalled when I tried a new kernel). I compiled the program with
Clang 8, on Ubuntu 19.10 server image, the source:

#include <linux/bpf.h>
#include "bpf_helpers.h"

#define DROP_PKT        0
#define ALLOW_PKT       1
#define REDUCE_CW       2

SEC("cgroup_skb/egress")
int hbm(struct __sk_buff *skb)
{
        return ALLOW_PKT | REDUCE_CW;
}
char _license[] SEC("license") = "GPL";


I also tried to trace down the bug with gdb. It seems like the
section_names array in libbpf.c filled with garbage, especially the
expected_attach_type fields (in my case, this contains
BPF_CGROUP_INET_INGRESS instead of BPF_CGROUP_INET_EGRESS).

Thanks!

             reply	other threads:[~2019-08-12  8:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-12  8:57 Fejes Ferenc [this message]
2019-08-12 18:27 ` Error when loading BPF_CGROUP_INET_EGRESS program with bpftool Andrii Nakryiko
2019-08-12 20:48   ` Fejes Ferenc
2019-08-13 21:18     ` Andrii Nakryiko
2019-10-19 15:10       ` Fejes Ferenc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAej5NbkQDpDXEtsROmLmNidSP8qN3VRE56s3z91zHw9XjtNZA@mail.gmail.com \
    --to=fejes@inf.elte.hu \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).