[P4-dev] Sending metadata to the controller

Andy Fingerhut andy.fingerhut at gmail.com
Tue Feb 12 13:38:52 EST 2019


If you use clone3 in ingress, to perform an ingress-to-egress clone, and
the original packet finishes ingress processing with normal unicast
handling, i.e. you assign a value to the egress_spec field in
standard_metadata of the output port, then:

+ the original non-clone packet will being egress processing with
standard_metadata.instance_type equal to NORMAL (0)
+ the cloned packet will do its own independent egress processing from the
original non-cloned packet, and will begin egress processing with
standard_metadata.instance_type equal to INGRESS_CLONE (1).

There is a similar value EGRESS_CLONE (2) that is the value of
standard_metadata.instance_type for egress-to-egress cloned packets that
are created via a clone3 operation invoked during egress processing of the
original packet.

Look for instance_type mentions on this page of documentation for
simple_switch:
https://github.com/p4lang/behavioral-model/blob/master/docs/simple_switch.md
(included in the behavioral-model repository, if you have a local copy you
want to examine instead)

It links to this snippet of code, which you can copy into your own P4_16 +
v1model programs if you want to use the names rather than the numeric
values for instance_type:
https://github.com/p4lang/p4c/blob/master/testdata/p4_14_samples/switch_20160512/includes/intrinsic.p4#L62-L68

Nate mentioned the demo P4_16 program I have written that exercises these
operations all in one test program:
https://github.com/jafingerhut/p4-guide/tree/master/v1model-special-ops

It contains the "caveat emptor" warning about doing clone3 operations that
preserve metadata.  There _are_ many common cases for preserving metadata
that do work with the latest p4c and simple_switch versions, and perhaps
even more that work with the June 2018 version of those tools that you may
be using in the demo.  If you do not need your own user-defined metadata
field values preserved with such cloned packets, you should not run into
any of those issues at all.

Andy

On Mon, Feb 11, 2019 at 6:43 PM <fhgdsfkjgirgtegosfgsjfhsgbvnsyfgasg at web.de>
wrote:

> Hi,
>
> I am using the code of the P4_16 runtime tutorial 2018-06-01 and now I
> want to send metadata of all processed packets from the P4 switch to the
> controller. It seems that I cannot create new packets at the switch, so I
> was thinking to clone existing packets and send the cloned packets to the
> controller. I have cloned the packets using clone3() but now I am stuck.
> Also I do not want the controller to reply with any additional packets when
> receiving metadata. If possible, I would put ethernet, ipv4 & udp header on
> the cloned packets while keeping the original header structure (ethernet,
> ipv4, tcp/udp, tunneling) for the original packets, but how can I
> distinguish cloned packets from original packets at the deparser stage? As
> far as I know, the metadata contains an instance_type to determine it, but
> metadata is not accessible anymore after the egress pipeline.
> If this was too fancy, what would be the best way to do it in P4 & P4
> runtime?
>
> Kind regards
> _______________________________________________
> 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/20190212/8d7bcc59/attachment.html>


More information about the P4-dev mailing list