From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Christian Deacon <gamemann@gflclan.com>, xdp-newbies@vger.kernel.org
Subject: Re: Parsing TCP Header Options In XDP/BPF
Date: Mon, 20 Sep 2021 22:59:39 +0200 [thread overview]
Message-ID: <87mto73qv8.fsf@toke.dk> (raw)
In-Reply-To: <dc08f117-50e7-bbe3-44e7-f6adb95eb011@gflclan.com>
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 parent reply other threads:[~2021-09-20 21:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-15 17:30 Parsing TCP Header Options In XDP/BPF Christian Deacon
2021-09-16 4:21 ` Rob Sherwood
2021-09-16 5:09 ` Martin KaFai Lau
2021-09-16 10:32 ` Toke Høiland-Jørgensen
2021-09-20 20:41 ` Christian Deacon
2021-09-20 20:59 ` Toke Høiland-Jørgensen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mto73qv8.fsf@toke.dk \
--to=toke@redhat.com \
--cc=gamemann@gflclan.com \
--cc=xdp-newbies@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).