From patchwork Thu Jun 6 15:15:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Moreno?= X-Patchwork-Id: 1944708 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fQYBKl4b; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vw7FX7430z20KL for ; Fri, 7 Jun 2024 01:16:00 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CA2E48474C; Thu, 6 Jun 2024 15:15:58 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id W8X14RIglZUE; Thu, 6 Jun 2024 15:15:55 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 3267284701 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fQYBKl4b Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3267284701; Thu, 6 Jun 2024 15:15:55 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 06A47C0077; Thu, 6 Jun 2024 15:15:55 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 36EB9C0037 for ; Thu, 6 Jun 2024 15:15:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 3239084729 for ; Thu, 6 Jun 2024 15:15:53 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id lpWuTYDDf7rc for ; Thu, 6 Jun 2024 15:15:52 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=amorenoz@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 69FFE84701 Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 69FFE84701 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 69FFE84701 for ; Thu, 6 Jun 2024 15:15:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717686951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9qeFKZXdd+OCF/0qasw8QiAMtU/JqooTSfkQr1WROgo=; b=fQYBKl4bWSo05sqNK0xW4CgEApxtIPMX/jV4zV2ierpWUXYPVT82epkqua1DCU4SRDwjal w0HLnd91+pFaMJk1qLhSZq5uqgqNLT2Hw0piZMvewWARUpm9rzl1M2BnBlzocCJQTXDVUs rRcxvHOIgDgJwvNEBi9b3xrHfERZCeM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-483-A-s0lN3gO42nS83j3Nakrw-1; Thu, 06 Jun 2024 11:15:49 -0400 X-MC-Unique: A-s0lN3gO42nS83j3Nakrw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8C11A800074 for ; Thu, 6 Jun 2024 15:15:49 +0000 (UTC) Received: from antares.redhat.com (unknown [10.39.193.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE3B340C6CB2; Thu, 6 Jun 2024 15:15:48 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Thu, 6 Jun 2024 17:15:46 +0200 Message-ID: <20240606151546.3020610-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH] python: ovs: flow: Fix nested check_pkt_len acts. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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 Reported-by: Ilya Maximets Acked-by: Eelco Chaudron --- python/ovs/flow/odp.py | 43 ++++++++++++++++++------------------ python/ovs/tests/test_odp.py | 29 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 21 deletions(-) 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))", [