[P4-dev] Slight Problem with a Boolean Expression

Antonin Bas antonin at barefootnetworks.com
Thu Aug 13 15:04:49 EDT 2015


Hi,

I don't think the spec allows this. Could you share the page number with me?

Our compiler only allows applying a given table once.
So doing this:
apply(table1);
apply(table2);
apply(table1);
in a control flow is forbidden by the p4lang frontend (for now).

Some cases which should be ok are handled incorrectly by the compiler. For
example:
if(*some_condition*) {
  apply(table1);
  apply(table2);
}
else {
  apply(table1);
  apply(table3);
}

However most of the times, these cases can easily be rewritten in a form
that will be accepted by the compiler. In our example:
apply(table1);
if(*some_condition*) {
  apply(table2);
}
else {
  apply(table3);
}

On Thu, Aug 13, 2015 at 11:59 AM, Peter Newman <petenewm at cisco.com> wrote:

> Antonin,
>
> Thanks. I guess it is time to update my tool set.
>
> At the risk of sharing my ignorance with the entire community I also get
> the following compiler error:
>
> ERROR: Table 'layer2_forwarding' is invoked multiple times.
>
> The spec specifically states that I can invoke the same table multiple
> times as long as it is the same identical table. Is this another old
> compiler version problem? I'm invoking the compiler with the command:
> 'p4-validate'.
>
> --Peter
>
>
> On 8/13/2015 11:43 AM, Antonin Bas wrote:
>
> Hi Peter,
>
> Thanks for reporting this bug, I just fixed it (some missing rule in the
> parser code). The relevant commit is this one:
> https://github.com/p4lang/p4-hlir/commit/3d6b69511b32daebdc5eb980dec8b56fbefea455
>
> Feel free to just pick up this commit, although I recommend pulling the
> latest code if you are using an old version. We have made a bunch of fixes
> since last April.
>
> Also, don't hesitate to report bugs like this directly in Github.
>
> Thanks again,
>
> Antonin
>
> On Thu, Aug 13, 2015 at 11:20 AM, Peter Newman <petenewm at cisco.com> wrote:
>
>> Antonin,
>>
>> I'm trying to express a test for a multicast IPv4 address:
>>
>> if ((ipv4.dstAddr & 0xf0000000) == 0xe0000000) {
>>     /* do something with multicast pkt */
>> }
>>
>> I receive the following error from the compiler:
>>
>> parse error in file xxx.p4 at line 144 : Syntax error while parsing at
>> token ) (RPAREN)
>> parse error in file xxx.p4 at line 144 : Invalid boolean expression
>> 2 errors during parsing
>>
>> If I remove the parenthesis the compiler accepts the expression but the
>> operator precedence would be incorrect.
>>
>> I am using the original public version of the compiler (so my apologies
>> if this has already been fixed).
>>
>> According to the BNF in the spec (version 1.0.2) I believe this to be a
>> valid expression (other than the requirement to use \& for bitwise AND
>> which I take to be a typo).
>>
>> --Peter
>>
>>
>
>
> --
> Antonin
>
>
>


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


More information about the P4-dev mailing list