[P4-dev] Minor Issues with the P4 Compiler

Peter Newman (petenewm) petenewm at cisco.com
Tue Jun 23 14:53:44 EDT 2015


I am working on a parser in P4. I noticed the following minor issues with the compiler:


Compiler crashes if you have a cycle in the parse graph. It enters an infinite recursion at line 448 in p4_tables.py:

xconds = exclusive_conditions.Solver(hlir)

You can prevent this behavior if you set the optimize flag to false in the call to build(). I didn’t look at what optimization it is trying to do but it doesn’t seem to affect my parser.

I did notice the comment a few lines later: "# I am being lazy, and this is all tentative anyway” so I guess this feature is still under active development. It might be better to check for a cycle before executing the optimization.


The HLIR spec defines a p4_expression to contain references to objects of type: None, int, p4_header_instance or p4_field. The compiler actually gives type str instead of p4_header_instance or p4_field. The string contains the name of the field.


In a variable length packet header the compiler checks the max_length field but interprets this field as being specified in bits whereas the HLIR spec defines it to be specified in bytes.


Just thought I’d document these observations before I forget them.

—Peter





More information about the P4-dev mailing list