secdev / scapy

Scapy: the Python-based interactive packet manipulation program & library.
https://scapy.net
GNU General Public License v2.0
10.29k stars 1.99k forks source link

In contrib/openflow3, bug with how OFPTFPTInstructions manages padding #4437

Closed LRGH closed 3 days ago

LRGH commented 1 week ago

Brief description

Existing test in test/contrib/openflow3.uts relies on the internal cache management of raw packet. This is highlighted by the following test, and can also be detected when raw packet cache is disabled.

Scapy version

2.5.0

Python version

all

Operating system

all

Additional environment information

Same for more recent versions (e.g. 640252ec9e8cb887b1b41a4c9f2e37124fc53fa5) and old versions (e.g. 2.3.3)

How to reproduce

from scapy.contrib.openflow3 import *

fpti = OFPTFPTInstructions(instruction_ids=[OFPITGotoTableID(), OFPITClearActionsID()])
print( len(fpti) )
fpti = OFPTFPTInstructions(raw(fpti))
print( len(fpti) )
fpti.instruction_ids[0] = OFPITGotoTableID()
print( len(fpti) )

Actual result

16
16
20

Expected result

16
16
16

Related resources

No response

gpotter2 commented 1 week ago

Thanks for the report, this is fixed in https://github.com/secdev/scapy/pull/4440.