[P4-dev] Include a variable field in a field_list?
antonin at barefootnetworks.com
Thu Jun 30 13:24:37 EDT 2016
I don't remember the spec banning variable length fields from field lists.
However, this is not how I would compute the UDP checksum. The "payload"
keyword is here for this specific purpose. Quoting the P4-14 spec here:
*The identifier payload indicates that the contents of the packet following
the header of the previously mentioned field is included in the field list.
This is to support special cases like the calculation of an Ethernet CRC
across the entire packet or the TCP checksum.*
If you try to use a variable-length field to store a packet payload, then
it may mean that you want the parser to extract the whole payload into a
field container (that is what bmv2 is doing anyway). This is useless if you
just need it to recompute / verify a checksum. I believe that in P4-16, you
have to provide a maximum bit length for variable-length fields, so that a
hardware target can allocate the necessary resources. So you can see why
using it for the payload does not make much sense.
Variable-length fields can be used to extract IP options as a block (see
P4-14 spec for an example). If you need to parse past the IP header, but
are not interested in doing anything with the IP options save for
preserving them in the outgoing packet, then a variable-length field is
what you need. However, if you need to extract individual options to use
them in the match-action pipeline, a variable-length field may not be
On Thu, Jun 30, 2016 at 8:34 AM, Huynhtu Dang <huynh.tu.dang at usi.ch> wrote:
> Dear all,
> Can a variable field is included in a field_list to compute a checksum?
> For example, UDP checksum is computed using UDP header and payload.
> However, the payload is a variable field. If it doesn’t, then, in which
> cases variable fields are useful?
> Tu Dang
> P4-dev mailing list
> P4-dev at lists.p4.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the P4-dev