Skip to content

Commit

Permalink
python: ovs: flow: Fix nested check_pkt_len acts.
Browse files Browse the repository at this point in the history
Add check_pkt_len action to the decoder list that it, itself, uses.

This makes nested check_pkt_len (i.e:a check_pkt_len inside another)
work.

Fixes: 076663b ("python: Add ovs datapath flow parsing.")
Reported-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
  • Loading branch information
amorenoz authored and igsilya committed Jun 7, 2024
1 parent fad8c8f commit 2c1a432
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 21 deletions.
43 changes: 22 additions & 21 deletions python/ovs/flow/odp.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,29 +365,30 @@ def _action_decoders_args():
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,
_decoders["check_pkt_len"] = nested_kv_decoder(
KVDecoders(
{
"size": decode_int,
"gt": nested_kv_decoder(
KVDecoders(
decoders=_decoders,
default_free=decode_free_output,
),
"le": nested_kv_decoder(
KVDecoders(
decoders=_decoders,
default_free=decode_free_output,
),
is_list=True,
is_list=True,
),
"le": nested_kv_decoder(
KVDecoders(
decoders=_decoders,
default_free=decode_free_output,
),
}
)
),
is_list=True,
),
}
)
)

return {
**_decoders,
}

@staticmethod
Expand Down
29 changes: 29 additions & 0 deletions python/ovs/tests/test_odp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))",
[
Expand Down

0 comments on commit 2c1a432

Please sign in to comment.