Repository navigation
fix(toolkit): pyshark traces TCP behind an IPv4 extension header as the default engine does (#1625) - #1628
fix(toolkit): pyshark traces TCP behind an IPv4 extension header as the default engine does (#1625)#1628JarryShaw wants to merge 1 commit into
Conversation
|
Coverage: 89.73% (unit tier, Python 3.14,
Per-file detail: the |
|
Verdict: NEEDS CHANGES at Sonnet cross-review. The fix itself holds, and the review checked it against its own frames: 58 hand-built frames and 564 truncation cut points match the default engine field by field, and frame alignment holds on every pcapng shape tried. But the second tshark pass adds failure modes that
Required: a second pass that fails or cannot be parsed must not crash the extraction or silently drop frames. Fall back to tshark's dissection with a warning, or raise from |
…he default engine does (#1625) - tshark dissects TCP behind an AH or IPv6 extension header in IPv4 by its own rules, and leaves the payload of a Mobility or HIP header out of the PDML, so the pyshark engine traced TCP the default engine rejects there and missed the TCP behind protocols 135 and 139. - tcp_traceflow now reads such a frame's TCP from its octets, by the rules the other engines share (pypcapfile's _upper_layer and _default_accepts), up to EXTENSION_HEADER_LIMIT headers and through IP-in-IP tunnels. - The engine reads those octets from a second tshark process of its own (-T ek -x -J frame, filtered to such frames), started on first use, read forward by frame number, and reaped on close. If it fails, the engine warns with PySharkWarning and traces such frames as tshark dissects them. - Drop ipv4-33/pyshark/trace from the #1609 Gap row, which this fixes. Tests: new tests/toolkit/test_pyshark_ipv4_extension_headers_1625_unit.py.
7d346ac to
e9d316a
Compare
|
Verdict: GOOD TO GO at Sonnet cross-review, round 2. Both round-1 findings are fixed. Simple Packet Blocks trace as the default engine does, and early close leaves no tshark processes and no zombie.
I reproduced the round-1 SPB probe agreeing on all 4 captures, the new tests passing (17) and failing against main's pyshark files (79), and no tshark left afterwards. Non-blocking: an engine dropped without |
|
Resolve conflicts |
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeAdded a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseDescription of your pull request and other information
Closes #1625.
tcp_traceflownow reads the TCP from the frame's octets with pypcapfile's rules (_upper_layer,_past_extension_headers,_default_accepts). The approach matches open PR fix(toolkit): dpkt and scapy find TCP in IPv4 where the default engine does (#1606, #1617) #1624 for dpkt and scapy.mipv6layer, and HIP's fields stop at offset 74 of a 101-octet frame.-T pdmlrefuses-x. So on the first frame that needs octets, the engine starts its owntshark -T ek -x -J frame, filtered to those protocols. It reads it forward by frame number and kills and reaps it on close. A capture without such frames never starts it. It isn't a second pysharkFileCapture: pyshark's JSON parser raisesKeyErroron a Simple Packet Block, and each capture replaces the asyncio child watcher, which left the first pass's tshark a zombie.PySharkWarning). That frame and later ones are traced as tshark dissects them, as on main. I chose this over raising so that no capture main extracts stops extracting.ipv4-33/pyshark/traceleaves itsGaprow. IPv6 stays open, so fix(toolkit): the dpkt, scapy and pyshark engines do not stop an extension-header chain at 32 #1609 is not closed.ipv6-33, fix(toolkit): the dpkt, scapy and pyshark engines do not stop an extension-header chain at 32 #1609). TCP reassembly is still declined.