get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2194223,
    "url": "http://patchwork.ozlabs.org/api/patches/2194223/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260207134728.1495932-4-lulu@redhat.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260207134728.1495932-4-lulu@redhat.com>",
    "list_archive_url": null,
    "date": "2026-02-07T13:47:20",
    "name": "[04/12] net/filter-mirror: add indev/outdev statistics for filter-redirector",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "41481295c25b2fe4b846a85312402c1c6aec4e61",
    "submitter": {
        "id": 78960,
        "url": "http://patchwork.ozlabs.org/api/people/78960/?format=api",
        "name": "Cindy Lu",
        "email": "lulu@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260207134728.1495932-4-lulu@redhat.com/mbox/",
    "series": [
        {
            "id": 491379,
            "url": "http://patchwork.ozlabs.org/api/series/491379/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=491379",
            "date": "2026-02-07T13:47:17",
            "name": "[01/12] net: introduce read_poll/write_poll",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/491379/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2194223/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2194223/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=BADEuUmj;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4f7XPY4117z1xtV\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 08 Feb 2026 00:49:21 +1100 (AEDT)",
            "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1voifZ-00038q-8W; Sat, 07 Feb 2026 08:48:18 -0500",
            "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <lulu@redhat.com>) id 1voifO-00031D-5m\n for qemu-devel@nongnu.org; Sat, 07 Feb 2026 08:48:07 -0500",
            "from us-smtp-delivery-124.mimecast.com ([170.10.129.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <lulu@redhat.com>) id 1voifK-0003DS-VK\n for qemu-devel@nongnu.org; Sat, 07 Feb 2026 08:48:04 -0500",
            "from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-593-zgkR_ncjMFObe-pHrwB92A-1; Sat,\n 07 Feb 2026 08:47:58 -0500",
            "from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93])\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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 9CBBF18003FC; Sat,  7 Feb 2026 13:47:57 +0000 (UTC)",
            "from S2.redhat.com (unknown [10.72.112.15])\n by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 8096618004AD; Sat,  7 Feb 2026 13:47:54 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1770472082;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=pqeiNPZr2xEEOl1HXgVWwToeoJpI5kf9x7HKvwPSlNA=;\n b=BADEuUmjOK9uIFhRQl3RoloFk768wpFha6IxbOQFZHOgeywRnu3x21Mlohs0wgA6gRWXQq\n IE+h7S74gvCTJK475wHgof6VtodR2uX/wSp3qq+wJzWxozsvCzDCWbkFjt7npVXlXcc1hu\n f8pwAeamgIXDPoLAd+85ZIWmhg6i3Tk=",
        "X-MC-Unique": "zgkR_ncjMFObe-pHrwB92A-1",
        "X-Mimecast-MFC-AGG-ID": "zgkR_ncjMFObe-pHrwB92A_1770472077",
        "From": "Cindy Lu <lulu@redhat.com>",
        "To": "lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, zhangckid@gmail.com,\n lizhijian@fujitsu.com, qemu-devel@nongnu.org",
        "Subject": "[PATCH 04/12] net/filter-mirror: add indev/outdev statistics for\n filter-redirector",
        "Date": "Sat,  7 Feb 2026 21:47:20 +0800",
        "Message-ID": "<20260207134728.1495932-4-lulu@redhat.com>",
        "In-Reply-To": "<20260207134728.1495932-1-lulu@redhat.com>",
        "References": "<20260207134728.1495932-1-lulu@redhat.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.93",
        "Received-SPF": "pass client-ip=170.10.129.124; envelope-from=lulu@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com",
        "X-Spam_score_int": "-20",
        "X-Spam_score": "-2.1",
        "X-Spam_bar": "--",
        "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,\n RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no",
        "X-Spam_action": "no action",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "qemu development <qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"
    },
    "content": "From: Jason Wang <jasowang@redhat.com>\n\nAdd packet and byte counters for filter-redirector's indev and outdev\ncharacter devices:\n\n- indev_packets/indev_bytes: count packets/bytes received from indev\n- outdev_packets/outdev_bytes: count packets/bytes sent to outdev\n\nThe indev counters are updated in redirector_rs_finalize() when a\ncomplete packet is read from indev. The outdev counters are updated\nin filter_redirector_receive_iov() when data is successfully sent\nto outdev.\n\nDesign changes:\n- Add FilterGetStats callback to NetFilterClass, allowing each filter\n  type to implement its own statistics collection\n- Introduce a flexible 'counters' array in NetFilterStats (QAPI) to\n  allow different filter types to expose their own specific counters\n- net.c uses the callback instead of directly calling filter-specific\n  functions, improving modularity\n\nThe QMP query-netfilter-stats command and HMP info netfilter-stats\ncommand now include the optional counters array for filters that\nimplement the get_stats callback.\n\nExample output:\n  (qemu) info netfilter-stats\n  rd0: netdev=bn0 type=filter-redirector\n    tx: 5 packets, 500 bytes\n    rx: 0 packets, 0 bytes\n    indev: 3 packets, 300 bytes\n    outdev: 5 packets, 500 bytes\n\nSigned-off-by: Jason Wang <jasowang@redhat.com>\nSigned-off-by: Cindy Lu <lulu@redhat.com>\n---\n include/net/filter.h |  8 ++++++++\n net/filter-mirror.c  | 42 ++++++++++++++++++++++++++++++++++++++++--\n net/net-hmp-cmds.c   | 10 ++++++++++\n net/net.c            | 28 ++++++++++++++++++++++++++++\n qapi/net.json        | 25 ++++++++++++++++++++++++-\n 5 files changed, 110 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/include/net/filter.h b/include/net/filter.h\nindex 04786e4e87..f0673c9163 100644\n--- a/include/net/filter.h\n+++ b/include/net/filter.h\n@@ -35,6 +35,13 @@ typedef void (FilterStatusChanged) (NetFilterState *nf, Error **errp);\n \n typedef void (FilterHandleEvent) (NetFilterState *nf, int event, Error **errp);\n \n+/*\n+ * Get filter-specific statistics counters.\n+ * Returns a GList of NetFilterCounter (QAPI type), or NULL if no counters.\n+ * The caller is responsible for freeing the returned list and its contents.\n+ */\n+typedef GList *(FilterGetStats) (NetFilterState *nf);\n+\n struct NetFilterClass {\n     ObjectClass parent_class;\n \n@@ -43,6 +50,7 @@ struct NetFilterClass {\n     FilterCleanup *cleanup;\n     FilterStatusChanged *status_changed;\n     FilterHandleEvent *handle_event;\n+    FilterGetStats *get_stats;\n     /* mandatory */\n     FilterReceiveIOV *receive_iov;\n };\ndiff --git a/net/filter-mirror.c b/net/filter-mirror.c\nindex e1a0650abd..21598b97a7 100644\n--- a/net/filter-mirror.c\n+++ b/net/filter-mirror.c\n@@ -11,8 +11,12 @@\n \n #include \"qemu/osdep.h\"\n #include \"net/filter.h\"\n+#define TYPE_FILTER_MIRROR \"filter-mirror\"\n+#define TYPE_FILTER_REDIRECTOR \"filter-redirector\"\n+\n #include \"net/net.h\"\n #include \"qapi/error.h\"\n+#include \"qapi/qapi-types-net.h\"\n #include \"qom/object.h\"\n #include \"qemu/main-loop.h\"\n #include \"qemu/error-report.h\"\n@@ -23,12 +27,10 @@\n #include \"block/aio-wait.h\"\n #include \"system/runstate.h\"\n \n-#define TYPE_FILTER_MIRROR \"filter-mirror\"\n typedef struct MirrorState MirrorState;\n DECLARE_INSTANCE_CHECKER(MirrorState, FILTER_MIRROR,\n                          TYPE_FILTER_MIRROR)\n \n-#define TYPE_FILTER_REDIRECTOR \"filter-redirector\"\n DECLARE_INSTANCE_CHECKER(MirrorState, FILTER_REDIRECTOR,\n                          TYPE_FILTER_REDIRECTOR)\n \n@@ -44,6 +46,12 @@ struct MirrorState {\n     bool vnet_hdr;\n     bool enable_when_stopped;\n     VMChangeStateEntry *vmsentry;\n+\n+    /* indev/outdev statistics for filter-redirector */\n+    uint64_t indev_packets;\n+    uint64_t indev_bytes;\n+    uint64_t outdev_packets;\n+    uint64_t outdev_bytes;\n };\n \n typedef struct FilterSendCo {\n@@ -234,6 +242,10 @@ static ssize_t filter_redirector_receive_iov(NetFilterState *nf,\n         ret = filter_send(s, iov, iovcnt);\n         if (ret < 0) {\n             error_report(\"filter redirector send failed(%s)\", strerror(-ret));\n+        } else if (ret > 0) {\n+            /* Update outdev statistics on successful send */\n+            s->outdev_packets++;\n+            s->outdev_bytes += ret;\n         }\n         return ret;\n     } else {\n@@ -283,6 +295,10 @@ static void redirector_rs_finalize(SocketReadState *rs)\n     MirrorState *s = container_of(rs, MirrorState, rs);\n     NetFilterState *nf = NETFILTER(s);\n \n+    /* Update indev statistics */\n+    s->indev_packets++;\n+    s->indev_bytes += rs->packet_len;\n+\n     redirector_to_filter(nf, rs->buf, rs->packet_len);\n }\n \n@@ -487,6 +503,27 @@ static void filter_mirror_class_init(ObjectClass *oc, const void *data)\n     nfc->receive_iov = filter_mirror_receive_iov;\n }\n \n+static GList *filter_redirector_get_stats(NetFilterState *nf)\n+{\n+    MirrorState *s = FILTER_REDIRECTOR(nf);\n+    GList *list = NULL;\n+    NetFilterCounter *counter;\n+\n+    counter = g_new0(NetFilterCounter, 1);\n+    counter->name = g_strdup(\"indev\");\n+    counter->packets = s->indev_packets;\n+    counter->bytes = s->indev_bytes;\n+    list = g_list_append(list, counter);\n+\n+    counter = g_new0(NetFilterCounter, 1);\n+    counter->name = g_strdup(\"outdev\");\n+    counter->packets = s->outdev_packets;\n+    counter->bytes = s->outdev_bytes;\n+    list = g_list_append(list, counter);\n+\n+    return list;\n+}\n+\n static void filter_redirector_class_init(ObjectClass *oc, const void *data)\n {\n     NetFilterClass *nfc = NETFILTER_CLASS(oc);\n@@ -506,6 +543,7 @@ static void filter_redirector_class_init(ObjectClass *oc, const void *data)\n     nfc->cleanup = filter_redirector_cleanup;\n     nfc->receive_iov = filter_redirector_receive_iov;\n     nfc->status_changed = filter_redirector_status_changed;\n+    nfc->get_stats = filter_redirector_get_stats;\n }\n \n static void filter_mirror_init(Object *obj)\ndiff --git a/net/net-hmp-cmds.c b/net/net-hmp-cmds.c\nindex 9bdd6d233f..df9336be1e 100644\n--- a/net/net-hmp-cmds.c\n+++ b/net/net-hmp-cmds.c\n@@ -192,6 +192,16 @@ void hmp_info_netfilter_stats(Monitor *mon, const QDict *qdict)\n                        stats->packets_tx, stats->bytes_tx);\n         monitor_printf(mon, \"  rx: %\" PRIu64 \" packets, %\" PRIu64 \" bytes\\n\",\n                        stats->packets_rx, stats->bytes_rx);\n+        if (stats->counters) {\n+            NetFilterCounterList *counter_entry;\n+            for (counter_entry = stats->counters; counter_entry;\n+                 counter_entry = counter_entry->next) {\n+                NetFilterCounter *counter = counter_entry->value;\n+                monitor_printf(mon,\n+                               \"  %s: %\" PRIu64 \" packets, %\" PRIu64 \" bytes\\n\",\n+                               counter->name, counter->packets, counter->bytes);\n+            }\n+        }\n     }\n \n     qapi_free_NetFilterStatsList(stats_list);\ndiff --git a/net/net.c b/net/net.c\nindex 40966fbf8a..b15f4db65e 100644\n--- a/net/net.c\n+++ b/net/net.c\n@@ -1631,6 +1631,34 @@ NetFilterStatsList *qmp_query_netfilter_stats(const char *name, Error **errp)\n             stats->bytes_tx = nf->bytes_tx;\n             stats->bytes_rx = nf->bytes_rx;\n \n+            /* Get filter-specific counters via callback */\n+            {\n+                NetFilterClass *nfc = NETFILTER_GET_CLASS(nf);\n+                if (nfc->get_stats) {\n+                    GList *filter_counters = nfc->get_stats(nf);\n+                    GList *iter;\n+\n+                    for (iter = filter_counters; iter; iter = iter->next) {\n+                        NetFilterCounter *fc = iter->data;\n+                        NetFilterCounter *counter;\n+\n+                        counter = g_new0(NetFilterCounter, 1);\n+                        counter->name = g_strdup(fc->name);\n+                        counter->packets = fc->packets;\n+                        counter->bytes = fc->bytes;\n+                        QAPI_LIST_PREPEND(stats->counters, counter);\n+\n+                        g_free(fc->name);\n+                        g_free(fc);\n+                    }\n+                    g_list_free(filter_counters);\n+\n+                    if (stats->counters) {\n+                        stats->has_counters = true;\n+                    }\n+                }\n+            }\n+\n             QAPI_LIST_APPEND(tail, stats);\n \n             if (name) {\ndiff --git a/qapi/net.json b/qapi/net.json\nindex 277cdd9e32..c57497d328 100644\n--- a/qapi/net.json\n+++ b/qapi/net.json\n@@ -1192,6 +1192,25 @@\n { 'event': 'NETDEV_VHOST_USER_DISCONNECTED',\n   'data': { 'netdev-id': 'str' } }\n \n+##\n+# @NetFilterCounter:\n+#\n+# A filter-specific counter with packet and byte counts.\n+#\n+# @name: the name of the counter (e.g., \"indev\", \"outdev\")\n+#\n+# @packets: number of packets\n+#\n+# @bytes: number of bytes\n+#\n+# Since: 10.1\n+##\n+{ 'struct': 'NetFilterCounter',\n+  'data': {\n+    'name':    'str',\n+    'packets': 'uint64',\n+    'bytes':   'uint64' } }\n+\n ##\n # @NetFilterStats:\n #\n@@ -1211,6 +1230,9 @@\n #\n # @bytes-rx: number of received bytes\n #\n+# @counters: filter-specific counters (optional, depends on\n+#     filter type)\n+#\n # Since: 10.1\n ##\n { 'struct': 'NetFilterStats',\n@@ -1221,7 +1243,8 @@\n     'packets-tx': 'uint64',\n     'packets-rx': 'uint64',\n     'bytes-tx':   'uint64',\n-    'bytes-rx':   'uint64' } }\n+    'bytes-rx':   'uint64',\n+    '*counters':  ['NetFilterCounter'] } }\n \n ##\n # @query-netfilter-stats:\n",
    "prefixes": [
        "04/12"
    ]
}