get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.1/patches/2220551/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2220551,
    "url": "http://patchwork.ozlabs.org/api/1.1/patches/2220551/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/1fdde3bfd9bac1f24ec54d9feae9c704ee92df07.1775568640.git.tredaelli@redhat.com/",
    "project": {
        "id": 47,
        "url": "http://patchwork.ozlabs.org/api/1.1/projects/47/?format=api",
        "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"
    },
    "msgid": "<1fdde3bfd9bac1f24ec54d9feae9c704ee92df07.1775568640.git.tredaelli@redhat.com>",
    "date": "2026-04-07T13:34:34",
    "name": "[ovs-dev,v2,5/5] dpctl: Add JSON output to dpctl/show.",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "9b59708f6aafa16b145671fd2344b3f8a5f1d071",
    "submitter": {
        "id": 70949,
        "url": "http://patchwork.ozlabs.org/api/1.1/people/70949/?format=api",
        "name": "Timothy Redaelli",
        "email": "tredaelli@redhat.com"
    },
    "delegate": {
        "id": 75123,
        "url": "http://patchwork.ozlabs.org/api/1.1/users/75123/?format=api",
        "username": "echaudron",
        "first_name": "Eelco",
        "last_name": "Chaudron",
        "email": "echaudro@redhat.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/1fdde3bfd9bac1f24ec54d9feae9c704ee92df07.1775568640.git.tredaelli@redhat.com/mbox/",
    "series": [
        {
            "id": 498985,
            "url": "http://patchwork.ozlabs.org/api/1.1/series/498985/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=498985",
            "date": "2026-04-07T13:34:24",
            "name": "Add JSON output to several ovs-appctl commands",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/498985/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2220551/comments/",
    "check": "fail",
    "checks": "http://patchwork.ozlabs.org/api/patches/2220551/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<ovs-dev-bounces@openvswitch.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "dev@openvswitch.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@legolas.ozlabs.org",
            "ovs-dev@lists.linuxfoundation.org"
        ],
        "Authentication-Results": [
            "legolas.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=Q8GXly6G;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org)",
            "smtp2.osuosl.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key)\n header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=Q8GXly6G",
            "smtp1.osuosl.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com",
            "smtp1.osuosl.org;\n dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com\n header.a=rsa-sha256 header.s=mimecast20190719 header.b=Q8GXly6G"
        ],
        "Received": [
            "from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fqnKC1yTLz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 07 Apr 2026 23:36:15 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby smtp2.osuosl.org (Postfix) with ESMTP id E225840681;\n\tTue,  7 Apr 2026 13:36:13 +0000 (UTC)",
            "from smtp2.osuosl.org ([127.0.0.1])\n by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id I8yLjAYuJwW0; Tue,  7 Apr 2026 13:36:12 +0000 (UTC)",
            "from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56])\n\tby smtp2.osuosl.org (Postfix) with ESMTPS id AE7954065E;\n\tTue,  7 Apr 2026 13:36:12 +0000 (UTC)",
            "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 8D2B1C04FB;\n\tTue,  7 Apr 2026 13:36:12 +0000 (UTC)",
            "from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 1E28BC04FB\n for <dev@openvswitch.org>; Tue,  7 Apr 2026 13:36:11 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n by smtp1.osuosl.org (Postfix) with ESMTP id BAC6E81191\n for <dev@openvswitch.org>; Tue,  7 Apr 2026 13:35:56 +0000 (UTC)",
            "from smtp1.osuosl.org ([127.0.0.1])\n by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id h6qvGZRd2whO for <dev@openvswitch.org>;\n Tue,  7 Apr 2026 13:35:55 +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 94BF08116C\n for <dev@openvswitch.org>; Tue,  7 Apr 2026 13:35:55 +0000 (UTC)",
            "from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-558-oheYl3dUPMyzhO8DNZScHw-1; Tue,\n 07 Apr 2026 09:35:51 -0400",
            "from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 43A411956065; Tue,  7 Apr 2026 13:35:50 +0000 (UTC)",
            "from aldebaran.char-dominant.ts.net (unknown [10.44.34.48])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id E48071955BCC; Tue,  7 Apr 2026 13:35:48 +0000 (UTC)"
        ],
        "X-Virus-Scanned": [
            "amavis at osuosl.org",
            "amavis at osuosl.org"
        ],
        "X-Comment": "SPF check N/A for local connections - client-ip=140.211.9.56;\n helo=lists.linuxfoundation.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN> ",
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 smtp2.osuosl.org AE7954065E",
            "OpenDKIM Filter v2.11.0 smtp1.osuosl.org 94BF08116C"
        ],
        "Received-SPF": "Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124;\n helo=us-smtp-delivery-124.mimecast.com; envelope-from=tredaelli@redhat.com;\n receiver=<UNKNOWN>",
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 smtp1.osuosl.org 94BF08116C",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775568954;\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=U6Bsce6vb3np8diFg6HayUx1hHNt6FJwaNXDRvELEGs=;\n b=Q8GXly6G5lq+lFNGP2piAd+c2tNQ7GL2Hf+KmG7vPwsv367C4kz8nJdMpL8O1LnL9FZjVl\n pyrewNDzbSJqgr9r5dw7tXZekp2i4H2YZDQrHFRbmpDybueNTC0cD9OTQpnnS/1CJYC3NO\n YBi6MqqeBs6MjTrKUS/eHUdm6r9q8Fo=",
        "X-MC-Unique": "oheYl3dUPMyzhO8DNZScHw-1",
        "X-Mimecast-MFC-AGG-ID": "oheYl3dUPMyzhO8DNZScHw_1775568950",
        "To": "dev@openvswitch.org",
        "Date": "Tue,  7 Apr 2026 15:34:34 +0200",
        "Message-ID": "\n <1fdde3bfd9bac1f24ec54d9feae9c704ee92df07.1775568640.git.tredaelli@redhat.com>",
        "In-Reply-To": "<cover.1775568640.git.tredaelli@redhat.com>",
        "References": "<cover.1775568640.git.tredaelli@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.0 on 10.30.177.12",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-MFC-PROC-ID": "8p4w3DwfuTqNF_zOeW7X15N3xY6yVIO_ACKBB8OUhF4_1775568950",
        "X-Mimecast-Originator": "redhat.com",
        "Subject": "[ovs-dev] [PATCH v2 5/5] dpctl: Add JSON output to dpctl/show.",
        "X-BeenThere": "ovs-dev@openvswitch.org",
        "X-Mailman-Version": "2.1.30",
        "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>",
        "From": "Timothy Redaelli via dev <ovs-dev@openvswitch.org>",
        "Reply-To": "Timothy Redaelli <tredaelli@redhat.com>",
        "Cc": "i.maximets@ovn.org",
        "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": "When --format json is passed to ovs-appctl, dpctl/show returns a JSON\nobject keyed by datapath name.  Each entry contains \"flows\", \"lookups\"\n(hit/lost/missed), and \"ports\" (keyed by port name, each with\n\"port-number\" and \"type\").  Optional sections \"masks\" and \"cache\" are\npresent as null when the datapath does not support them.  Port \"config\"\nand \"statistics\" sub-objects are included when applicable.\n\nThe output_format field is added to struct dpctl_params so the handler\ncan select the appropriate callback (show_dpif or show_dpif_json).\nThe JSON accumulator is stored in dpctl_params.json, and the reply\nis sent by dpctl_unixctl_handler based on whether json is set.  On\nerror, the JSON object is discarded and a text error reply is sent.\n\nExample output:\n  {\"ovs-system\": {\"flows\": 0,\n                   \"lookups\": {\"hit\": 0, \"lost\": 0, \"missed\": 0},\n                   \"masks\": null, \"cache\": null,\n                   \"ports\": {\"br0\": {\"port-number\": 0,\n                                     \"type\": \"internal\"}}}}\n\nSigned-off-by: Timothy Redaelli <tredaelli@redhat.com>\n---\n NEWS           |   4 +\n lib/dpctl.c    | 203 ++++++++++++++++++++++++++++++++++++++++++++++++-\n lib/dpctl.h    |  11 +++\n tests/dpctl.at |  17 +++++\n 4 files changed, 232 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/NEWS b/NEWS\nindex 1a3044cbf..da49c67b3 100644\n--- a/NEWS\n+++ b/NEWS\n@@ -1,5 +1,9 @@\n Post-v3.7.0\n --------------------\n+   - ovs-appctl:\n+     * Added JSON output support (--format json) for fdb/stats-show,\n+       upcall/show, dpif-netdev/pmd-sleep-show, dpif-netdev/pmd-stats-show,\n+       and dpctl/show commands.\n    - Userspace datapath:\n      * ARP/ND lookups for native tunnel are now rate limited. The holdout\n        timer can be configured with 'tnl/neigh/retrans_time'.\ndiff --git a/lib/dpctl.c b/lib/dpctl.c\nindex 752168b5a..c7d6ca9e3 100644\n--- a/lib/dpctl.c\n+++ b/lib/dpctl.c\n@@ -49,6 +49,7 @@\n #include \"smap.h\"\n #include \"sset.h\"\n #include \"timeval.h\"\n+#include \"openvswitch/json.h\"\n #include \"unixctl.h\"\n #include \"util.h\"\n #include \"openvswitch/ofp-flow.h\"\n@@ -635,6 +636,185 @@ show_dpif_cache(struct dpif *dpif, struct dpctl_params *dpctl_p)\n     show_dpif_cache__(dpif, dpctl_p);\n }\n \n+static void\n+show_dpif_json(struct dpif *dpif, struct dpctl_params *dpctl_p)\n+{\n+    struct json *json_dps = dpctl_p->json;\n+    struct json *json_dp = json_object_create();\n+    struct dpif_dp_stats stats;\n+\n+    if (!dpif_get_dp_stats(dpif, &stats)) {\n+        uint64_t n_pkts = stats.n_hit + stats.n_missed;\n+        struct json *json_lookups = json_object_create();\n+\n+        json_object_put(json_lookups, \"hit\",\n+                        json_integer_create(stats.n_hit));\n+        json_object_put(json_lookups, \"lost\",\n+                        json_integer_create(stats.n_lost));\n+        json_object_put(json_lookups, \"missed\",\n+                        json_integer_create(stats.n_missed));\n+        json_object_put(json_dp, \"flows\", json_integer_create(stats.n_flows));\n+        json_object_put(json_dp, \"lookups\", json_lookups);\n+\n+        if (stats.n_masks != UINT32_MAX) {\n+            double avg = n_pkts ? (double) stats.n_mask_hit / n_pkts : 0.0;\n+            struct json *json_masks = json_object_create();\n+\n+            json_object_put(json_masks, \"hit\",\n+                            json_integer_create(stats.n_mask_hit));\n+            json_object_put(json_masks, \"hit-per-packet\",\n+                            json_real_create(avg));\n+            json_object_put(json_masks, \"total\",\n+                            json_integer_create(stats.n_masks));\n+            json_object_put(json_dp, \"masks\", json_masks);\n+        } else {\n+            json_object_put(json_dp, \"masks\", json_null_create());\n+        }\n+\n+        if (stats.n_cache_hit != UINT64_MAX) {\n+            double avg_hits = n_pkts\n+                ? (double) stats.n_cache_hit / n_pkts * 100 : 0.0;\n+            struct json *json_cache = json_object_create();\n+\n+            json_object_put(json_cache, \"hit\",\n+                            json_integer_create(stats.n_cache_hit));\n+            json_object_put(json_cache, \"hit-rate-percentage\",\n+                            json_real_create(avg_hits));\n+            json_object_put(json_dp, \"cache\", json_cache);\n+        } else {\n+            json_object_put(json_dp, \"cache\", json_null_create());\n+        }\n+    } else {\n+        json_object_put(json_dp, \"cache\", json_null_create());\n+        json_object_put(json_dp, \"flows\", json_null_create());\n+        json_object_put(json_dp, \"lookups\", json_null_create());\n+        json_object_put(json_dp, \"masks\", json_null_create());\n+    }\n+\n+    uint32_t nr_caches;\n+    if (!dpif_cache_get_supported_levels(dpif, &nr_caches) && nr_caches > 0) {\n+        struct json *json_caches = json_object_create();\n+\n+        for (int i = 0; i < nr_caches; i++) {\n+            const char *name;\n+            uint32_t size;\n+\n+            if (dpif_cache_get_name(dpif, i, &name) ||\n+                dpif_cache_get_size(dpif, i, &size)) {\n+                continue;\n+            }\n+            struct json *json_c = json_object_create();\n+\n+            json_object_put(json_c, \"size\", json_integer_create(size));\n+            json_object_put(json_caches, name, json_c);\n+        }\n+        json_object_put(json_dp, \"caches\", json_caches);\n+    }\n+\n+    struct json *json_ports = json_object_create();\n+    struct dpif_port_dump dump;\n+    struct dpif_port dpif_port;\n+    odp_port_t *port_nos = NULL;\n+    size_t allocated_port_nos = 0, n_port_nos = 0;\n+\n+    DPIF_PORT_FOR_EACH (&dpif_port, &dump, dpif) {\n+        if (n_port_nos >= allocated_port_nos) {\n+            port_nos = x2nrealloc(port_nos, &allocated_port_nos,\n+                                  sizeof *port_nos);\n+        }\n+        port_nos[n_port_nos++] = dpif_port.port_no;\n+    }\n+\n+    if (port_nos) {\n+        qsort(port_nos, n_port_nos, sizeof *port_nos, compare_port_nos);\n+    }\n+\n+    for (int i = 0; i < n_port_nos; i++) {\n+        struct netdev *netdev;\n+\n+        if (dpif_port_query_by_number(dpif, port_nos[i], &dpif_port, true)) {\n+            continue;\n+        }\n+\n+        struct json *json_port = json_object_create();\n+\n+        json_object_put(json_port, \"port-number\",\n+                        json_integer_create(odp_to_u32(dpif_port.port_no)));\n+        json_object_put_string(json_port, \"type\", dpif_port.type);\n+\n+        if (strcmp(dpif_port.type, \"system\")) {\n+            int error = netdev_open(dpif_port.name, dpif_port.type, &netdev);\n+\n+            if (!error) {\n+                struct smap config;\n+\n+                smap_init(&config);\n+                if (!netdev_get_config(netdev, &config) &&\n+                    smap_count(&config) > 0) {\n+                    json_object_put(json_port, \"config\",\n+                                    smap_to_json(&config));\n+                }\n+                smap_destroy(&config);\n+                netdev_close(netdev);\n+            }\n+        }\n+\n+        if (dpctl_p->print_statistics) {\n+            struct netdev_stats s;\n+            int error = netdev_open(dpif_port.name, dpif_port.type, &netdev);\n+\n+            if (!error) {\n+                error = netdev_get_stats(netdev, &s);\n+                netdev_close(netdev);\n+                if (!error) {\n+                    struct json *json_stats = json_object_create();\n+\n+                    json_object_put(json_stats, \"collisions\",\n+                                    json_integer_create(s.collisions));\n+                    json_object_put(json_stats, \"rx-bytes\",\n+                                    json_integer_create(s.rx_bytes));\n+                    json_object_put(json_stats, \"rx-dropped\",\n+                                    json_integer_create(s.rx_dropped));\n+                    json_object_put(json_stats, \"rx-errors\",\n+                                    json_integer_create(s.rx_errors));\n+                    json_object_put(json_stats, \"rx-frame-errors\",\n+                                    json_integer_create(s.rx_frame_errors));\n+                    json_object_put(json_stats, \"rx-over-errors\",\n+                                    json_integer_create(s.rx_over_errors));\n+                    json_object_put(json_stats, \"rx-packets\",\n+                                    json_integer_create(s.rx_packets));\n+                    json_object_put(json_stats, \"tx-aborted-errors\",\n+                                    json_integer_create(s.tx_aborted_errors));\n+                    json_object_put(json_stats, \"tx-bytes\",\n+                                    json_integer_create(s.tx_bytes));\n+                    json_object_put(json_stats, \"tx-carrier-errors\",\n+                                    json_integer_create(s.tx_carrier_errors));\n+                    json_object_put(json_stats, \"tx-dropped\",\n+                                    json_integer_create(s.tx_dropped));\n+                    json_object_put(json_stats, \"tx-errors\",\n+                                    json_integer_create(s.tx_errors));\n+                    json_object_put(json_stats, \"tx-packets\",\n+                                    json_integer_create(s.tx_packets));\n+                    json_object_put(json_stats, \"upcall-errors\",\n+                                    json_integer_create(s.upcall_errors));\n+                    json_object_put(json_stats, \"upcall-packets\",\n+                                    json_integer_create(s.upcall_packets));\n+                    json_object_put(json_port, \"statistics\", json_stats);\n+                }\n+            }\n+        } else {\n+            json_object_put(json_port, \"statistics\", json_null_create());\n+        }\n+\n+        json_object_put(json_ports, dpif_port.name, json_port);\n+        dpif_port_destroy(&dpif_port);\n+    }\n+\n+    free(port_nos);\n+    json_object_put(json_dp, \"ports\", json_ports);\n+    json_object_put(json_dps, dpif_name(dpif), json_dp);\n+}\n+\n static void\n show_dpif(struct dpif *dpif, struct dpctl_params *dpctl_p)\n {\n@@ -833,6 +1013,15 @@ static int\n dpctl_show(int argc, const char *argv[], struct dpctl_params *dpctl_p)\n {\n     int error, lasterror = 0;\n+    dps_for_each_cb cb;\n+\n+    if (dpctl_p->output_format == UNIXCTL_OUTPUT_FMT_JSON) {\n+        dpctl_p->json = json_object_create();\n+        cb = show_dpif_json;\n+    } else {\n+        cb = show_dpif;\n+    }\n+\n     if (argc > 1) {\n         int i;\n         for (i = 1; i < argc; i++) {\n@@ -841,7 +1030,7 @@ dpctl_show(int argc, const char *argv[], struct dpctl_params *dpctl_p)\n \n             error = parsed_dpif_open(name, false, &dpif);\n             if (!error) {\n-                show_dpif(dpif, dpctl_p);\n+                cb(dpif, dpctl_p);\n                 dpif_close(dpif);\n             } else {\n                 dpctl_error(dpctl_p, error, \"opening datapath %s failed\",\n@@ -850,7 +1039,7 @@ dpctl_show(int argc, const char *argv[], struct dpctl_params *dpctl_p)\n             }\n         }\n     } else {\n-        lasterror = dps_for_each(dpctl_p, show_dpif);\n+        lasterror = dps_for_each(dpctl_p, cb);\n     }\n \n     return lasterror;\n@@ -3153,6 +3342,7 @@ dpctl_unixctl_handler(struct unixctl_conn *conn, int argc, const char *argv[],\n         .is_appctl = true,\n         .output = dpctl_unixctl_print,\n         .aux = &ds,\n+        .output_format = unixctl_command_get_output_format(conn),\n     };\n \n     /* Parse options (like getopt). Unfortunately it does\n@@ -3220,7 +3410,14 @@ dpctl_unixctl_handler(struct unixctl_conn *conn, int argc, const char *argv[],\n         error = handler(argc, argv, &dpctl_p) != 0;\n     }\n \n-    if (error) {\n+    if (dpctl_p.json) {\n+        if (error) {\n+            json_destroy(dpctl_p.json);\n+            unixctl_command_reply_error(conn, ds_cstr(&ds));\n+        } else {\n+            unixctl_command_reply_json(conn, dpctl_p.json);\n+        }\n+    } else if (error) {\n         unixctl_command_reply_error(conn, ds_cstr(&ds));\n     } else {\n         unixctl_command_reply(conn, ds_cstr(&ds));\ndiff --git a/lib/dpctl.h b/lib/dpctl.h\nindex 9d0052152..fe475471e 100644\n--- a/lib/dpctl.h\n+++ b/lib/dpctl.h\n@@ -19,6 +19,9 @@\n #include <stdbool.h>\n \n #include \"compiler.h\"\n+#include \"unixctl.h\"\n+\n+struct json;\n \n struct dpctl_params {\n     /* True if it is called by ovs-appctl command. */\n@@ -51,6 +54,14 @@ struct dpctl_params {\n \n     /* 'usage' (if != NULL) gets called for the \"help\" command. */\n     void (*usage)(void *aux);\n+\n+    /* Output format requested by the caller. */\n+    enum unixctl_output_fmt output_format;\n+\n+    /* JSON object for accumulating structured output.  Command handlers\n+     * set this to a non-NULL value when producing JSON output; the caller\n+     * uses it to decide whether to send a JSON or text reply. */\n+    struct json *json;\n };\n \n int dpctl_run_command(int argc, const char *argv[],\ndiff --git a/tests/dpctl.at b/tests/dpctl.at\nindex a87f67f98..5e1d20e00 100644\n--- a/tests/dpctl.at\n+++ b/tests/dpctl.at\n@@ -25,6 +25,23 @@ dummy@br0:\n   flows: 0\n   port 0: br0 (dummy-internal)\n ])\n+dnl Check dpctl/show JSON output.\n+AT_CHECK([ovs-appctl --format json --pretty dpctl/show dummy@br0], [0], [dnl\n+{\n+  \"dummy@br0\": {\n+    \"cache\": null,\n+    \"flows\": 0,\n+    \"lookups\": {\n+      \"hit\": 0,\n+      \"lost\": 0,\n+      \"missed\": 0},\n+    \"masks\": null,\n+    \"ports\": {\n+      \"br0\": {\n+        \"port-number\": 0,\n+        \"statistics\": null,\n+        \"type\": \"dummy-internal\"}}}}\n+])\n AT_CHECK([ovs-appctl dpctl/add-if dummy@br0 vif1.0,type=dummy,port_no=5])\n AT_CHECK([ovs-appctl dpctl/show dummy@br0], [0], [dnl\n dummy@br0:\n",
    "prefixes": [
        "ovs-dev",
        "v2",
        "5/5"
    ]
}