{"id":2220547,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2220547/?format=json","web_url":"http://patchwork.ozlabs.org/project/openvswitch/patch/a23f5fc994cc5b454acc5a57225b498d97ec5ac3.1775568640.git.tredaelli@redhat.com/","project":{"id":47,"url":"http://patchwork.ozlabs.org/api/1.1/projects/47/?format=json","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":"<a23f5fc994cc5b454acc5a57225b498d97ec5ac3.1775568640.git.tredaelli@redhat.com>","date":"2026-04-07T13:34:26","name":"[ovs-dev,v2,1/5] ofproto-dpif: Add JSON output to fdb/stats-show.","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6b36dfe75d01a5b33e213eab4198202cd0c512aa","submitter":{"id":70949,"url":"http://patchwork.ozlabs.org/api/1.1/people/70949/?format=json","name":"Timothy Redaelli","email":"tredaelli@redhat.com"},"delegate":{"id":75123,"url":"http://patchwork.ozlabs.org/api/1.1/users/75123/?format=json","username":"echaudron","first_name":"Eelco","last_name":"Chaudron","email":"echaudro@redhat.com"},"mbox":"http://patchwork.ozlabs.org/project/openvswitch/patch/a23f5fc994cc5b454acc5a57225b498d97ec5ac3.1775568640.git.tredaelli@redhat.com/mbox/","series":[{"id":498985,"url":"http://patchwork.ozlabs.org/api/1.1/series/498985/?format=json","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/2220547/comments/","check":"success","checks":"http://patchwork.ozlabs.org/api/patches/2220547/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=QGAkKXB0;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org)","smtp4.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=QGAkKXB0","smtp4.osuosl.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com"],"Received":["from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137])\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 4fqnHz09qgz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 07 Apr 2026 23:35:10 +1000 (AEST)","from localhost (localhost [127.0.0.1])\n\tby smtp4.osuosl.org (Postfix) with ESMTP id 118DF40367;\n\tTue,  7 Apr 2026 13:35:09 +0000 (UTC)","from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id Mdvc1M4C29Gn; Tue,  7 Apr 2026 13:35:08 +0000 (UTC)","from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56])\n\tby smtp4.osuosl.org (Postfix) with ESMTPS id 18AB24035A;\n\tTue,  7 Apr 2026 13:35:08 +0000 (UTC)","from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id F09BDC04FB;\n\tTue,  7 Apr 2026 13:35:07 +0000 (UTC)","from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 466E1C04FA\n for <dev@openvswitch.org>; Tue,  7 Apr 2026 13:35:06 +0000 (UTC)","from localhost (localhost [127.0.0.1])\n by smtp4.osuosl.org (Postfix) with ESMTP id 2CE214035A\n for <dev@openvswitch.org>; Tue,  7 Apr 2026 13:35:06 +0000 (UTC)","from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id O32VnLbZWjS3 for <dev@openvswitch.org>;\n Tue,  7 Apr 2026 13:35:05 +0000 (UTC)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by smtp4.osuosl.org (Postfix) with ESMTPS id 0B260402FD\n for <dev@openvswitch.org>; Tue,  7 Apr 2026 13:35:04 +0000 (UTC)","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-157-NJQY_ZHSMfOOjlxVkYs6jQ-1; Tue,\n 07 Apr 2026 09:35:02 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 6C9E01800344; Tue,  7 Apr 2026 13:35:01 +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 25D7419560A6; Tue,  7 Apr 2026 13:34:59 +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 smtp4.osuosl.org 18AB24035A","OpenDKIM Filter v2.11.0 smtp4.osuosl.org 0B260402FD"],"Received-SPF":"Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124;\n helo=us-smtp-delivery-124.mimecast.com; envelope-from=tredaelli@redhat.com;\n receiver=<UNKNOWN>","DMARC-Filter":"OpenDMARC Filter v1.4.2 smtp4.osuosl.org 0B260402FD","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775568903;\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=3oZ9wfSWx1HHGtwf/1AuseGJZ6I9NAr/iv6Qo2lX9w0=;\n b=QGAkKXB0m6X8pTpU3dEnT/DubkuPqhxL5px6C952I8PTLRkRAu4llcjgT8bYUDOytuRfw2\n C9/Jb5zxhancgLHhX4II5RoJk3v5OGC0qFjzUU75/r3L3W1idGgd4f1OZh1kKeQDLMDU7t\n +I5386ObxqiH8ZJxTuU4bKERsvwRiAU=","X-MC-Unique":"NJQY_ZHSMfOOjlxVkYs6jQ-1","X-Mimecast-MFC-AGG-ID":"NJQY_ZHSMfOOjlxVkYs6jQ_1775568901","To":"dev@openvswitch.org","Date":"Tue,  7 Apr 2026 15:34:26 +0200","Message-ID":"\n <a23f5fc994cc5b454acc5a57225b498d97ec5ac3.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":"XObea3coNNjVUAs8XHUe2IU9HK9HmVxVa5DD6foNjIc_1775568901","X-Mimecast-Originator":"redhat.com","Subject":"[ovs-dev] [PATCH v2 1/5] ofproto-dpif: Add JSON output to\n fdb/stats-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, fdb/stats-show returns a\nJSON object keyed by bridge name.  Each bridge contains two sub-objects:\n\"entries\" (with \"current\", \"maximum\", and \"static\" counts) and \"events\"\n(with \"evicted\", \"expired\", \"learned\", and \"moved\" counters).\n\nThe implementation is split into separate text and JSON helper functions\nto keep the main handler simple.\n\nExample output:\n  {\"br0\": {\"entries\": {\"current\": 17, \"maximum\": 8192, \"static\": 17},\n           \"events\":  {\"evicted\": 0, \"expired\": 0,\n                       \"learned\": 17, \"moved\": 0}}}\n\nReported-at: https://issues.redhat.com/browse/FDP-2444\nSigned-off-by: Timothy Redaelli <tredaelli@redhat.com>\n---\n ofproto/ofproto-dpif.c | 87 ++++++++++++++++++++++++++++++++----------\n tests/ofproto-dpif.at  | 15 ++++++++\n 2 files changed, 81 insertions(+), 21 deletions(-)","diff":"diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c\nindex a02afe8ef..af77577b8 100644\n--- a/ofproto/ofproto-dpif.c\n+++ b/ofproto/ofproto-dpif.c\n@@ -6384,11 +6384,67 @@ ofproto_unixctl_fdb_stats_clear(struct unixctl_conn *conn, int argc,\n     unixctl_command_reply(conn, \"statistics successfully cleared\");\n }\n \n+static struct json *\n+ofproto_unixctl_fdb_stats_show_json(const struct ofproto_dpif *ofproto,\n+                                    const char *bridge_name)\n+{\n+    struct json *entries = json_object_create();\n+    struct json *events = json_object_create();\n+    struct json *bridge = json_object_create();\n+    struct json *json = json_object_create();\n+\n+    json_object_put(entries, \"current\",\n+                    json_integer_create(hmap_count(&ofproto->ml->table)));\n+    json_object_put(entries, \"maximum\",\n+                    json_integer_create(ofproto->ml->max_entries));\n+    json_object_put(entries, \"static\",\n+                    json_integer_create(ofproto->ml->static_entries));\n+    json_object_put(bridge, \"entries\", entries);\n+\n+    json_object_put(events, \"evicted\",\n+                    json_integer_create(ofproto->ml->total_evicted));\n+    json_object_put(events, \"expired\",\n+                    json_integer_create(ofproto->ml->total_expired));\n+    json_object_put(events, \"learned\",\n+                    json_integer_create(ofproto->ml->total_learned));\n+    json_object_put(events, \"moved\",\n+                    json_integer_create(ofproto->ml->total_moved));\n+    json_object_put(bridge, \"events\", events);\n+\n+    json_object_put(json, bridge_name, bridge);\n+    return json;\n+}\n+\n+static void\n+ofproto_unixctl_fdb_stats_show_text(const struct ofproto_dpif *ofproto,\n+                                    const char *bridge_name, struct ds *ds)\n+{\n+    ds_put_format(ds, \"Statistics for bridge \\\"%s\\\":\\n\", bridge_name);\n+    ds_put_format(ds, \"  Current/maximum MAC entries in the table: %\"\n+                  PRIuSIZE\"/%\"PRIuSIZE\"\\n\",\n+                  hmap_count(&ofproto->ml->table),\n+                  ofproto->ml->max_entries);\n+    ds_put_format(ds,\n+                  \"  Current static MAC entries in the table : %\"\n+                  PRIuSIZE\"\\n\", ofproto->ml->static_entries);\n+    ds_put_format(ds,\n+                  \"  Total number of learned MAC entries     : %\"\n+                  PRIu64\"\\n\", ofproto->ml->total_learned);\n+    ds_put_format(ds,\n+                  \"  Total number of expired MAC entries     : %\"\n+                  PRIu64\"\\n\", ofproto->ml->total_expired);\n+    ds_put_format(ds,\n+                  \"  Total number of evicted MAC entries     : %\"\n+                  PRIu64\"\\n\", ofproto->ml->total_evicted);\n+    ds_put_format(ds,\n+                  \"  Total number of port moved MAC entries  : %\"\n+                  PRIu64\"\\n\", ofproto->ml->total_moved);\n+}\n+\n static void\n ofproto_unixctl_fdb_stats_show(struct unixctl_conn *conn, int argc OVS_UNUSED,\n                                const char *argv[], void *aux OVS_UNUSED)\n {\n-    struct ds ds = DS_EMPTY_INITIALIZER;\n     const struct ofproto_dpif *ofproto;\n     ofproto = ofproto_dpif_lookup_by_name(argv[1]);\n     if (!ofproto) {\n@@ -6396,28 +6452,17 @@ ofproto_unixctl_fdb_stats_show(struct unixctl_conn *conn, int argc OVS_UNUSED,\n         return;\n     }\n \n-    ds_put_format(&ds, \"Statistics for bridge \\\"%s\\\":\\n\", argv[1]);\n     ovs_rwlock_rdlock(&ofproto->ml->rwlock);\n+    if (unixctl_command_get_output_format(conn) == UNIXCTL_OUTPUT_FMT_JSON) {\n+        struct json *json = ofproto_unixctl_fdb_stats_show_json(ofproto,\n+                                                                argv[1]);\n+        ovs_rwlock_unlock(&ofproto->ml->rwlock);\n+        unixctl_command_reply_json(conn, json);\n+        return;\n+    }\n \n-    ds_put_format(&ds, \"  Current/maximum MAC entries in the table: %\"\n-                  PRIuSIZE\"/%\"PRIuSIZE\"\\n\",\n-                  hmap_count(&ofproto->ml->table), ofproto->ml->max_entries);\n-    ds_put_format(&ds,\n-                  \"  Current static MAC entries in the table : %\"PRIuSIZE\"\\n\",\n-                  ofproto->ml->static_entries);\n-    ds_put_format(&ds,\n-                  \"  Total number of learned MAC entries     : %\"PRIu64\"\\n\",\n-                  ofproto->ml->total_learned);\n-    ds_put_format(&ds,\n-                  \"  Total number of expired MAC entries     : %\"PRIu64\"\\n\",\n-                  ofproto->ml->total_expired);\n-    ds_put_format(&ds,\n-                  \"  Total number of evicted MAC entries     : %\"PRIu64\"\\n\",\n-                  ofproto->ml->total_evicted);\n-    ds_put_format(&ds,\n-                  \"  Total number of port moved MAC entries  : %\"PRIu64\"\\n\",\n-                  ofproto->ml->total_moved);\n-\n+    struct ds ds = DS_EMPTY_INITIALIZER;\n+    ofproto_unixctl_fdb_stats_show_text(ofproto, argv[1], &ds);\n     ovs_rwlock_unlock(&ofproto->ml->rwlock);\n     unixctl_command_reply(conn, ds_cstr(&ds));\n     ds_destroy(&ds);\ndiff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at\nindex 39e43d376..70e28b7d9 100644\n--- a/tests/ofproto-dpif.at\n+++ b/tests/ofproto-dpif.at\n@@ -8248,6 +8248,21 @@ AT_CHECK_UNQUOTED([ovs-appctl fdb/stats-show br0 | grep static], [0], [dnl\n   Current static MAC entries in the table : 17\n ])\n \n+dnl Check JSON output.\n+AT_CHECK([ovs-appctl --format json --pretty fdb/stats-show br0], [0], [dnl\n+{\n+  \"br0\": {\n+    \"entries\": {\n+      \"current\": 17,\n+      \"maximum\": 8192,\n+      \"static\": 17},\n+    \"events\": {\n+      \"evicted\": 0,\n+      \"expired\": 0,\n+      \"learned\": 18,\n+      \"moved\": 0}}}\n+])\n+\n OVS_VSWITCHD_STOP\n AT_CLEANUP\n \n","prefixes":["ovs-dev","v2","1/5"]}