[P4-dev] Minor Issues with the P4 Compiler

Antonin Bas antonin at barefootnetworks.com
Wed Jun 24 15:21:22 EDT 2015


Hi Peter,

Thanks for your email. Please see comments inline:

On Tue, Jun 23, 2015 at 11:53 AM, Peter Newman (petenewm) <
petenewm at cisco.com> wrote:

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

What kind of cycle do you have in your P4 program? This MPLS parser (
https://github.com/p4lang/p4factory/blob/master/targets/switch/p4src/includes/parser.p4#L147)
has a cycle (you can extract up to 3 MPLS headers) and is handled correctly
by the compiler. More generally, it is okay to have a cycle so long as you
are extracting to a tag stack. I can't think of a use case where this would
not be the case, which is why I would be interested in seeing your P4
program.


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

At which stage do you observe strings? The resolve_names function (
https://github.com/p4lang/p4-hlir/blob/master/p4_hlir/hlir/p4_expressions.py#L64)
should have been called at some point and take care of this.


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

Wasn't this be fixed by this commit:
https://github.com/p4lang/p4-hlir/commit/72f20169a25619e6cc318254b952886a26e25972
?


>
>
> Just thought I’d document these observations before I forget them.
>
> —Peter
>
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at p4.org
> Listinfo - http://mail.p4.org/mailman/listinfo/p4-dev_p4.org
> Archives - http://mail.p4.org/pipermail/p4-dev_p4.org/
>



-- 
Antonin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20150624/656cc820/attachment-0001.html>


More information about the P4-dev mailing list