-
Notifications
You must be signed in to change notification settings - Fork 2
Description
The ActionHeader class has a get_size() method that returns the action length including the padding in multiple of 8. While this makes sense for inherited objects, it is not correct for actual ActionHeader() objects.
See this example:
# ./venv/bin/python3
Python 3.9.2 (default, Mar 20 2025, 02:07:39)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyof.v0x04.common.action import ActionType, ActionHeader
>>> a = ActionHeader(action_type=ActionType.OFPAT_OUTPUT, length=4)
>>> a.pack()
b'\x00\x00\x00\x04'
>>> a.get_size()
8
Of course, the correct size for the example above would be 4.
The ActionHeader can be pretty useful to be used directly when creating Table Features Properties, specially for ActionsProperty and field action_ids. As per the spec:
The action_ids is the list of actions for the feature (see 5.12). The elements of that list are variable size to enable expressing experimenter > actions, non-experimenter actions are 4 bytes.
I'm facing issues with this because of an implementation I'm doing for the p4ofagent software, which will accept passive OpenFlow connections to be used with ovs-ofctl dump-flows for instance. I'm getting incorrect TableFeatures length because of this.