diff --git a/python/ovs/flow/odp.py b/python/ovs/flow/odp.py index 7d9b165d4..a8f8c067a 100644 --- a/python/ovs/flow/odp.py +++ b/python/ovs/flow/odp.py @@ -365,29 +365,30 @@ class ODPFlow(Flow): is_list=True, ) + _decoders["check_pkt_len"] = nested_kv_decoder( + KVDecoders( + { + "size": decode_int, + "gt": nested_kv_decoder( + KVDecoders( + decoders=_decoders, + default_free=decode_free_output, + ), + is_list=True, + ), + "le": nested_kv_decoder( + KVDecoders( + decoders=_decoders, + default_free=decode_free_output, + ), + is_list=True, + ), + } + ) + ) + return { **_decoders, - "check_pkt_len": nested_kv_decoder( - KVDecoders( - { - "size": decode_int, - "gt": nested_kv_decoder( - KVDecoders( - decoders=_decoders, - default_free=decode_free_output, - ), - is_list=True, - ), - "le": nested_kv_decoder( - KVDecoders( - decoders=_decoders, - default_free=decode_free_output, - ), - is_list=True, - ), - } - ) - ), } @staticmethod diff --git a/python/ovs/tests/test_odp.py b/python/ovs/tests/test_odp.py index f19ec386e..d514e9be3 100644 --- a/python/ovs/tests/test_odp.py +++ b/python/ovs/tests/test_odp.py @@ -541,6 +541,35 @@ def test_odp_fields(input_string, expected): ), ], ), + ( + "actions:check_pkt_len(size=200,gt(check_pkt_len(size=400,gt(4),le(2))),le(check_pkt_len(size=100,gt(1),le(drop))))", # noqa: E501 + [ + KeyValue( + "check_pkt_len", + { + "size": 200, + "gt": [ + { + "check_pkt_len": { + "size": 400, + "gt": [{"output": {"port": 4}}], + "le": [{"output": {"port": 2}}], + } + } + ], + "le": [ + { + "check_pkt_len": { + "size": 100, + "gt": [{"output": {"port": 1}}], + "le": [{"drop": True}], + } + } + ], + }, + ) + ], + ), ( "actions:meter(1),hash(l4(0))", [