[P4-dev] parsing variable-length fields in HTTP

Aldo Febro af12abw at gmail.com
Sat Jul 15 16:09:13 EDT 2017

Thank you, Antonin and Vladimir, for your insightful reply. It helps!

I was looking at the approach used in TLV parsing example where it has
variable-length IP options and noticed its similarity to HTTP headers. But
I also noticed the difference i.e. this example consists of fixed-length
options and one variable-length option (timestamp), which makes it
processable by p4.

In TLV_parsing example, I noticed that it uses "valid" match type (1=valid
or 0=invalid). My question is, how does the action "ipv4_option_timestamp"
determine validity? Do you have other examples?

Thank you


reads {
ipv4_option_security : valid;
ipv4_option_timestamp : valid;

On Fri, Jul 14, 2017 at 6:48 PM, Vladimir Gurevich <
vladimir.gurevich at barefootnetworks.com> wrote:

> Hello Aldo,
> To add to Antonin's excellent reply, I'd also have to notice that HTTP
> employs TCP and thus regular expression matching has to be done across
> multiple packets, since you can never know how the actual data stream will
> be segmented.
> Although, again, nothing in P4 language prevents a certain target to
> provide such a capability, I am not aware of any such targets in existence.
> Implementing this on BMv2 will be a non-trivial exercise on its own, but
> doing it in high-speed hardware will be a big, dedicated project at best
> and not-quite possible at worst, given the currently possible clock rates.
> Basically, a regular expression matching engine can reasonably advance 1
> byte per clock, so at modern clock speeds you'll be lucky if you can
> process 10G stream at line rate. 40G will probably be out-of-reach.
> Usually, such matching is not done "inline" as to not stall the processing.
> Generally speaking, what you want to do is not a typical application for
> P4.
> Happy hacking,
> Vladimir
> On Fri, Jul 14, 2017 at 1:23 PM, Aldo Febro <af12abw at gmail.com> wrote:
>> Hi All,
>> I wonder if P4 is capable of parsing HTTP protocol with its
>> variable-length fields?
>>  e.g.
>> Host: www.p4.org\r\n
>> User-Agent: Mozilla/5.0\r\n
>> Accept: text/html,image/apng\r\n
>> etc. where each variable-length field is terminated with "\r\n" character
>> (CRLF).
>> As far as I know, P4 can accommodate only one variable-length field by
>> using "*", which value will be derived by calculating length and
>> max_length. But with HTTP, most fields are of variable length.
>> What I'd like to be able to do is to parse each field individually i.e.
>> doing a match based on "Hosts:, "User-Agent:", etc. Is this doable yet?
>> Many thanks!
>> Aldo
>> _______________________________________________
>> P4-dev mailing list
>> P4-dev at lists.p4.org
>> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
> --
> *Vladimir Gurevich*
> *Barefoot Networks*
> *Technical Lead, Customer Engineering*
> Email: vag at barefootnetworks.com
> Phone: (408) 833-4505
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20170715/c59eb8d2/attachment-0002.html>

More information about the P4-dev mailing list