[P4-dev] Exiting out of the ingress based on a condition(ACL rule)

aditya dogra dogra.aditya at gmail.com
Fri Dec 1 00:10:39 EST 2017


Thanks a lot Andy for that insight . We have modified our program to assign
the node_type values into the ingress meta data and now its working .

Regards,
Aditya Dogra
"When the going gets tough, the tough get going"

On Fri, Dec 1, 2017 at 1:03 AM, Andy Fingerhut <andy.fingerhut at gmail.com>
wrote:

> Sorry for the mistake.  I meant to say "if statements may have little or
> no support _for being used inside of an action definition_".
>
> Andy
>
> On Thu, Nov 30, 2017 at 11:32 AM, Andy Fingerhut <andy.fingerhut at gmail.com
> > wrote:
>
>> In the open source compiler, and perhaps some other P4_16
>> implementations, if statements may have little or no support (there is some
>> support for them in the open source compiler, I believe only if it can turn
>> them into equialent assignment statements using the ternary operator (cond)
>> ? (true_value) : (false_value)).
>>
>> A general way to handle doing conditional things in actions is not to do
>> them in the actions, but assign values to metadata or header fields inside
>> of actions, and then soon after applying the table in the control, use 'if'
>> statements there on those metadata or header fields.
>>
>> Andy
>>
>> On Wed, Nov 29, 2017 at 9:04 PM, aditya dogra <dogra.aditya at gmail.com>
>> wrote:
>>
>>> Hi ,
>>>      Is there a way in the p4-16 program we can jump out of the ingress
>>> block based on an ACL or a table entry ?
>>>
>>> We have a table which specifies whether we need to encap the packet or
>>> not . If the table specifies that encap rule is specified , we should encap
>>> the packet in new format , else we should exit out of the ingress block and
>>> let it egress normally (we dont want packet to get drop). We tried "exit"
>>> statement , however "exit" in condition gives an error . *Is there any
>>> specific way we need to do exit or jump from the control block ? *
>>>
>>>
>>> p4c-bm2-ss --p4v 16 "insert_new_hdr.p4" -o "insert_new_hdr.p4.json"
>>> *insert_new_hdr.p4(377): error: exit: Conditional execution in actions
>>> is not supported on this target*
>>>           exit;
>>>           ^^^^
>>>
>>> Table entry is : *table_set_default node_source node_sourcing 3*
>>>
>>> *Pseudocode *
>>>
>>> const bit<8>  NO_OP_NODE = 0x03;
>>>
>>> ingress block {
>>>
>>>
>>>     action node_sourcing(nodeType_t node_type) {
>>>
>>>        if (NO_OP_NODE == node_type){
>>>           /* COME OUT OF THE INGRESS .. DONT DO ANYTHING AT ALL */
>>>           exit;
>>>        }
>>>
>>>     }
>>>
>>>
>>>         table node_source {
>>>             actions        = { node_sourcing; NoAction; }
>>>             default_action =  NoAction();
>>>     }
>>>
>>>
>>>         apply {
>>>             if (condition1) {
>>>
>>>
>>>                 node_source.apply();   ==> If the ACL ot table entry
>>> doesnt match , we should be to exit out of the ingress block and continue
>>> with the egress block .
>>>
>>>
>>>                 if (condition2)
>>>                 {
>>>                      add_some_extra_header();
>>>                      new_hdr.apply();
>>>                 } else if (condition3)
>>>
>>>                 {
>>>                     if(new_condition)
>>>                     {
>>>                        add_new_hdr2_option();
>>>                     }
>>>                     new_hdr.apply();
>>>                 }
>>>
>>>             }
>>>         }
>>>     }
>>>
>>>
>>> }
>>>
>>>
>>>
>>> Regards,
>>> Aditya Dogra
>>>
>>> _______________________________________________
>>> P4-dev mailing list
>>> P4-dev at lists.p4.org
>>> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20171201/b3496b6f/attachment-0002.html>


More information about the P4-dev mailing list