[P4-dev] Include a variable field in a field_list?

Huynhtu Dang huynh.tu.dang at usi.ch
Thu Jun 30 15:56:50 EDT 2016


Thanks, Antonin.

Payload is what I wanted to include in the field_list. However, payload identifier disappears in P4-16. If we declare a variable field instead functioning as “payload” identifier, how does the offset change?

Best,
Tu Dang

On Jun 30, 2016, at 7:24 PM, Antonin Bas <antonin at barefootnetworks.com<mailto:antonin at barefootnetworks.com>> wrote:

Hi Tu,

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 appropriate.

Best,

Antonin

On Thu, Jun 30, 2016 at 8:34 AM, Huynhtu Dang <huynh.tu.dang at usi.ch<mailto: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?

Best,
Tu Dang
_______________________________________________
P4-dev mailing list
P4-dev at lists.p4.org<mailto:P4-dev at lists.p4.org>
http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org



--
Antonin



More information about the P4-dev mailing list