Hello Tanja,
On 02/20/2017 09:53 AM, Tanja Ulmen via iovisor-dev wrote:
Hi,
I'm new to eBPF and bcc and I hope this is the right platform for my
question.
Welcome!
I have the following problem while working with a bpf program array map:
I have a C file that contains a program map like this:
BPF_TABLE("prog", int, int, prog_array, 2);
Later on it is called with
prog_array.call(ebpf_packet, 1);
The respective part of my python file looks like this:
b = BPF(src_file="./output.c")
prog = """
int hello(struct __sk_buff* ebpf_packet) {
bpf_trace_printk("Hello, World!\\n");
return 0;
}
"""
hw = BPF(text=prog)
hello_fn = hw.load_func("hello", BPF.SCHED_CLS)
prog_array = b["prog_array"]
prog_array[ctypes.c_int(1)] = ctypes.c_int(hello_fn.fd)
print prog_array.items()
The output of the last line is just an empty array [] and the
subprogram "hello" is not called when I run the program. There is no
error. I have also hash bpf tables where I can assign key and leaf
without any problems and these tables are accessed correctly during
the run.
Do you have any idea where my mistake could be?
Are you calling load_func() for the program in the .c file?
I modified one of the examples to add a tail call, you can see at [1].
Although print(prog_array.items()) shows an empty array, the second eBPF
program is called. I tried to print the prog array in some other
examples and I always get an empty one, I don't know why.
[1] https://gist.github.com/mvbpolito/6312896d2004efd189dff79e913df297
Regards,
Mauricio
Best regards,
Tanja
_______________________________________________
iovisor-dev mailing list
[email protected]
https://lists.iovisor.org/mailman/listinfo/iovisor-dev
_______________________________________________
iovisor-dev mailing list
[email protected]
https://lists.iovisor.org/mailman/listinfo/iovisor-dev