Repository navigation
fix(link)!: L2TPv2 drops the reserved flag bits on rebuild, and make() drops a lone ns or nr - #1226
Merged
Merged
Conversation
…) drops a lone ns or nr - Declare the reserved bits 2-3, 5 and 8-11 as BitField subfields, carry them on Flags.reserved (on-wire positions, mask 0x34F0) and pass them back through _make_data/make(), so a rebuild keeps them (#1207). - make() raises ProtocolError when only one of ns/nr is given, since RFC 2661 section 3.1 has S mark both fields together (#1208); it also refuses a reserved value outside 0x34F0. Closes #1207 Closes #1208
Contributor
|
Coverage: 88.91% (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) — pylint/mypy/isort run with the Makefile flags on the three changed source files; no new messagesmake testpasses, and a test case covers the change — the modules listed below onlyWhat is the purpose of your pull request?
fix— corrects a defectDescription
Closes #1207
Closes #1208
#1207: the flags
BitFieldgainsreserved_1(bits 2-3),reserved_2(bit 5) andreserved_3(bits 8-11);Flags.reservedholds them in on-wire positions (mask0x34F0), andmake(reserved=...)writes them back.200200010002ff03002145000000was rebuilt as000200…; it now rebuilds byte-exactly, as do masks0x1000,0x0400,0x00f0and0x34f0, also inside UDP/1701.#1208: RFC 2661 §3.1 has
Smark Ns and Nr together, so a lone value cannot be represented. I choseProtocolErrorover defaulting the other to 0: a default would write an Nr/Ns the caller never asked for, and the library's other builders refuse to invent wire values.L2TPv2(ns=7)used to return000200000000; it now raisesProtocolError: L2TPv2: ns and nr must be given together.Breaking:
data.link.l2tp.Flagshas a new required fieldreserved, and the schema flags dict three new keys.make()now raises where it used to drop a lonens/nr, and also raises forreservedbits outside0x34F0.tests/protocols/link/test_link_unit.pyhand-built fixtures gained the new keys (they did not pin wrong behaviour, but they omitted keys the real schema always produces).Tests: new
tests/protocols/link/test_l2tpv2_roundtrip_unit.py: 6 passed / 12 subtests with the fix; reverting the fix gives12 failed, 3 passed(the 3 being a positive control and the outer tests whose subtests failed). Also passed:test_link_unit(24),test_l2tpv2_length_roundtrip_unit(4),test_l2tpv2_type_unit(8),test_l2tp_version_unit(7),test_make_data_keys_unit(2),test_construction_keyword_check_unit(21),test_option_roundtrip_unit(6, no L2TP entry inEXPECTED_FAILURES);run_unittest_leg.py protocols --exclude protocols/internet: 856 tests, 0 failures;tests/project: 389 passed, 1 skipped.