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

Baptiste Jonglez baptiste at bitsofnetworks.org
Thu Jun 30 11:55:07 EDT 2016


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?


PS: I also have trouble implementing the checksum, since it encompasses
the whole ICMPv6 packet, but that will be for another email.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20160630/0242d212/attachment.asc>

More information about the P4-dev mailing list