No, really the only thing you are allowed to do from bpf on a prog
array is call() and delete(). It is a one-way street.

Unfortunately you will have to keep track of which programs are in
which slots from the userspace side entirely.

On Fri, Mar 3, 2017 at 12:52 AM, Tanja Ulmen via iovisor-dev
<[email protected]> wrote:
> Is there another way to look into a program array? I'm currently using the
> program below:
>
> prog = """
>   BPF_TABLE("prog", int, int, prog_array, 5);
>
>   int hello(struct __sk_buff* ebpf_packet) {
>     int key = 1;
>     int *value;
>
>     bpf_trace_printk("Hello, World!\\n");
>
>     value = bpf_map_lookup_elem(&prog_array, &key);
>
>     prog_array.call(ebpf_packet, 1);
>     bpf_trace_printk("Tail-call not executed!\\n");
>     return 1;
>   }
>   """
>
> And I get the following error:
>
> bpf: Invalid argument
> 0: (bf) r6 = r1
> 1: (b7) r1 = 1
> 2: (63) *(u32 *)(r10 -4) = r1
> 3: (b7) r1 = 2593
> 4: (6b) *(u16 *)(r10 -12) = r1
> 5: (b7) r1 = 1684828783
> 6: (63) *(u32 *)(r10 -16) = r1
> 7: (18) r1 = 0x6c6c6548
> 9: (7b) *(u64 *)(r10 -24) = r1
> 10: (b7) r7 = 0
> 11: (73) *(u8 *)(r10 -10) = r7
> 12: (bf) r1 = r10
> 13: (07) r1 += -24
> 14: (b7) r2 = 15
> 15: (85) call 6
> 16: (bf) r2 = r10
> 17: (07) r2 += -4
> 18: (08) r0 = 0x0
> invalid BPF_LD_IMM insn
>
> Regards,
> Tanja
>
>
> Am 02.03.2017 um 14:35 schrieb Mauricio Vasquez:
>
>
>
> On 02/28/2017 06:01 AM, Tanja Ulmen wrote:
>
> Hi Mauricio,
>
> thank you for the example program, it works and I get both outputs.
>
> Are you calling load_func() for the program in the .c file?
>
> Yes I'm calling load_func() for the program. My program is similar to the
> endToEndTest.py of the P4 frontend
> (https://github.com/iovisor/bcc/blob/0c8c179fc1283600887efa46fe428022efc4151b/src/cc/frontends/p4/test/endToEndTest.py).
> Thus a small virtual network where each node has its own namespace.
>
> I think the problem of my program is that the program with the tail-call is
> executed in a namespace, but I don't know exactly why this is a problem.  I
> will keep on looking for the problem, but maybe you have some further ideas?
>
> Unfortunately I don't have any idea for it.
>
> As a comment, it is normal that "print prog_array.items()" prints [], the
> prog type array does not implement the lookup function.
>
> Regards,
> Mauricio
>
>
> Regards,
> Tanja
>
>
> Am 23.02.2017 um 20:24 schrieb Mauricio Vasquez:
>
> 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
>
_______________________________________________
iovisor-dev mailing list
[email protected]
https://lists.iovisor.org/mailman/listinfo/iovisor-dev

Reply via email to