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

aditya dogra dogra.aditya at gmail.com
Fri Dec 1 00:11:21 EST 2017


Thanks Mihai . We modifed the pogram and now its working .

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

On Thu, Nov 30, 2017 at 9:53 PM, Mihai Budiu <mbudiu at vmware.com> wrote:

> You don’t really need a conditional in an action; a table is nothing but a
> large switch statement which executes an action based on a key.
>
> So you can use node_type as a key and match on NO_OP_NODE.
>
>
>
> Mihai
>
>
>
> *From:* P4-dev [mailto:p4-dev-bounces at lists.p4.org] *On Behalf Of *aditya
> dogra
> *Sent:* Wednesday, November 29, 2017 9:04 PM
> *To:* p4-dev <p4-dev at lists.p4.org>
> *Subject:* [P4-dev] Exiting out of the ingress based on a condition(ACL
> rule)
>
>
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20171201/fc7e8081/attachment-0002.html>


More information about the P4-dev mailing list