diff mbox series

[ovs-dev] python: ovs: flow: Fix nested check_pkt_len acts.

Message ID 20240606151546.3020610-1-amorenoz@redhat.com
State Accepted
Commit 2c1a432e2f089f54c4aa395befbc6c2f07f0d305
Delegated to: Ilya Maximets
Headers show
Series [ovs-dev] python: ovs: flow: Fix nested check_pkt_len acts. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Adrián Moreno June 6, 2024, 3:15 p.m. UTC
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.

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
 python/ovs/flow/odp.py       | 43 ++++++++++++++++++------------------
 python/ovs/tests/test_odp.py | 29 ++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 21 deletions(-)

Comments

Ilya Maximets June 6, 2024, 4 p.m. UTC | #1
On 6/6/24 17:15, Adrian Moreno wrote:
> 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.
> 
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> ---
>  python/ovs/flow/odp.py       | 43 ++++++++++++++++++------------------
>  python/ovs/tests/test_odp.py | 29 ++++++++++++++++++++++++
>  2 files changed, 51 insertions(+), 21 deletions(-)

Hi, Adrian.

Could you, please, provide a Fixes tag for this?
No need to send v2 just for this, just reply with it to this thread.
(Tags should start from the beginning of the line for patchwork to
recognize them.)

Best regards, Ilya Maximets.
Adrián Moreno June 6, 2024, 5:53 p.m. UTC | #2
On Thu, Jun 06, 2024 at 06:00:26PM GMT, Ilya Maximets wrote:
> On 6/6/24 17:15, Adrian Moreno wrote:
> > 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.
> >
> > Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> > ---
> >  python/ovs/flow/odp.py       | 43 ++++++++++++++++++------------------
> >  python/ovs/tests/test_odp.py | 29 ++++++++++++++++++++++++
> >  2 files changed, 51 insertions(+), 21 deletions(-)
>
> Hi, Adrian.
>
> Could you, please, provide a Fixes tag for this?
> No need to send v2 just for this, just reply with it to this thread.
> (Tags should start from the beginning of the line for patchwork to
> recognize them.)
>

Sure, how about this:

Reported-by: Ilya Maximets <i.maximets@ovn.org>
Fixes: 076663b31edc ("python: Add ovs datapath flow parsing.")

Thanks
Adrián
Eelco Chaudron June 7, 2024, 7:06 a.m. UTC | #3
On 6 Jun 2024, at 17:15, Adrian Moreno wrote:

> 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.
>
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>

Thanks for fixing this, changes look good to me. Guess only a fixes tag is missing as Ilya already mentioned.

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Ilya Maximets June 7, 2024, 1:52 p.m. UTC | #4
On 6/6/24 19:53, Adrián Moreno wrote:
> On Thu, Jun 06, 2024 at 06:00:26PM GMT, Ilya Maximets wrote:
>> On 6/6/24 17:15, Adrian Moreno wrote:
>>> 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.
>>>
>>> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
>>> ---
>>>  python/ovs/flow/odp.py       | 43 ++++++++++++++++++------------------
>>>  python/ovs/tests/test_odp.py | 29 ++++++++++++++++++++++++
>>>  2 files changed, 51 insertions(+), 21 deletions(-)
>>
>> Hi, Adrian.
>>
>> Could you, please, provide a Fixes tag for this?
>> No need to send v2 just for this, just reply with it to this thread.
>> (Tags should start from the beginning of the line for patchwork to
>> recognize them.)
>>
> 
> Sure, how about this:
> 
> Reported-by: Ilya Maximets <i.maximets@ovn.org>
> Fixes: 076663b31edc ("python: Add ovs datapath flow parsing.")
> 
> Thanks
> Adrián
> 

Thanks, Adrian and Eelco!

Applied and backported down to 3.0.

Best regards, Ilya Maximets.
diff mbox series

Patch

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,
         )
 
-        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
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))",
             [