[P4-dev] applying the same table multiple times

cs.lev cs.lev at gmx.com
Fri Nov 23 11:08:36 EST 2018

Dear All,

I have run into a simple problem.
I have simple application that parses different header types, e.g.,
For specific TCP packets I want to some special forwarding, which
contains some conditions, i.e., as conditions cannot be defined in
actions, I need to implement my conditions in the Ingress control's
apply {} part.
Such condition would be a state of a bit, e.g., if SYN then forward, if
ACK then drop (for simplicity! of course this does not make sense :)).

On the other hand, to provide working communications, I need to handle
ICMP and ARP packets as well.

So, what I am doing is that I have a switch with 2 ports, and a
port_forward table, which forwards packets from port 0 to port 1 and
vice versa.
And in the Ingress control's apply part, I have conditions for the
types of the packets, but in essence I would like to apply port_forward
table mulitple times, as I need to pass ARP,ICMP and even the modified
TCP packets as well from one port to the other, however the following
code snippet does not work:
            else if(hdr.ipv4.isValid())
                if(hdr.ipv4.protocol == IP_PROTO_ICMP)
                if(hdr.ipv4.protocol == IP_PROTO_TCP &&
			//do the mumbojumbo with the packets (or this part could also
be done in a separate action)

compiler raises the following error:
Program is not supported by this target, because table
MyIngress.port_forward has multiple successors
  table port_forward

This means for me that one table can only be applied once, however not
just my stupid example would require to 'recirculate packets to already
visited table'. 

Is there any way to resolve my issue? Can I call apply a table several
times if I jump from ingress to egress back-and-forth (I don't know
whether this would even work for jumping back only once).

Or can I call somehow an action without applying a table (but of course
matching on the input port (for instance in my case) would be known)?

So far, as a workaround I created the same tables over and over with
different names (e.g., port_forward, arp_forward, icmp_forward) but
fundamentally with the same look (match-action table). At least the
actions can be reused in the tables, so they don't need to be redefined
in a similar way.


More information about the P4-dev mailing list