[P4-dev] Sending metadata to the controller

Kamila Součková kamila at ksp.sk
Tue Feb 12 04:26:59 EST 2019


I don't think digest is ideal for what the OP is asking for - cloning would
work better.

If you want to add another layer of Ethernet/IP/UDP encapsulation, you will
need to add it to your header stack, so that in the end it looks something
like Ethernet/IP/UDP/Ethernet/IP/..., the first 3 being you encapsulation
(not always present, ignored in the parser, and named differently, e.g.
encaps_eth, encaps_ip, encaps_udp), and the rest being the original packet.

Then you can use the instance type in the pipeline (not in the deparser) to
fill in the encapsulation only if this is a cloned packet. If it isn't,
don't touch the encapsulation and it will remain invalid.

Then in the deparser, you can unconditionally emit all the headers,
including the encaps_* ones: emit() will actually only output data if the
header is valid, so if you didn't fill in the encapsulation in the
pipeline, it will do nothing, which is exactly what you want.

Best,
Kamila

On Tue, 12 Feb 2019, 04:22 , <hemant at mnkcg.com> wrote:

> Thanks for the clarification, Nate.
>
>
>
> To help, here is a URL from Andy’s P4 Guide that also has several clone
> examples, etc.
>
>
>
> https://github.com/jafingerhut/p4-guide/tree/master/v1model-special-ops
>
>
>
> To find the digest related notes, use this:
>
>
>
> https://github.com/jafingerhut/p4-guide/search?q=digest&unscoped_q=digest
>
>
>
> Cheers,
>
>
>
> Hemant
>
>
>
> *From:* Nate Foster <jnfoster at cs.cornell.edu>
> *Sent:* Monday, February 11, 2019 10:13 PM
> *To:* hemant at mnkcg.com
> *Cc:* fhgdsfkjgirgtegosfgsjfhsgbvnsyfgasg at web.de; p4-dev <
> p4-dev at lists.p4.org>
> *Subject:* Re: [P4-dev] Sending metadata to the controller
>
>
>
> Hemant, I doubt PSA will be helpful here -- the original post mentioned
> using the P4_16 runtime tutorial from last June, which is based on V1Model.
>
>
>
> Instead, I would look at Andy Fingerhut's excellent P4 Guide
> https://github.com/jafingerhut/p4-guide/ which contains several V1Model
> examples that use digests.
>
>
>
> -N
>
>
>
> On Mon, Feb 11, 2019 at 10:02 PM <hemant at mnkcg.com> wrote:
>
> See if you can use the PSA Digest message:
> https://p4.org/p4-spec/docs/PSA-v1.1.0.html#sec-packet-digest
>
>
>
> It will help distinguish different messages.  I am not sure if the
> controller always replies on receiving a Digest message because then this
> solution won’t work for you.  Also, the PSA document says Digest is used to
> send messages from the data plane to the control plane.  I am not sure if
> the control plane can be a P4Runtime controller.
>
>
>
> If you have p4c downloaded, see this Digest related P4 test program.
>
>
>
> p4c/testdata/p4_16_samles/p4rt_digest_complex.p4
>
>
>
> Hemant
>
>
>
> *From:* P4-dev <p4-dev-bounces at lists.p4.org> *On Behalf Of *
> fhgdsfkjgirgtegosfgsjfhsgbvnsyfgasg at web.de
> *Sent:* Monday, February 11, 2019 9:42 PM
> *To:* p4-dev at lists.p4.org
> *Subject:* [P4-dev] Sending metadata to the controller
>
>
>
> 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
>
> _______________________________________________
> 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/5d4aee5b/attachment.html>


More information about the P4-dev mailing list