Repository navigation
fix(protocols): an IPv4 Total Length of 0 is TSO, and one inside the header is bogus (#1547) - #1554
Merged
Merged
Conversation
…header is bogus (#1547) - A Total Length of 0, as TCP segmentation offload leaves it on the sending host, handed the next layer 0 - hdr_len octets, so TCP fell back to Raw and the flow was never traced. The payload is now the rest of the captured frame with no trailer, as Wireshark and dpkt read it. - Any other Total Length shorter than the header is Wireshark's "Bogus IP length": no payload layer and no negative length reaching one; the octets after the header are kept as the trailer. - Both write the Total Length back as it was, so parse -> rebuild, make -> parse and from_data(info.to_dict()) stay byte-exact. A Total Length past the capture is unchanged. tests/protocols/internet, schema, foundation/reassembly and the capture round trip pass.
Owner
Author
|
Verdict: GOOD TO GO at
Not blocking:
|
4 of 13 tasks
Contributor
|
Coverage: 90.01% (unit tier, Python 3.14,
Per-file detail: the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 change — tests added; rantests/protocols/internet,tests/protocols/schema,tests/foundation/reassembly,tests/protocols/test_capture_roundtrip_runtime.pyandtests/project/test_isort_clean.py, not the full suiteAdded 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 #1547. Follows the owner's ruling to match Wireshark (tshark 4.6.9, measured).
total_length == 0is TSO.IPv4.read(ipv4.py:363) passed0 - hdr_lento the next layer, so TCP fell back toRaw. The payload is now the rest of the captured frame with no trailer, as Wireshark ("presumed TSO") and dpkt read it. Ontcp.pcapwith the IPv4 lengths zeroed, the default engine now traces[(1, 2, 6, 7), (3, 4, 5)], as dpkt and scapy do.0 < total_length < hdr_lenis bogus. tshark reports "Bogus IP length" and stops ateth:ethertype:ip. pcapkit now givesEthernet:IPv4with aNoPayload. No negative length reaches the next layer, and the octets after the header go totrailer.total_lengthback unchanged. parse→rebuild, make→parse andfrom_data(info.to_dict())are byte-exact, with the checksum fixed or stale. Atotal_lengthlonger than the capture is unchanged; the test pins it.schema/internet/ipv4.py:736) now handles both cases explicitly, so it no longer depends on a negative length being read as "unset".internet.pyis untouched; the fix is local to IPv4. Not fixed here: IPv4 reassembly of a TSO datagram is stillPARTIALwith no payload, in every engine, because the toolkit adapters passtl=ipv4.len(0). That needs a follow-up outside this PR's files.Tests:
tests/protocols/internet/test_ipv4_tso_total_length_1547_runtime.py, which fails onmain.