Re: Parsing TCP Header Options In XDP/BPF

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

 



Christian Deacon <gamemann@xxxxxxxxxxx> writes:

> Hey and I apologize for the late reply!
>
>
> On 9/15/2021 11:19 PM, Rob Sherwood wrote:
>  > Definitely not an expert but no one has replied so I'll throw out my 
> guess :-)
>  >
>  > Check out https://lwn.net/Articles/794934/ for more info on 'bounded 
> loops', but my guess is that the verifier doesn't have enough context to 
> verify your loop is really bounded.
>  >
>  > One trick might be to convert your while loop to a for(;;) loop, 
> e.g., instead of :
>  >
>  > 
> https://github.com/gamemann/XDP-TCP-Header-Options/blob/master/src/xdp_prog.c#L81
>  > while ( optdata < 40) {... }
>  >
>  > you could try:
>  >
>  > for (optdata = 0; optdata < 40; optdata ++) { ... }
>  >
>  > I know from past attempts that just because it's obvious to humans 
> that there's not an infinite loop, it's not always obvious to the verifier.
>  >
>  > Hope that helps (and is correct!),
>  >
>  > - Rob
>  > .
>
> I did try a for loop before, but still ran into the same BPF verifier 
> error :( I tried adding checks to prevent an infinite loop along with 
> checks to make sure it doesn't go outside of ctx->data_end or below 
> ctx->data, but no change. Thank you!
>
> On 9/16/2021 5:32 AM, Toke Høiland-Jørgensen wrote:
>  > Christian Deacon <gamemann@xxxxxxxxxxx> writes:
>  >
>  >> Hi everyone,
>  >>
>  >>
>  >> I wasn't sure whether to submit this under XDP's mailing list or BPF's.
>  >> However, since it's an XDP program, I figured I'd start here. The issue
>  >> has to do with the BPF verifier, though.
>  >>
>  >>
>  >> I am trying to parse TCP header options within XDP/BPF. In my case, I
>  >> want to locate the 'timestamps' option and read/write to the sender and
>  >> receive timestamps (the option's data, which is eight bytes in total I
>  >> believe).
>  >
>  > We're doing just this in the 'pping' utility, see code here:
>  > 
> https://github.com/xdp-project/bpf-examples/blob/master/pping/pping_kern.c#L83
>  >
>  > -Toke
>
> This code works great for me so far! Thank you!

Awesome! You're welcome :)

-Toke





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

  Powered by Linux