Re: Fighting BPF verifier to reach end-of-packet with XDP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/6/20 11:08 AM, Jesper Dangaard Brouer wrote:
On Fri, 1 May 2020 17:41:32 +0200
Jesper Dangaard Brouer <brouer@xxxxxxxxxx> wrote:

Hi Daniel,

One use-case for tail grow patchset, is to add a kernel timestamp at
XDP time in the extended tailroom of packet and return XDP_PASS to let
packet travel were it needs to go, and then via tcpdump we can extract
this timestamp. (E.g. this could improve on Ilias TSN measurements[2]).

I have implemented it here[3]. It works, but it is really a hassle to
convince the BPF verifier, that my program was safe.  I use the
IP-headers total length to find the end-of-packet.

I moved the code example here experiment01-tailgrow[4]:
  [4] https://github.com/xdp-project/xdp-tutorial/blob/master/experiment01-tailgrow/xdp_prog_kern.c

People can follow the changes via PR# [123].
  [123] https://github.com/xdp-project/xdp-tutorial/pull/123

Is there an easier BPF way to move a data pointer to data_end?

I've also added some "fail" examples[5]:
  [5] https://github.com/xdp-project/xdp-tutorial/tree/master/experiment01-tailgrow

That I will appreciate someone to review my explaining comments, on why
verifier chooses to fail these programs... as they might be wrong.
Any suggestion on how I could extend the kernel (or verifier) to
provide easier access to the tailroom I grow?

Is it possible to use the cls_bpf older style load_byte() helpers?

In cls_bpf we use the tailroom grow for slow-path icmp [0], which may be the
primary use-case from my PoV for the tailroom grow. We haven't had a case where
we need it for crafting custom DNS replies though (it looks like you have one in
XDP (?), so may be good to add a sample code w/ your XDP series on this).

The issue from your fail1 example should very likely be that the offset in your
case is unbounded so verifier cannot do anything with this information. You would
need to make the offset bounded, add it to data and then open the range in the
data/data_end test with the constant you're accessing later, see my comment. I
haven't run your example, but that is what I'd probably try first.

Thanks,
Daniel

  [0] https://github.com/cilium/cilium/blob/master/bpf/lib/icmp6.h#L209



[Index of Archives]     [Linux Networking Development]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite Campsites]

  Powered by Linux