Repository navigation
fix(toolkit): reassemble the first fragmented IP layer, so tunnelled fragments reassemble (#2307) - #2338
Conversation
|
Review: NEEDS CHANGES at
|
691d2bc to
42903c7
Compare
|
Review: GOOD TO GO at
|
|
Coverage: 91.58% (unit tier, Python 3.15,
Per-file detail: the |
…fragments reassemble (#2307) Problem: the IPv4 and IPv6 reassembly adapters read the frame's outermost IPv4 or IPv6 layer, so in an IP-in-IP tunnel a fragmented inner datagram was reassembled whole under the tunnel's header, or dropped (tunnel DF set, or no Fragment header in the tunnel's IPv6), and never reassembled itself. Fix: take the first layer of that IP version, from the outside in, that is a fragment (IPv4 MF or a non-zero offset; an IPv6 Fragment header), else the outermost as before. Applied to the default engine's PCAP and PCAP-NG adapters, and to scapy and dpkt, which picked the outermost too. Test: tests/toolkit/test_tunnelled_ip_reassembly_2307_unit.py reassembles a fragmented inner datagram (4in4 with DF clear and set, 6in6) and a fragmented tunnel carrying a whole one, per engine; the inner cases fail on main. The scapy 6in6 pin now expects the inner packet reassembled on its own header.
42903c7 to
d284138
Compare
|
Amended |
|
Ready to merge at
|
make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix — bug fixDescription
Closes #2307, per the ruling (option 2: reassemble the first fragmented IP layer).
ipv4_reassemblyandipv6_reassemblyreadframe['IPv4']/frame['IPv6'], which is always the outermost layer. In an IP-in-IP tunnel, the inner fragments were keyed on the tunnel's header. They were dropped when the tunnel had DF set, or when its IPv6 header had no Fragment header._fragmenthelper picks the first layer of the right IP version, outside in, that is a fragment. If no layer is a fragment, it falls back to the outermost layer, so untunnelled traffic is unchanged.pcap,pcapng), Scapy and DPKT all use it.test_tunnelled_ip_reassembly_2307_unit.pycovers inner datagrams fragmented inside 4in4 (DF clear and set) and 6in6, plus a fragmented tunnel carrying a whole datagram, on every engine, byte for byte. One existing Scapy test expectedNonefor a fragmented 6in6 inner packet, and now expects it reassembled.origin/main, 13 failed, e.g.ValueError: too many values to unpack (expected 1, got 2). On the head, 22 passed.