[P4-dev] Variable-length header problem

yunchen chang y2924uki at gmail.com
Thu May 4 04:07:15 EDT 2017


Hello Antonin:

Thank you for telling me the information. It works fine now.

I have another question.
I will use ONOS to be my controller after I finished my P4 program.
But in the link(https://github.com/ccascone/onos-p4-dev),
the bmv2 that ONOS used is "onos-bmv2"(
https://github.com/opennetworkinglab/onos-bmv2/tree/master).
Will onos-bmv2 solve the bug in the future like bmv2(
https://github.com/p4lang/behavioral-model)?
(like this change, variable-length header)
And will there be something wrong if I update p4c(
https://github.com/p4lang/p4c-bm/tree/master) in ONOS?

Thanks.

Best regard,
Abbie

On Thu, May 4, 2017 at 5:07 AM, Antonin Bas <antonin at barefootnetworks.com>
wrote:

> Hi Abbie,
>
> It sounds like you are using an older version of bmv2. This sounds like an
> issue I fixed with the following pull request: https://github.com/
> p4lang/behavioral-model/pull/330
> Would you mind updating your bmv2 to the *latest version* (and by latest
> I mean the very latest, as I just pushed an additional fix for
> variable-length fields today) and trying again? I just tried TCP parsing
> with / without options and it seems to be working fine now.
>
> Thanks,
>
> Antonin
>
> On Wed, May 3, 2017 at 3:46 AM, yunchen chang <y2924uki at gmail.com> wrote:
>
>> Hello everyone :
>>
>> I have a question in parse tcp header.
>> Because tcp header sometimes have option data, the length is variable.
>> Therefore I parse tcp header like below :
>>
>> parser parse_tcp {
>>     extract(tcp_header);
>>     set_metadata( intrinsic_metadata.tcp_hdr_len, tcp_header.dataOffset
>> * 4 );
>>     return ingress ;
>> }
>>
>> header_type tcp_header_t {
>>     fields {
>>         srcPort : 16;
>>         dstPort : 16;
>>         seqNo : 32;
>>         ackNo : 32;
>>         dataOffset : 4;
>>         res : 3;
>>         ecn : 3;
>>         ctrl : 6;
>>         window : 16;
>>         checksum : 16;
>>         urgentPtr : 16;
>>         options: *;
>>     }
>>
>>     length : 4 * dataOffset ;
>>     max_length : 512;
>> }
>>
>> But sometimes it will fail.
>> I changed the bm_sim/parser.cpp code(https://github.com/p4lang
>> /behavioral-model/blob/master/src/bm_sim/parser.cpp ,235~262) to show
>> some information that I need.
>> ( document I attached )
>>
>> The log file is below :
>>
>> [18:31:09.106] [bmv2] [D] [thread 97342] [30.0] [cxt 0] Extracting header
>> 'tcp_header'
>> [18:31:09.106] [bmv2] [D] [thread 97342] check :
>> [18:31:09.106] [bmv2] [D] [thread 97342] 74
>> [18:31:09.106] [bmv2] [D] [thread 97342] 34
>> [18:31:09.106] [bmv2] [D] [thread 97342] 32 // the header size is
>> [18:31:09.106] [bmv2] [D] [thread 97342] after check the header size is
>> [18:31:09.106] [bmv2] [D] [thread 97342] 32
>> [18:31:09.106] [bmv2] [D] [thread 97342] after extract the header size is
>> [18:31:09.106] [bmv2] [D] [thread 97342] 40
>> [18:31:09.106] [bmv2] [D] [thread 97342] bytes_parsed add done the header
>> size is
>> [18:31:09.106] [bmv2] [D] [thread 97342] 40
>> [18:31:09.106] [bmv2] [D] [thread 97342] [30.0] [cxt 0] Parser set:
>> setting field 'intrinsic_metadata.tcp_hdr_len' from expression, new
>> value is 40
>>
>> ###### works fine, but why the size will change ( the header size is 40
>> bytes )
>>
>> [18:31:09.108] [bmv2] [D] [thread 97342] [31.0] [cxt 0] Extracting header
>> 'tcp_header'
>> [18:31:09.108] [bmv2] [D] [thread 97342] check :
>> [18:31:09.108] [bmv2] [D] [thread 97342] 54
>> [18:31:09.108] [bmv2] [D] [thread 97342] 34
>> [18:31:09.108] [bmv2] [D] [thread 97342] 40 // the header size
>> [18:31:09.108] [bmv2] [E] [thread 97342] [31.0] [cxt 0] Exception while
>> parsing: PacketTooShort
>>
>> ###### works fail, and the header size is 20 bytes not 40 bytes
>>
>> I also sent the pcap file.
>>
>> Thanks.
>>
>> Best regards,
>> Abbie
>>
>>
>> _______________________________________________
>> P4-dev mailing list
>> P4-dev at lists.p4.org
>> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>>
>
>
>
> --
> Antonin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20170504/6859fdee/attachment-0002.html>


More information about the P4-dev mailing list