[P4-dev] String concatenation / Header stack as table key
Jeferson Santiago da Silva
eng.jefersonsantiago at gmail.com
Sat May 13 19:53:40 EDT 2017
It seems what you are trying to do is somewhat like deep packet inspection.
P4 semantics does not allow packet payload manipulation. However, if you
are using the BMv2 as a target you can implement it as extern method to it.
The support for arbitrary externs was pushed this week. Your result string
can then be assigned to a metadata for further processing.
Date: Tue, 14 Feb 2017 17:27:45 +0000
> From: Rui Miguel <rmiguel at lasige.di.fc.ul.pt>
> To: "p4-dev lists.p4.org" <p4-dev at lists.p4.org>
> Subject: [P4-dev] String concatenation / Header stack as table key
> Message-ID: <ebb04506913e6c684a0b1bfa186280a4 at webplazza.di.fc.ul.pt>
> Content-Type: text/plain; charset="utf-8"
> I am working on a P4 program and I've come across the need to concatenate
> a string (preferably at the parsing phase, if that makes any sense). I know
> of the operator ++, but the specifics make it a bit more complicated.
> The packet I'm receiving contains the raw string with various metadata
> segments in-between. My objective is to extract the good/data pieces out of
> it and concatenate them. The number of segments (including metadata ones)
> as well as their respective lengths (and therefore the length of the entire
> raw string) are all unbounded.
> The whole string will serve as a table key. Initially, I was saving each
> good segment in a header stack. Would a table accept a headerstack
> attribute (with no fixed number of elements) of varbits as a key? How would
> longest prefix match (lpm) and ternary matches work in that case?
> As an alternative, I thought of concatenating the good segments, but this
> seems impossible.
> ? Instead of pushing into a headerstack, I could accumulate into a varbit,
> but using the assignment (=) operator would set the dynamic width of the
> field, thus preventing further accumulations (and ++ seems to require bit
> ? Therefore, I have to extract the whole raw string (whose size is
> variable, but a previous field in the packet structure indicates its total
> length) with the dual-argument extract(). However, if I do this, I see no
> way of further processing the raw string.
Jeferson Santiago da Silva, M.Sc.
Ph.D. Candidate in Computer Engineering
Hardware and Programmable Logic Design Engineer
Phone: +1 (514) 581-1004
Montreal/QC - Canada
Lattes CV: http://lattes.cnpq.br/9568850258686622
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the P4-dev