title: Parsing IPv6 extension headers containing unknown extensions
body: <p>I'm writing a very simple net filter, and getting to where I want to parse IPv6 headers to match things like ICMPv6 types, TCP/UDP port numbers, etc.</p>
  
  <p>So I'm reading about the <a href="http://en.wikipedia.org/wiki/IPv6_packet">IPv6 packet format</a> in depth, and I'm kind of like... well... I sort of had to read it over and over again to make sure I was actually reading it right.
  It looks to me that you have to start with the 40-byte fixed header and look at its next header field. Then you have to look at the next header's next header field, and so on, like a linked list, until you reach the end. If there's payload, it will follow.</p>
  
  <p>The problem is that there is no length field either in the fixed header or the extension headers. You have to have a table of extension header types and their sizes so that you can chase this linked list to the end.</p>
  
  <p>This strikes me as a strange, possibly even hare-brained design. What if I encounter an unrecognized extension header type? What do I do? I don't know its length. I guess I have to throw the packet out and block it, since in a net filter allowing the packet through would allow an attacker to evade the net filter by including a bogus header type. <em>But that means that if the protocol is ever extended, every single piece of IPv6 header parsing software ever written must be simultaneously updated if the new extension is to be used.</em></p>
  
  <p>So how can I parse IPv6 headers if I don't know the extensions they're using? How can I skip a header for an unknown extension, since I don't know its length?</p>