[P4-dev] P4-dev Digest, Vol 23, Issue 39

Dekwan Perry dekwanperry at gmail.com
Thu Jul 20 18:06:59 EDT 2017


Hey robert, got any memes?

On Jul 20, 2017 12:39 PM, <p4-dev-request at lists.p4.org> wrote:

> Send P4-dev mailing list submissions to
>         p4-dev at lists.p4.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
> or, via email, send a message with subject or body 'help' to
>         p4-dev-request at lists.p4.org
>
> You can reach the person managing the list at
>         p4-dev-owner at lists.p4.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of P4-dev digest..."
>
>
> Today's Topics:
>
>    1. Re: VL field bitwidth needs to be a multiple of 8 (Mihai Budiu)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 20 Jul 2017 16:37:50 +0000
> From: Mihai Budiu <mbudiu at vmware.com>
> To: Antonin Bas <antonin at barefootnetworks.com>, Regis Martins
>         <regisftm at gmail.com>
> Cc: p4-dev <p4-dev at lists.p4.org>
> Subject: Re: [P4-dev] VL field bitwidth needs to be a multiple of 8
> Message-ID:
>         <CY4PR05MB287078884A11EC0F056B00E0ADA70 at CY4PR05MB2870.
> namprd05.prod.outlook.com>
>
> Content-Type: text/plain; charset="utf-8"
>
> I have filed issue https://github.com/p4lang/p4c/issues/783 to track this.
> Thank you for finding this bug.
>
> Mihai
>
> From: P4-dev [mailto:p4-dev-bounces at lists.p4.org] On Behalf Of Antonin Bas
> Sent: Wednesday, July 19, 2017 6:16 PM
> To: Regis Martins <regisftm at gmail.com>
> Cc: p4-dev <p4-dev at lists.p4.org>
> Subject: Re: [P4-dev] VL field bitwidth needs to be a multiple of 8
>
> That looks like another issue with the generated JSON. Each header has a
> $valid$ field added by the compiler which can be read to check if a header
> is valid. However, this is a read-only field. Here the JSON code tries to
> set that field to 1 to make the ipv4 header valid, but because the field is
> read-only, it has no effect. The ipv4 header is therefore not considered
> valid. The bmv2 implementation evaluates invalid fields as "00...0" in
> table lookups, which explains the logs that you are seeing (and also why
> the checksum verification is skipped).
>
> I suggest that you open an issue on p4lang/p4c describing this issue.
>
> I have yet another workaround for you but it requires you to modify the
> JSON file by hand :)
>
> Locate the following:
>             {
>               "parameters" : [
>                 {
>                   "type" : "field",
>                   "value" : ["ipv4", "$valid$"]
>                 },
>                 {
>                   "type" : "expression",
>                   "value" : {
>                     "type" : "expression",
>                     "value" : {
>                       "op" : "b2d",
>                       "left" : null,
>                       "right" : {
>                         "type" : "bool",
>                         "value" : true
>                       }
>                     }
>                   }
>                 }
>               ],
>               "op" : "set"
>             }
>
> And replace it with:
>             {
>               "parameters" : [
>                 {
>                   "op" : "add_header",
>                   "parameters" : [{"type" : "header", "value" : "ipv4"}]
>                 }
>               ],
>               "op" : "primitive"
>             }
>
> Assuming I didn't make a typo, it should work.
>
> On Wed, Jul 19, 2017 at 5:49 PM, Regis Martins <regisftm at gmail.com<mailto:
> regisftm at gmail.com>> wrote:
> ?Hello Antonin,
>
> I just tried that...
>
> Here is the output:
>
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Processing packet
> received on port 1
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser 'parser':
> start
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser state
> 'start' has no switch, going to default next state
> [21:31:05.731] [bmv2] [T] [thread 7478] [33.0] [cxt 0] Bytes parsed: 0
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Extracting header
> 'eth'
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser state
> 'parse_eth': key is 0800
> [21:31:05.731] [bmv2] [T] [thread 7478] [33.0] [cxt 0] Bytes parsed: 14
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Extracting header
> 'tmp_hdr'
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'scalars.tmp' from expression, new value is 0
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Extracting
> variable-sized header 'tmp_hdr_0'
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.$valid$' from expression, new value is 1
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.version' from field 'tmp_hdr.version' (4)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.ihl' from field 'tmp_hdr.ihl' (5)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.diffserv' from field 'tmp_hdr.diffserv' (0)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.totalLen' from field 'tmp_hdr.totalLen' (84)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.id<https://urldefense.proofpoint.com/v2/url?u=http-
> 3A__ipv4.id&d=DwMFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=
> tGW6TKXajnoXSyy1S1P4DHGPe8sj54GGvw-b21n7aWg&m=M-6VV9SQ37sS_
> xCvlvyTo7tomnuC4Q2Zw8-0chyZq0M&s=3ChNVeTtMEGtwHPXSauZ7TI5SRSU9N
> 6GqEi_7E_rBxY&e=>' from field 'tmp_hdr.id<https://
> urldefense.proofpoint.com/v2/url?u=http-3A__tmp-5Fhdr.id&d=DwMFaQ&c=
> uilaK90D4TOVoH58JNXRgQ&r=tGW6TKXajnoXSyy1S1P4DHGPe8sj54
> GGvw-b21n7aWg&m=M-6VV9SQ37sS_xCvlvyTo7tomnuC4Q2Zw8-0chyZq0M&s=
> KeJpqiN5UFdj4iBmYzVNTFokScJixwgIkXR3FRjmFG8&e=>' (58185)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.flags' from field 'tmp_hdr.flags' (2)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.fragOffset' from field 'tmp_hdr.fragOffset' (0)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.ttl' from field 'tmp_hdr.ttl' (64)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.protocol' from field 'tmp_hdr.protocol' (1)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.hdrChecksum' from field 'tmp_hdr.hdrChecksum' (16972)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.srcAddr' from field 'tmp_hdr.srcAddr' (167772170)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.dstAddr' from field 'tmp_hdr.dstAddr' (167772426)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser set: setting
> field 'ipv4.options_ipv4' from field 'tmp_hdr_0.options_ipv4' (0)
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser state
> 'parse_ipv4': key is 01
> [21:31:05.731] [bmv2] [T] [thread 7478] [33.0] [cxt 0] Bytes parsed: 34
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Extracting header
> 'icmp'
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser state
> 'parse_icmp' has no switch, going to default next state
> [21:31:05.731] [bmv2] [T] [thread 7478] [33.0] [cxt 0] Bytes parsed: 38
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Extracting header
> 'payld'
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser state
> 'parse_payld' has no switch, going to default next state
> [21:31:05.731] [bmv2] [T] [thread 7478] [33.0] [cxt 0] Bytes parsed: 46
> [21:31:05.731] [bmv2] [T] [thread 7478] [33.0] [cxt 0] Skipping checksum
> 'cksum' verification because target field invalid
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Parser 'parser': end
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Pipeline 'ingress':
> start
> [21:31:05.731] [bmv2] [T] [thread 7478] [33.0] [cxt 0]
> p4src/task_9.p4(201) Condition "and" is true
> [21:31:05.731] [bmv2] [T] [thread 7478] [33.0] [cxt 0] Applying table
> 'set_table'
> [21:31:05.731] [bmv2] [D] [thread 7478] [33.0] [cxt 0] Looking up key:
> * ipv4.srcAddr        : 00000000
>
>
> ?For some weird reason, set field is not working for ipv4.srcAddr... that
> should be * ipv4.srcAddr        : 0a00000a
>
> If I remove the options_ipv4 field and the length and max_length
> parameters it works fine...
>
> Any other advice?
>
> Thank you,
>
>
> Regis Martins
>
>
> On Wed, Jul 19, 2017 at 8:06 PM, Regis Martins <regisftm at gmail.com<mailto:
> regisftm at gmail.com>> wrote:
> Got it!
>
> Let me test it.
>
> Thanks again Antonin! You will have a note of thanks on my thesis! :)
>
> Regards,
>
> Regis Martins
>
>
> On Wed, Jul 19, 2017 at 7:59 PM, Antonin Bas <antonin at barefootnetworks.com
> <mailto:antonin at barefootnetworks.com>> wrote:
> Looks like a p4c-bm2-ss compiler bug to me. I opened a Github issue:
> https://github.com/p4lang/p4c/issues/781<https://urldefense.
> proofpoint.com/v2/url?u=https-3A__github.com_p4lang_p4c_
> issues_781&d=DwMFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=
> tGW6TKXajnoXSyy1S1P4DHGPe8sj54GGvw-b21n7aWg&m=M-6VV9SQ37sS_
> xCvlvyTo7tomnuC4Q2Zw8-0chyZq0M&s=0evFE8SI3aGxUtHpphHBrX5__
> Zpw5YjmE0Cn4KeeZNY&e=>
> Your P4 program is correct, but the generated bmv2 JSON is not. As a
> workaround (while waiting for the issue to be fixed), you may be able to
> replace (ihl << 2) with ((ihl << 2) - 20) * 8. This is no longer correct
> P4, but will leverage the p4c-bm2-ss bug to get your program running on
> bmv2.
>
> On Wed, Jul 19, 2017 at 3:18 PM, Regis Martins <regisftm at gmail.com<mailto:
> regisftm at gmail.com>> wrote:
> Hello people!
>
> I'm trying to create a variable length field on my ipv4 header, as
> following:
>
> ...
>
> header_type ipv4_t {
>     fields {
>         version     : 4;
>         ihl         : 4;
>         diffserv    : 8;
>         totalLen    : 16;
>         id          : 16;
>         flags       : 3;
>         fragOffset  : 13;
>         ttl         : 8;
>         protocol    : 8;
>         hdrChecksum : 16;
>         srcAddr     : 32;
>         dstAddr     : 32;
>         options_ipv4: *;
>     }
>     length          : (ihl << 2);
>     max_length      : 60;
> }
>
>
> ...
>
>
> The compilation works fine, however the fist packet_in (it is a ping),
> abends the bmv2 with the following message:
>
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Parser 'parser':
> start
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Parser state
> 'start' has no switch, going to default next state
> [19:05:52.601] [bmv2] [T] [thread 6991] [33.0] [cxt 0] Bytes parsed: 0
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Extracting header
> 'eth'
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Parser state
> 'parse_eth': key is 0800
> [19:05:52.601] [bmv2] [T] [thread 6991] [33.0] [cxt 0] Bytes parsed: 14
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Extracting header
> 'tmp_hdr'
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Parser set: setting
> field 'scalars.tmp' from expression, new value is 4
> [19:05:52.601] [bmv2] [D] [thread 6991] [33.0] [cxt 0] Extracting
> variable-sized header 'tmp_hdr_0'
> simple_switch: parser.cpp:288: virtual void bm::ParserOpExtractVL::operator()(bm::Packet*,
> const char*, size_t*) const: Assertion `nbits % 8 == 0 && "VL field
> bitwidth needs to be a multiple of 8"' failed.
>
> Any clue about what is happening?
>
> Please, let me know if there you need further information...
>
> Regards,
>
> Regis Martins
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org<mailto:P4-dev at lists.p4.org>
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org<h
> ttps://urldefense.proofpoint.com/v2/url?u=http-3A__lists.
> p4.org_mailman_listinfo_p4-2Ddev-5Flists.p4.org&d=DwMFaQ&
> c=uilaK90D4TOVoH58JNXRgQ&r=tGW6TKXajnoXSyy1S1P4DHGPe8sj54
> GGvw-b21n7aWg&m=M-6VV9SQ37sS_xCvlvyTo7tomnuC4Q2Zw8-0chyZq0M&s=
> uVZlDVFt40OG3AizkFe7PbVOK_EUilQsuL9z2UEYWtQ&e=>
>
>
>
> --
> Antonin
>
>
>
>
>
> --
> Antonin
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/
> attachments/20170720/04a35cc9/attachment.html>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at p4.org
> Listinfo - http://mail.p4.org/mailman/listinfo/p4-dev_p4.org
> Archives - http://mail.p4.org/pipermail/p4-dev_p4.org/
>
>
> ------------------------------
>
> End of P4-dev Digest, Vol 23, Issue 39
> **************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20170720/0046b5a7/attachment-0002.html>


More information about the P4-dev mailing list