summaryrefslogtreecommitdiff
path: root/python/ovs/flow/ofp.py
diff options
context:
space:
mode:
authorAdrian Moreno <amorenoz@redhat.com>2022-12-19 17:13:44 +0100
committerIlya Maximets <i.maximets@ovn.org>2022-12-21 18:36:02 +0100
commitfe204743cbc609dc5dfefd1437fc058b7ad3ca52 (patch)
tree31e75b3a7d0b7ea232d712b1d3fb860215b6433e /python/ovs/flow/ofp.py
parent3648fec08f15b3f2cc37cd4b85eaccb773d1f444 (diff)
downloadopenvswitch-fe204743cbc609dc5dfefd1437fc058b7ad3ca52.tar.gz
python: Add explicit decoders for all ofp actions.
We were silently relying on some ofp actions to be decoded by the default decoder which would yield decent string values. In order to be more safe and robust, add an explicit decoder for all missing actions. This patch also reworks the learn action decoding to make it more explicit and verify all the fields specified in the learn action are actually valid fields. Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'python/ovs/flow/ofp.py')
-rw-r--r--python/ovs/flow/ofp.py50
1 files changed, 35 insertions, 15 deletions
diff --git a/python/ovs/flow/ofp.py b/python/ovs/flow/ofp.py
index 0bc110c57..3d79ed6ad 100644
--- a/python/ovs/flow/ofp.py
+++ b/python/ovs/flow/ofp.py
@@ -243,6 +243,7 @@ class OFPFlow(Flow):
**OFPFlow._fw_action_decoders_args(),
**OFPFlow._control_action_decoders_args(),
**OFPFlow._other_action_decoders_args(),
+ **OFPFlow._instruction_action_decoders_args(),
}
clone_actions = OFPFlow._clone_actions_decoders_args(actions)
actions.update(clone_actions)
@@ -272,6 +273,8 @@ class OFPFlow(Flow):
"pop_vlan": decode_flag,
"strip_vlan": decode_flag,
"push_vlan": decode_default,
+ "pop_mpls": decode_int,
+ "push_mpls": decode_int,
"decap": decode_flag,
"encap": decode_encap,
}
@@ -286,8 +289,8 @@ class OFPFlow(Flow):
"set_mpls_ttl",
"mod_nw_tos",
"mod_nw_ecn",
- "mod_tcp_src",
- "mod_tcp_dst",
+ "mod_tp_src",
+ "mod_tp_dst",
]
return {
"load": decode_load_field,
@@ -299,9 +302,15 @@ class OFPFlow(Flow):
"mod_dl_src": EthMask,
"mod_nw_dst": IPMask,
"mod_nw_src": IPMask,
+ "mod_nw_ttl": decode_int,
+ "mod_vlan_vid": decode_int,
+ "set_vlan_vid": decode_int,
+ "mod_vlan_pcp": decode_int,
+ "set_vlan_pcp": decode_int,
"dec_ttl": decode_dec_ttl,
"dec_mpls_ttl": decode_flag,
"dec_nsh_ttl": decode_flag,
+ "delete_field": decode_field,
"check_pkt_larger": decode_chk_pkt_larger,
**{field: decode_default for field in field_default_decoders},
}
@@ -342,6 +351,14 @@ class OFPFlow(Flow):
)
),
"ct_clear": decode_flag,
+ "fin_timeout": nested_kv_decoder(
+ KVDecoders(
+ {
+ "idle_timeout": decode_time,
+ "hard_timeout": decode_time,
+ }
+ )
+ ),
}
@staticmethod
@@ -382,22 +399,13 @@ class OFPFlow(Flow):
actions.
"""
return {
- "learn": decode_learn(
- {
- **action_decoders,
- "fin_timeout": nested_kv_decoder(
- KVDecoders(
- {
- "idle_timeout": decode_time,
- "hard_timeout": decode_time,
- }
- )
- ),
- }
- ),
+ "learn": decode_learn(action_decoders),
"clone": functools.partial(
decode_exec, KVDecoders(action_decoders)
),
+ "write_actions": functools.partial(
+ decode_exec, KVDecoders(action_decoders)
+ ),
}
@staticmethod
@@ -426,3 +434,15 @@ class OFPFlow(Flow):
)
),
}
+
+ @staticmethod
+ def _instruction_action_decoders_args():
+ """Generate the decoder arguments for instruction actions
+ (see man(7) ovs-actions)."""
+ return {
+ "meter": decode_int,
+ "clear_actions": decode_flag,
+ # write_actions moved to _clone actions
+ "write_metadata": decode_mask(64),
+ "goto_table": decode_int,
+ }