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

Vladimir Gurevich vladimir.gurevich at barefootnetworks.com
Fri Jul 14 21:48:08 EDT 2017


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20170714/605398f4/attachment-0002.html>


More information about the P4-dev mailing list