Describe the bug
ESP accepts an extension= keyword, stores it, and then never reads it. Extension mode is dead code for that one protocol.
pcapkit/protocols/internet/esp.py:1276 assigns self._extf = extension, and no line anywhere in the file reads self._extf. Contrast pcapkit/protocols/internet/ah.py, its sibling under IPsec, which reads it three times (:75, :87, :99) to guard name, protochain and payload, and assigns it at :233.
Counted across the eight implemented IPv6 extension headers:
_extf UnsupportedCall if extension: return
HOPOPT 4 7 1
IPv6_Route 4 7 1
IPv6_Opts 4 7 1
IPv6_Frag 4 7 1
MH 4 7 1
HIP 4 7 1
AH 4 7 1
ESP 1 0 0
ESP is the only outlier on all three markers: it has no UnsupportedCall guard properties and no if extension: return short-circuit in read.
Reproduction
Not run against a capture — read from source at origin/main. ESP.read declares extension: 'bool' = False at :996-997 and __post_init__ at :1259-1260, so ESP(..., extension=True) is accepted; :1276 records it; nothing consumes it. The parse therefore behaves identically whether extension is True or False.
Expected behavior
One of two things, and which is a design decision rather than a mechanical fix:
- ESP should support extension mode — then it needs the three
UnsupportedCall guard properties and the if extension: return short-circuit its seven siblings have, and _extf becomes load-bearing.
- ESP should not — then
extension= should be removed from read and __post_init__ rather than accepted and silently discarded, and :1276 deleted.
Accepting a keyword that changes nothing is the worst of the three, because a caller cannot tell it had no effect.
System information
Source-only; no library version involved. Read at origin/main.
Additional context
Found while measuring the IPv6_Ext shared-base proposal on #891, where it decides whether ESP joins that base. Noted there in #891 so the refactor is not silently made to carry this fix: giving ESP the base would supply the missing guards as a side effect, turning a behaviour-preserving refactor into a behaviour change. This issue exists so that question gets answered on its own merits.
Describe the bug
ESPaccepts anextension=keyword, stores it, and then never reads it. Extension mode is dead code for that one protocol.pcapkit/protocols/internet/esp.py:1276assignsself._extf = extension, and no line anywhere in the file readsself._extf. Contrastpcapkit/protocols/internet/ah.py, its sibling underIPsec, which reads it three times (:75,:87,:99) to guardname,protochainandpayload, and assigns it at:233.Counted across the eight implemented IPv6 extension headers:
ESPis the only outlier on all three markers: it has noUnsupportedCallguard properties and noif extension: returnshort-circuit inread.Reproduction
Not run against a capture — read from source at
origin/main.ESP.readdeclaresextension: 'bool' = Falseat:996-997and__post_init__at:1259-1260, soESP(..., extension=True)is accepted;:1276records it; nothing consumes it. The parse therefore behaves identically whetherextensionisTrueorFalse.Expected behavior
One of two things, and which is a design decision rather than a mechanical fix:
UnsupportedCallguard properties and theif extension: returnshort-circuit its seven siblings have, and_extfbecomes load-bearing.extension=should be removed fromreadand__post_init__rather than accepted and silently discarded, and:1276deleted.Accepting a keyword that changes nothing is the worst of the three, because a caller cannot tell it had no effect.
System information
Source-only; no library version involved. Read at
origin/main.Additional context
Found while measuring the
IPv6_Extshared-base proposal on #891, where it decides whetherESPjoins that base. Noted there in#891so the refactor is not silently made to carry this fix: givingESPthe base would supply the missing guards as a side effect, turning a behaviour-preserving refactor into a behaviour change. This issue exists so that question gets answered on its own merits.