Orange-OpenSource / p4rt-ovs

Programming runtime extensions for Open vSwitch with P4
Apache License 2.0
24 stars 9 forks source link

verifier: Program with ubpf_printf() is rejected by the BPF verifier #4

Open osinstom opened 4 years ago

osinstom commented 4 years ago

I'm trying to test programs with ubpf_printf(). However, verifier rejects them. I use mpls.c from exmaples/ as the reference program.

If I put ubpf_printf() before ubpf_packet_data() I'm getting the following message:

|bpf|WARN|Failed to load code: uninitialized register 0 at PC 2

If I put ubpf_printf() after ubpf_packet_data() I'm getting the following message:

|bpf|WARN|Failed to load code: invalid access to packet (0 + 8 > 0) at PC 4

The latter is quite strange for me, as ubpf_printf() does not impact the actual packet.

@pchaigno Would you be able to take a look at it?

pchaigno commented 4 years ago

I understand the second error, but not the first. In the second case, R0 is marked as UINIT by the call to printf. It is then used to access the packet, so the verifier complains. I need to check what's the correct behaviour there.

For the first case, does your printf have multiple arguments? I don't understand why R0 is accessed... I will try to find some time to run tests.