Repository navigation
fix(toolkit): pyshark traces no TCP inside encapsulations the default engine leaves raw (#1639) - #1670
Conversation
|
Verdict: GOOD TO GO at Round 2's fix: tshark moves Unverified:
A Left for a follow-up, being filed: the |
|
resolve conflicts |
|
Recorded: resolving the conflicts. With #1663 merged, the only conflict is in |
… engine leaves raw (#1639) - tshark dissects TCP inside link types 12 and 14, which it reads as raw IP, Linux SLL, MPLS, PPPoE, 802.3 LLC/SNAP, Cisco ISL, GRE, VXLAN and L2TP, all of which the default engine leaves raw, so pyshark traced TCP the default engine does not. - tcp_traceflow now reads every frame tshark finds TCP in from its octets, by #1625's path: the outermost IP layer the default engine dissects, by the capture file's link type, then IP-in-IP alone. Where it dissects no IP there, or tshark's IP layer is elsewhere, nothing is traced. OCTETS_FILTER gains tcp, so the second tshark pass serves these frames. - _network matches tshark's destination address where tshark reports it: behind an LSRR or SSRR route not used up, ip.dst is the route's last address, in the option, so such frames were not traced. - A frame whose octets cannot be had is still traced as tshark dissects it. - Update the #1625 tests that pinned the interim fallback, and drop the ipv6-33/pyshark/trace gap from the #1604 table, which this closes. Tests: new tests/toolkit/test_pyshark_encapsulated_tcp_1639_unit.py. Closes #1639
|
Coverage: 89.46% (unit tier, Python 3.14,
Per-file detail: the |
|
Verdict: GOOD TO GO at
|
6890f38 to
f0c02f0
Compare
Third-party engines are best effort (#1687), so the pyshark code that exists only to match the default engine comes out: - revert #1686, #1670 and #1642: the second tshark pass that read a frame's octets, the link type read from the capture file, the 64-layer bound, reading past tshark's 802.1Q limit, and keying a source-routed segment by ip.cur_rt - revert #1613's tshark preferences that turned IP reassembly off, with its FileCapture assertion in test_runtime_engines.py and its sentence in the engines index - keep #1613's partial-TCP-header guard and #1605's keying by the IP header that carries the segment - re-land #1671's crash fix: a TCP layer whose IP layer lacks ip.src or ip.dst is not traced, rather than raising AttributeError - delete the three test modules those reverts added and the agreement checks in test_pyshark_unit.py; the #1611 and #1671 checks assert constants The pyshark test modules, test_runtime_engines.py, test_engine_runtime.py and the project guards pass on 3.11 (tshark 4.6.9) and 3.14.
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
Cause. pyshark traced whatever TCP tshark dissects. tshark dissects TCP inside DLT 12 and 14 (it reads both as raw IP), Linux SLL, MPLS, PPPoE, LLC/SNAP, Cisco ISL, GRE, VXLAN and L2TP, and the default engine leaves all of these raw.
Fix. Every frame tshark finds TCP in now takes #1642's octet path (
pcapkit/toolkit/pyshark.py:958): the outermost IP layer by the capture file's link type, then IP-in-IP only. Nothing is traced where the default engine reads no IP, or where tshark's IP layer is elsewhere._networkmatches that layer's destination address where tshark reports it (:835), because behind an LSRR or SSRR route not yet used up tshark'sip.dstis the route's last address, in the option.OCTETS_FILTERgainstcp(:356). The second tshark pass costs about 0.1 s per capture with TCP: 0.12 s against 0.23 s median on 3 frames. On 5,000 TCP frames it is lost in run-to-run noise (28.8–29.2 s on both). If the octets can't be read, the frame is traced as tshark dissects it, as before.Measured on 3.11 with tshark 4.6.9, against
main. The sweep covers 18,050 frames on DLTs 0, 1, 12, 14, 101, 108, 113, 228, 229 and 276 plus PCAP-NG, and 10,080 more behind LSRR, SSRR and Record Route options (live, used up and malformed). Result: 0 new disagreements, 10,685 fixed, 126 left (#1626 andFRAME_LAYER_LIMIT, below). 2,357 of the fixed frames are in 12 source-route captures thatmain's pyshark aborted with a bareAttributeError, because tshark gives noip.dstbehind a length-9 route. This branch reads them through.Tests. New
tests/toolkit/test_pyshark_encapsulated_tcp_1639_unit.py. Withpcapkit/atmain, all 11 tests fail (32 failures). On this branch's previous revision, its source-route cases fail (3 tests, 5 failures). Three existing files pinned #1642's interim fallback and are updated, as before.Not fixed here, unchanged from
main:FRAME_LAYER_LIMIT.ip.dst, and raisesAttributeErrorwhere there is none.TSharkCrashException(retcode 255) is a race that also happens onmain. It hitstest_engine_agreement_runtime.pyabout 0.3 times per run on both: 11 in 37 runs onmain, 12 in 42 here.Closes #1639