[P4-dev] Parsing TLV options for ICMPv6 ND (header stack?)

Antonin Bas antonin at barefootnetworks.com
Thu Jun 30 13:31:50 EDT 2016


Hi Baptiste,

What you are trying to do is not very easy in P4. I encourage you to look
at my TLV_parsing example on p4lang (
https://github.com/p4lang/tutorials/tree/master/examples/TLV_parsing),
which parse IPv4 options. In a nutshell, I use different header stacks, one
for each option type. The size of each stack has to be known at compile
time, which means you have to provide a upper bound on the number of
options for each type. When parsing, you extract to the correct stack based
on the option type.

Thanks,

Antonin

On Thu, Jun 30, 2016 at 8:55 AM, Baptiste Jonglez <
baptiste at bitsofnetworks.org> wrote:

> Hello,
>
> I haven't found a way to parse a stack of headers in P4, because the
> number of elements in the stack (i.e. the number of "extract" operations
> that needs to be run) is unknown at compile time.
>
> I was attempting to do this to parse ICMPv6 ND options, but maybe this is
> the wrong approach to this problem.
>
> Conceptually, ICMPv6 looks like this (on top of IPv6):
>
>     type: 8;
>     code: 8;
>     checksum: 16;
>
> Then, depending on the type, the format is different.  For NS (type 135),
> which is what I am interested to parse, the format is:
>
>     reserved: 32;
>     targetAddr: 128;
>     options: *;
>
> So far so good.  The difficult part is "options", which is a list of one
> or more options.  Each option is TLV-formatted, see
> https://tools.ietf.org/html/rfc4861#section-4.6 for details.
>
> I think the only way to parse options is to first look at the IPv6 packet
> length (to see if there actually are options), and then walk the option
> list using the "length" field of each TLV.  Now that I think about it, the
> "header stack" idea will not work here, because not all options have the
> same length.
>
> Is parsing this even possible in P4?  If so, what would be the best
> approach?
>
> Thanks,
> Baptiste
>
> PS: I also have trouble implementing the checksum, since it encompasses
> the whole ICMPv6 packet, but that will be for another email.
>
> _______________________________________________
> 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/20160630/0eb1eec2/attachment-0002.html>


More information about the P4-dev mailing list