[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xdp-newbies
Subject:    Re: Parsing TCP Header Options In XDP/BPF
From:       Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= <toke () redhat ! com>
Date:       2021-09-20 20:59:39
Message-ID: 87mto73qv8.fsf () toke ! dk
[Download RAW message or body]

Christian Deacon <gamemann@gflclan.com> 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@gflclan.com> 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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic