get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1558024/
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1558024,
    "url": "http://patchwork.ozlabs.org/api/patches/1558024/",
    "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/20211122112256.2011194-9-amorenoz@redhat.com/",
    "project": {
        "id": 47,
        "url": "http://patchwork.ozlabs.org/api/projects/47/",
        "name": "Open vSwitch",
        "link_name": "openvswitch",
        "list_id": "ovs-dev.openvswitch.org",
        "list_email": "ovs-dev@openvswitch.org",
        "web_url": "http://openvswitch.org/",
        "scm_url": "git@github.com:openvswitch/ovs.git",
        "webscm_url": "https://github.com/openvswitch/ovs",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20211122112256.2011194-9-amorenoz@redhat.com>",
    "list_archive_url": null,
    "date": "2021-11-22T11:22:46",
    "name": "[ovs-dev,v1,08/18] python: add ovs datapath flow parsing",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "e66f21bbec5852fc551781269d694d1a0613db84",
    "submitter": {
        "id": 77477,
        "url": "http://patchwork.ozlabs.org/api/people/77477/",
        "name": "Adrian Moreno",
        "email": "amorenoz@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/20211122112256.2011194-9-amorenoz@redhat.com/mbox/",
    "series": [
        {
            "id": 273222,
            "url": "http://patchwork.ozlabs.org/api/series/273222/",
            "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=273222",
            "date": "2021-11-22T11:22:39",
            "name": "python: add flow parsing library",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/273222/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1558024/comments/",
    "check": "fail",
    "checks": "http://patchwork.ozlabs.org/api/patches/1558024/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ovs-dev-bounces@openvswitch.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "dev@openvswitch.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "ovs-dev@lists.linuxfoundation.org"
        ],
        "Authentication-Results": [
            "bilbo.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=iDgUfn6T;\n\tdkim-atps=neutral",
            "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=140.211.166.137; helo=smtp4.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN>)",
            "smtp1.osuosl.org (amavisd-new);\n dkim=pass (1024-bit key) header.d=redhat.com",
            "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amorenoz@redhat.com"
        ],
        "Received": [
            "from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby bilbo.ozlabs.org (Postfix) with ESMTPS id 4HyQ022s1tz9sRR\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 22 Nov 2021 22:24:18 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby smtp4.osuosl.org (Postfix) with ESMTP id B4958410B8;\n\tMon, 22 Nov 2021 11:24:16 +0000 (UTC)",
            "from smtp4.osuosl.org ([127.0.0.1])\n\tby localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id kBJyzmzyW_4c; Mon, 22 Nov 2021 11:24:15 +0000 (UTC)",
            "from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56])\n\tby smtp4.osuosl.org (Postfix) with ESMTPS id 68C9A41BF8;\n\tMon, 22 Nov 2021 11:24:14 +0000 (UTC)",
            "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 34E13C0036;\n\tMon, 22 Nov 2021 11:24:14 +0000 (UTC)",
            "from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 03166C0012\n for <dev@openvswitch.org>; Mon, 22 Nov 2021 11:24:13 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n by smtp1.osuosl.org (Postfix) with ESMTP id EE71C80B1C\n for <dev@openvswitch.org>; Mon, 22 Nov 2021 11:23:37 +0000 (UTC)",
            "from smtp1.osuosl.org ([127.0.0.1])\n by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id 6LIqBlSEO9Mq for <dev@openvswitch.org>;\n Mon, 22 Nov 2021 11:23:36 +0000 (UTC)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by smtp1.osuosl.org (Postfix) with ESMTPS id B637180F49\n for <dev@openvswitch.org>; Mon, 22 Nov 2021 11:23:36 +0000 (UTC)",
            "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-52-DpUhfED5NtuAodAwZ8tnNw-1; Mon, 22 Nov 2021 06:23:32 -0500",
            "from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com\n [10.5.11.13])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 839C010168C0\n for <dev@openvswitch.org>; Mon, 22 Nov 2021 11:23:31 +0000 (UTC)",
            "from amorenoz.users.ipa.redhat.com (unknown [10.2.16.196])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 45E4260862;\n Mon, 22 Nov 2021 11:23:30 +0000 (UTC)"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.8.0",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1637580215;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=oXMglsVZetRuyyan8FiQ7vspz5bMLplRJvpqqvb4vOE=;\n b=iDgUfn6T7K6iCJmiD1MwbPVXZk+2IiZulLf/l3sg94ZeMWNCFRjD8zxG2cR4bpsIpLfrxh\n UaAAp5R7jTV7llqJEctamzJ4q3CZA5z3iqiNdEKnTVn3Sx15z/g0OqRXNdu89FchtKQny5\n 7kkBeLd+fQN7RCyl33nLfflH32g6LR0=",
        "X-MC-Unique": "DpUhfED5NtuAodAwZ8tnNw-1",
        "From": "Adrian Moreno <amorenoz@redhat.com>",
        "To": "dev@openvswitch.org",
        "Date": "Mon, 22 Nov 2021 12:22:46 +0100",
        "Message-Id": "<20211122112256.2011194-9-amorenoz@redhat.com>",
        "In-Reply-To": "<20211122112256.2011194-1-amorenoz@redhat.com>",
        "References": "<20211122112256.2011194-1-amorenoz@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.13",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Subject": "[ovs-dev] [PATCH v1 08/18] python: add ovs datapath flow parsing",
        "X-BeenThere": "ovs-dev@openvswitch.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "<ovs-dev.openvswitch.org>",
        "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>",
        "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>",
        "List-Post": "<mailto:ovs-dev@openvswitch.org>",
        "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>",
        "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "ovs-dev-bounces@openvswitch.org",
        "Sender": "\"dev\" <ovs-dev-bounces@openvswitch.org>"
    },
    "content": "A ODPFlow is a Flow with the following sections:\nufid\ninfo (e.g: bytes, packets, dp, etc)\nmatch\nactions\n\nUse a factory class ODPFlowFactory to cache the decoder objects.\n\nOnly three datapath actions require special handling:\ngre: because it has double parenthesys\ngeneve: because it supports many concatenated lists of options\nnat: we reuse the decoder used for openflow actions\n\nSigned-off-by: Adrian Moreno <amorenoz@redhat.com>\n---\n python/automake.mk      |   3 +-\n python/ovs/flows/odp.py | 723 ++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 725 insertions(+), 1 deletion(-)\n create mode 100644 python/ovs/flows/odp.py",
    "diff": "diff --git a/python/automake.mk b/python/automake.mk\nindex d1464d7f6..8b0713cfc 100644\n--- a/python/automake.mk\n+++ b/python/automake.mk\n@@ -48,7 +48,8 @@ ovs_pyfiles = \\\n \tpython/ovs/flows/list.py \\\n \tpython/ovs/flows/flow.py \\\n \tpython/ovs/flows/ofp.py \\\n-\tpython/ovs/flows/ofp_act.py\n+\tpython/ovs/flows/ofp_act.py \\\n+\tpython/ovs/flows/odp.py\n \n # These python files are used at build time but not runtime,\n # so they are not installed.\ndiff --git a/python/ovs/flows/odp.py b/python/ovs/flows/odp.py\nnew file mode 100644\nindex 000000000..8fe721f86\n--- /dev/null\n+++ b/python/ovs/flows/odp.py\n@@ -0,0 +1,723 @@\n+\"\"\" Defines an Openvswitch Datapath Flow\n+\"\"\"\n+import re\n+from functools import partial\n+\n+from ovs.flows.flow import Flow, Section\n+\n+from ovs.flows.kv import (\n+    KVParser,\n+    KVDecoders,\n+    nested_kv_decoder,\n+    decode_nested_kv,\n+)\n+from ovs.flows.decoders import (\n+    decode_default,\n+    decode_time,\n+    decode_int,\n+    decode_mask,\n+    Mask8,\n+    Mask16,\n+    Mask32,\n+    Mask64,\n+    Mask128,\n+    IPMask,\n+    EthMask,\n+    decode_free_output,\n+    decode_flag,\n+    decode_nat,\n+)\n+\n+\n+class ODPFlow(Flow):\n+    def __init__(self, sections, raw=\"\", id_=None):\n+        \"\"\"Constructor\"\"\"\n+        super(ODPFlow, self).__init__(sections, raw, id_)\n+\n+    def __str__(self):\n+        if self._orig:\n+            return self._orig\n+        else:\n+            return self.to_string()\n+\n+    def to_string(self):\n+        \"\"\"Print a text representation of the flow\"\"\"\n+        string = \"Info: {}\\n\" + self.info\n+        string += \"Match : {}\\n\" + self.match\n+        string += \"Actions: {}\\n \" + self.actions\n+        return string\n+\n+\n+class ODPFlowFactory:\n+    \"\"\"Datapath Flow\"\"\"\n+\n+    def __init__(self):\n+        self.info_decoders = self._info_decoders()\n+        self.match_decoders = self._match_decoders()\n+        self.action_decoders = self._action_decoders()\n+\n+    def from_string(self, odp_string, id=None):\n+        \"\"\"Parse a odp flow string\n+\n+        The string is expected to have the follwoing format:\n+             [ufid], [match] [flow data] actions:[actions]\n+\n+        Args:\n+            odp_string (str): a datapath flow string\n+\n+        Returns:\n+            an ODPFlow instance\n+        \"\"\"\n+\n+        sections = []\n+\n+        # If UFID present, parse it and\n+        ufid_pos = odp_string.find(\"ufid:\")\n+        if ufid_pos >= 0:\n+            ufid_string = odp_string[\n+                ufid_pos : (odp_string[ufid_pos:].find(\",\") + 1)\n+            ]\n+            ufid_parser = KVParser(KVDecoders({\"ufid\": decode_default}))\n+            ufid_parser.parse(ufid_string)\n+            if len(ufid_parser.kv()) != 1:\n+                raise ValueError(\"malformed odp flow: %s\" % odp_string)\n+            sections.append(\n+                Section(\"ufid\", ufid_pos, ufid_string, ufid_parser.kv())\n+            )\n+\n+        action_pos = odp_string.find(\"actions:\")\n+        if action_pos < 0:\n+            raise ValueError(\"malformed odp flow: %s\" % odp_string)\n+\n+        # rest of the string is between ufid and actions\n+        rest = odp_string[\n+            (ufid_pos + len(ufid_string) if ufid_pos >= 0 else 0) : action_pos\n+        ]\n+\n+        action_pos += 8  # len(\"actions:\")\n+        actions = odp_string[action_pos:]\n+\n+        field_parts = rest.lstrip(\" \").partition(\" \")\n+\n+        if len(field_parts) != 3:\n+            raise ValueError(\"malformed odp flow: %s\" % odp_string)\n+\n+        match = field_parts[0]\n+        info = field_parts[2]\n+\n+        iparser = KVParser(KVDecoders(self.info_decoders))\n+        iparser.parse(info)\n+        isection = Section(\n+            name=\"info\",\n+            pos=odp_string.find(info),\n+            string=info,\n+            data=iparser.kv(),\n+        )\n+        sections.append(isection)\n+\n+        mparser = KVParser(KVDecoders(self.match_decoders))\n+        mparser.parse(match)\n+        msection = Section(\n+            name=\"match\",\n+            pos=odp_string.find(match),\n+            string=match,\n+            data=mparser.kv(),\n+        )\n+        sections.append(msection)\n+\n+        aparser = KVParser(\n+            KVDecoders(self.action_decoders, default_free=decode_free_output)\n+        )\n+        aparser.parse(actions)\n+        asection = Section(\n+            name=\"actions\",\n+            pos=action_pos,\n+            string=actions,\n+            data=aparser.kv(),\n+            is_list=True,\n+        )\n+        sections.append(asection)\n+\n+        return ODPFlow(sections, odp_string, id)\n+\n+    @classmethod\n+    def _action_decoders(cls):\n+        _decoders = {\n+            \"drop\": decode_flag,\n+            \"lb_output\": decode_int,\n+            \"trunc\": decode_int,\n+            \"recirc\": decode_int,\n+            \"userspace\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"pid\": decode_int,\n+                        \"sFlow\": nested_kv_decoder(\n+                            KVDecoders(\n+                                {\n+                                    \"vid\": decode_int,\n+                                    \"pcp\": decode_int,\n+                                    \"output\": decode_int,\n+                                }\n+                            )\n+                        ),\n+                        \"slow_path\": decode_default,\n+                        \"flow_sample\": nested_kv_decoder(\n+                            KVDecoders(\n+                                {\n+                                    \"probability\": decode_int,\n+                                    \"collector_sed_id\": decode_int,\n+                                    \"obs_domain_id\": decode_int,\n+                                    \"obs_point_id\": decode_int,\n+                                    \"output_port\": decode_default,\n+                                    \"ingress\": decode_flag,\n+                                    \"egress\": decode_flag,\n+                                }\n+                            )\n+                        ),\n+                        \"ipfix\": nested_kv_decoder(\n+                            KVDecoders(\n+                                {\n+                                    \"output_port\": decode_default,\n+                                }\n+                            )\n+                        ),\n+                        \"controller\": nested_kv_decoder(\n+                            KVDecoders(\n+                                {\n+                                    \"reason\": decode_int,\n+                                    \"dont_send\": decode_int,\n+                                    \"continuation\": decode_int,\n+                                    \"recirc_id\": decode_int,\n+                                    \"rule_cookie\": decode_int,\n+                                    \"controller_id\": decode_int,\n+                                    \"max_len\": decode_int,\n+                                }\n+                            )\n+                        ),\n+                        \"userdata\": decode_default,\n+                        \"actions\": decode_flag,\n+                        \"tunnel_out_port\": decode_int,\n+                        \"push_eth\": nested_kv_decoder(\n+                            KVDecoders(\n+                                {\n+                                    \"src\": EthMask,\n+                                    \"dst\": EthMask,\n+                                    \"type\": decode_int,\n+                                }\n+                            )\n+                        ),\n+                        \"pop_eth\": decode_flag,\n+                    }\n+                )\n+            ),\n+            \"set\": nested_kv_decoder(KVDecoders(cls._field_decoders())),\n+            \"push_vlan\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"vid\": decode_int,\n+                        \"pcp\": decode_int,\n+                        \"cfi\": decode_int,\n+                        \"tpid\": decode_int,\n+                    }\n+                )\n+            ),\n+            \"pop_vlan\": decode_flag,\n+            \"push_nsh\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"flags\": decode_int,\n+                        \"ttl\": decode_int,\n+                        \"mdtype\": decode_int,\n+                        \"np\": decode_int,\n+                        \"spi\": decode_int,\n+                        \"si\": decode_int,\n+                        \"c1\": decode_int,\n+                        \"c2\": decode_int,\n+                        \"c3\": decode_int,\n+                        \"c4\": decode_int,\n+                        \"md2\": decode_int,\n+                    }\n+                )\n+            ),\n+            \"pop_nsh\": decode_flag,\n+            \"tnl_pop\": decode_int,\n+            \"ct_clear\": decode_flag,\n+            \"ct\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"commit\": decode_flag,\n+                        \"force_commit\": decode_flag,\n+                        \"zone\": decode_int,\n+                        \"mark\": Mask32,\n+                        \"label\": Mask128,\n+                        \"helper\": decode_default,\n+                        \"timeout\": decode_default,\n+                        \"nat\": decode_nat,\n+                    }\n+                )\n+            ),\n+            **cls._tnl_action_decoder(),\n+        }\n+\n+        _decoders[\"clone\"] = nested_kv_decoder(\n+            KVDecoders(decoders=_decoders, default_free=decode_free_output)\n+        )\n+\n+        return {\n+            **_decoders,\n+            \"sample\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"sample\": (lambda x: float(x.strip(\"%\"))),\n+                        \"actions\": nested_kv_decoder(\n+                            KVDecoders(\n+                                decoders=_decoders,\n+                                default_free=decode_free_output,\n+                            )\n+                        ),\n+                    }\n+                )\n+            ),\n+            \"check_pkt_len\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"size\": decode_int,\n+                        \"gt\": nested_kv_decoder(\n+                            KVDecoders(\n+                                decoders=_decoders,\n+                                default_free=decode_free_output,\n+                            )\n+                        ),\n+                        \"le\": nested_kv_decoder(\n+                            KVDecoders(\n+                                decoders=_decoders,\n+                                default_free=decode_free_output,\n+                            )\n+                        ),\n+                    }\n+                )\n+            ),\n+        }\n+\n+    @classmethod\n+    def _tnl_action_decoder(cls):\n+        return {\n+            \"tnl_push\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"tnl_port\": decode_int,\n+                        \"header\": nested_kv_decoder(\n+                            KVDecoders(\n+                                {\n+                                    \"size\": decode_int,\n+                                    \"type\": decode_int,\n+                                    \"eth\": nested_kv_decoder(\n+                                        KVDecoders(\n+                                            {\n+                                                \"src\": EthMask,\n+                                                \"dst\": EthMask,\n+                                                \"dl_type\": decode_int,\n+                                            }\n+                                        )\n+                                    ),\n+                                    \"ipv4\": nested_kv_decoder(\n+                                        KVDecoders(\n+                                            {\n+                                                \"src\": IPMask,\n+                                                \"dst\": IPMask,\n+                                                \"proto\": decode_int,\n+                                                \"tos\": decode_int,\n+                                                \"ttl\": decode_int,\n+                                                \"frag\": decode_int,\n+                                            }\n+                                        )\n+                                    ),\n+                                    \"ipv6\": nested_kv_decoder(\n+                                        KVDecoders(\n+                                            {\n+                                                \"src\": IPMask,\n+                                                \"dst\": IPMask,\n+                                                \"label\": decode_int,\n+                                                \"proto\": decode_int,\n+                                                \"tclass\": decode_int,\n+                                                \"hlimit\": decode_int,\n+                                            }\n+                                        )\n+                                    ),\n+                                    \"udp\": nested_kv_decoder(\n+                                        KVDecoders(\n+                                            {\n+                                                \"src\": decode_int,\n+                                                \"dst\": decode_int,\n+                                                \"dsum\": Mask16,\n+                                            }\n+                                        )\n+                                    ),\n+                                    \"vxlan\": nested_kv_decoder(\n+                                        KVDecoders(\n+                                            {\n+                                                \"flags\": decode_int,\n+                                                \"vni\": decode_int,\n+                                            }\n+                                        )\n+                                    ),\n+                                    \"geneve\": nested_kv_decoder(\n+                                        KVDecoders(\n+                                            {\n+                                                \"oam\": decode_flag,\n+                                                \"crit\": decode_flag,\n+                                                \"vni\": decode_int,\n+                                                \"options\": partial(\n+                                                    decode_geneve, False\n+                                                ),\n+                                            }\n+                                        )\n+                                    ),\n+                                    \"gre\": decode_tnl_gre,\n+                                    \"erspan\": nested_kv_decoder(\n+                                        KVDecoders(\n+                                            {\n+                                                \"ver\": decode_int,\n+                                                \"sid\": decode_int,\n+                                                \"idx\": decode_int,\n+                                                \"sid\": decode_int,\n+                                                \"dir\": decode_int,\n+                                                \"hwid\": decode_int,\n+                                            }\n+                                        )\n+                                    ),\n+                                    \"gtpu\": nested_kv_decoder(\n+                                        KVDecoders(\n+                                            {\n+                                                \"flags\": decode_int,\n+                                                \"msgtype\": decode_int,\n+                                                \"teid\": decode_int,\n+                                            }\n+                                        )\n+                                    ),\n+                                }\n+                            )\n+                        ),\n+                        \"out_port\": decode_int,\n+                    }\n+                )\n+            )\n+        }\n+\n+    @classmethod\n+    def _info_decoders(cls):\n+        return {\n+            \"packets\": decode_int,\n+            \"bytes\": decode_int,\n+            \"used\": decode_time,\n+            \"flags\": decode_default,\n+            \"dp\": decode_default,\n+        }\n+\n+    @classmethod\n+    def _match_decoders(cls):\n+        return {\n+            **cls._field_decoders(),\n+            \"encap\": nested_kv_decoder(KVDecoders(cls._field_decoders())),\n+        }\n+\n+    @classmethod\n+    def _field_decoders(cls):\n+        return {\n+            \"skb_priority\": Mask32,\n+            \"skb_mark\": Mask32,\n+            \"recirc_id\": decode_int,\n+            \"dp_hash\": Mask32,\n+            \"ct_state\": decode_default,  # TODO: Parse flags\n+            \"ct_zone\": Mask16,\n+            \"ct_mark\": Mask32,\n+            \"ct_label\": Mask128,\n+            \"ct_tuple4\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"src\": IPMask,\n+                        \"dst\": IPMask,\n+                        \"proto\": Mask8,\n+                        \"tcp_src\": Mask16,\n+                        \"tcp_dst\": Mask16,\n+                    }\n+                )\n+            ),\n+            \"ct_tuple6\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"src\": IPMask,\n+                        \"dst\": IPMask,\n+                        \"proto\": Mask8,\n+                        \"tcp_src\": Mask16,\n+                        \"tcp_dst\": Mask16,\n+                    }\n+                )\n+            ),\n+            \"tunnel\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"tun_id\": Mask64,\n+                        \"src\": IPMask,\n+                        \"dst\": IPMask,\n+                        \"ipv6_src\": IPMask,\n+                        \"ipv6_dst\": IPMask,\n+                        \"tos\": Mask8,\n+                        \"ttl\": Mask8,\n+                        \"tp_src\": Mask16,\n+                        \"tp_dst\": Mask16,\n+                        \"erspan\": nested_kv_decoder(\n+                            KVDecoders(\n+                                {\n+                                    \"ver\": Mask8,\n+                                    \"idx\": Mask32,\n+                                    \"sid\": decode_int,\n+                                    \"dir\": Mask8,\n+                                    \"hwid\": Mask8,\n+                                }\n+                            )\n+                        ),\n+                        \"vxlan\": nested_kv_decoder(\n+                            KVDecoders(\n+                                {\n+                                    \"gbp\": nested_kv_decoder(\n+                                        KVDecoders(\n+                                            {\n+                                                \"id\": Mask16,\n+                                                \"flags\": Mask8,\n+                                            }\n+                                        )\n+                                    )\n+                                }\n+                            )\n+                        ),\n+                        \"geneve\": partial(decode_geneve, True),\n+                        \"gtpu\": nested_kv_decoder(\n+                            KVDecoders(\n+                                {\n+                                    \"flags\": Mask8,\n+                                    \"msgtype\": Mask8,\n+                                }\n+                            )\n+                        ),\n+                        \"flags\": decode_default,\n+                    }\n+                )\n+            ),\n+            \"in_port\": decode_default,\n+            \"eth\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"src\": EthMask,\n+                        \"dst\": EthMask,\n+                    }\n+                )\n+            ),\n+            \"vlan\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"vid\": Mask16,\n+                        \"pcp\": Mask16,\n+                        \"cfi\": Mask16,\n+                    }\n+                )\n+            ),\n+            \"eth_type\": Mask16,\n+            \"mpls\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"label\": Mask32,\n+                        \"tc\": Mask32,\n+                        \"ttl\": Mask32,\n+                        \"bos\": Mask32,\n+                    }\n+                )\n+            ),\n+            \"ipv4\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"src\": IPMask,\n+                        \"dst\": IPMask,\n+                        \"proto\": Mask8,\n+                        \"tos\": Mask8,\n+                        \"ttl\": Mask8,\n+                        \"frag\": decode_default,\n+                    }\n+                )\n+            ),\n+            \"ipv6\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"src\": IPMask,\n+                        \"dst\": IPMask,\n+                        \"label\": decode_mask(20),\n+                        \"proto\": Mask8,\n+                        \"tclass\": Mask8,\n+                        \"hlimit\": Mask8,\n+                        \"frag\": decode_default,\n+                    }\n+                )\n+            ),\n+            \"tcp\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"src\": Mask16,\n+                        \"dst\": Mask16,\n+                    }\n+                )\n+            ),\n+            \"tcp_flags\": decode_default,\n+            \"udp\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"src\": Mask16,\n+                        \"dst\": Mask16,\n+                    }\n+                )\n+            ),\n+            \"sctp\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"src\": Mask16,\n+                        \"dst\": Mask16,\n+                    }\n+                )\n+            ),\n+            \"icmp\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"type\": Mask8,\n+                        \"code\": Mask8,\n+                    }\n+                )\n+            ),\n+            \"icmpv6\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"type\": Mask8,\n+                        \"code\": Mask8,\n+                    }\n+                )\n+            ),\n+            \"arp\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"sip\": IPMask,\n+                        \"tip\": IPMask,\n+                        \"op\": Mask16,\n+                        \"sha\": EthMask,\n+                        \"tha\": EthMask,\n+                    }\n+                )\n+            ),\n+            \"nd\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"target\": IPMask,\n+                        \"sll\": EthMask,\n+                        \"tll\": EthMask,\n+                    }\n+                )\n+            ),\n+            \"nd_ext\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"nd_reserved\": Mask32,\n+                        \"nd_options_type\": Mask8,\n+                    }\n+                )\n+            ),\n+            \"packet_type\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"ns\": Mask16,\n+                        \"id\": Mask16,\n+                    }\n+                )\n+            ),\n+            \"nsh\": nested_kv_decoder(\n+                KVDecoders(\n+                    {\n+                        \"flags\": Mask8,\n+                        \"mdtype\": Mask8,\n+                        \"np\": Mask8,\n+                        \"spi\": Mask32,\n+                        \"si\": Mask8,\n+                        \"c1\": Mask32,\n+                        \"c2\": Mask32,\n+                        \"c3\": Mask32,\n+                        \"c4\": Mask32,\n+                    }\n+                )\n+            ),\n+        }\n+\n+\n+def decode_geneve(mask, value):\n+    \"\"\"\n+    Decode geneve options. Used for both tnl_push(header(geneve(options())))\n+    action and tunnel(geneve()) match.\n+\n+    It has the following format:\n+\n+    {class=0xffff,type=0x80,len=4,0xa}\n+\n+    Args:\n+        mask (bool): Whether masking is supported\n+        value (str): The value to decode\n+    \"\"\"\n+    if mask:\n+        decoders = {\n+            \"class\": Mask16,\n+            \"type\": Mask8,\n+            \"len\": Mask8,\n+        }\n+\n+        def free_decoder(value):\n+            return \"data\", Mask128(value)\n+\n+    else:\n+        decoders = {\n+            \"class\": decode_int,\n+            \"type\": decode_int,\n+            \"len\": decode_int,\n+        }\n+\n+        def free_decoder(value):\n+            return \"data\", decode_int(value)\n+\n+    result = []\n+    for opts in re.findall(r\"{.*?}\", value):\n+        result.append(\n+            decode_nested_kv(\n+                KVDecoders(decoders=decoders, default_free=free_decoder),\n+                opts.strip(\"{}\"),\n+            )\n+        )\n+    return result\n+\n+\n+def decode_tnl_gre(value):\n+    \"\"\"\n+    Decode tnl_push(header(gre())) action\n+\n+    It has the following format:\n+\n+    gre((flags=0x2000,proto=0x6558),key=0x1e241))\n+\n+    Args:\n+        value (str): The value to decode\n+    \"\"\"\n+\n+    return decode_nested_kv(\n+        KVDecoders(\n+            {\n+                \"flags\": decode_int,\n+                \"proto\": decode_int,\n+                \"key\": decode_int,\n+                \"csum\": decode_int,\n+                \"seq\": decode_int,\n+            }\n+        ),\n+        value.replace(\"(\", \"\").replace(\")\", \"\"),\n+    )\n",
    "prefixes": [
        "ovs-dev",
        "v1",
        "08/18"
    ]
}