Repository navigation
fix(l2tp): L2TPv2.from_data drops the L flag and the Length field - #1174
Merged
Merged
Conversation
`_make_data` returned the parsed Length under `length`, which `ProtocolBase.__init__` consumes as the parse length, so it never reached `make()` and the rebuild cleared `L` and omitted the Length octets. `make()` now takes it as `total_length`, as #1166 did for IPv4 and UDP, and `_make_data` passes it under that key. `test_link_unit` called `make(length=20)` directly and is updated to the new keyword. All 24 T/L/S/O(+pad) combinations now round-trip. Closes #1172
Contributor
|
Coverage: 88.89% (unit tier, Python 3.14,
Per-file detail: the |
Owner
Author
|
Cross-review verdict on
|
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.
make pylint,make mypy,make isort) — run with the Makefile flags onl2tpv2.py(mypy clean, isort clean, pylint only the pre-existing W0622 ontype)make testpasses, and a test case covers the change — per-module runs listed below, not the fullmake testWhat is the purpose of your pull request?
fix— corrects a defectCloses #1172
Cause.
_make_datareturned the parsed Length aslength, whichProtocolBase.__init__takes as the parse length, somake()never saw it and clearedL.make()now takestotal_length(as #1166 did for IPv4/UDP).tests/protocols/link/test_link_unit.pycalledmake(length=20)directly and is updated to the new keyword.Probe.
L2TPv2.from_data(L2TPv2(bytes.fromhex('c802000c0001000000010002')).info).data.hex(): before88020001000000010002, afterc802000c0001000000010002. Over every T/L/S/O combination, with and without a 3-octet zero pad: 12/24 round-trip before, 24/24 after. No capture inexamples/captures/carries L2TP (0 frames out of 103 UDP).Tests. New
tests/protocols/link/test_l2tpv2_length_roundtrip_unit.py:4 passed, 24 subtests passed; with the fix reverted,15 failed, 1 passed, 12 subtests passed.test_link_unit24 passed,test_l2tp_version_unit7 passed,test_make_data_keys_unit2 passed,test_construction_keyword_check_unit21 passed,test_option_roundtrip_unit6 passed,tests/project389 passed, 1 skipped.util/run_unittest_leg.py protocols --exclude protocols/internet: 831 tests, 0 failures, 0 errors before; 835 tests, 0 failures, 0 errors after.