From patchwork Thu May 16 15:41:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Meng X-Patchwork-Id: 1936050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=G4g7yrii; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VgDpj4S55z1ymw for ; Fri, 17 May 2024 01:41:33 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9A353836F6; Thu, 16 May 2024 15:41:31 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id vJauMflIUDdO; Thu, 16 May 2024 15:41:30 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7F9E281F7F Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=G4g7yrii Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 7F9E281F7F; Thu, 16 May 2024 15:41:30 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D7714C007C; Thu, 16 May 2024 15:41:29 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id BDEB4C0037 for ; Thu, 16 May 2024 15:41:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id A99EE41D0C for ; Thu, 16 May 2024 15:41:28 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id PN0mYPACwvPm for ; Thu, 16 May 2024 15:41:27 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=jmeng@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 8A6E0401F3 Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8A6E0401F3 Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=G4g7yrii Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 8A6E0401F3 for ; Thu, 16 May 2024 15:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715874086; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zq6jOUGENCfTu7IlzOMghY0zwyak5wFsiW/+MfQYMMI=; b=G4g7yriiEjqTL2HuCn6r/ZGA5JkMB0fNpbEBNi0/dBmoPoYkzQnur+E9UpHxpizYFofB1Q RyhT4USbdgEQzQztTmJCrziikkiSkdJr1Ey5BYtsctR8uBiDRjEYm+3g/fvHFv/nJlm04t YvEfEw3uJMZuRbEEH+bRqrhiyxCRAxU= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-vmV5LL4-ONG1Ho4hGU4hvg-1; Thu, 16 May 2024 11:41:24 -0400 X-MC-Unique: vmV5LL4-ONG1Ho4hGU4hvg-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2e41bd70238so76507531fa.1 for ; Thu, 16 May 2024 08:41:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715874083; x=1716478883; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zq6jOUGENCfTu7IlzOMghY0zwyak5wFsiW/+MfQYMMI=; b=n64Lxez7DN0ZmRhA2oMcdcuUlQBtR8+aeDc3rOyXeKXNI0n6zSjn5DYKyOdDlsuGEL ZOthHswEndg7oTZpyvA0Tva6WiYt9aj6QaVV7d4MRkR1Xf4z6csLPdkPsU+w8rFJLy0b Biwp+p5dzjXMTK/R+NOtc+6SNG5slTyB97UCwMDjJmrCPGh8rlUZl2rY1IDPaUwrjwPH U2GYrnv/PuEf0vQb3yB+DrD13yB8spmlRsPTxHlcjtRMCv14QTvNJTtcoo+yzMOJHp9r KN9ZAjIZJU2cTaYD2cbrlJhoggSwQmugl8T/S5l09UpEWFgSftFLMlQtgEX8qcDbs7oM gHZg== X-Gm-Message-State: AOJu0Yw5bI3wPp/hEccx9kVoQkkIP/+fZN3sEwuMUHnbbqSlPTynLT9D Fpzc5PxwMoAYbVdV3sM5CJfpj+ahoUqk/+jQM6LACi9qtdc2tAKIUlFg3sNLyY6qpN4JBgGXx3/ vBZMHXR/KbMc38zrU3dt1fMSGfLVGsf7QctFaXAdMqaE4ps4GjM7WlNuWjyqCC0e2lh8u/B2wIJ iQlTd4Tfk3DLY2klqVGNEuVdkCB/kj X-Received: by 2002:ac2:5b84:0:b0:521:54b5:86a3 with SMTP id 2adb3069b0e04-52210273d59mr11832940e87.64.1715874083289; Thu, 16 May 2024 08:41:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGMMOsaiornVHSyr7KGwvlso8tBWJvH/x9lQy2lvsnYLJxp+2ciffU/eEb1gXw0Hm5cVNmkA== X-Received: by 2002:ac2:5b84:0:b0:521:54b5:86a3 with SMTP id 2adb3069b0e04-52210273d59mr11832924e87.64.1715874082752; Thu, 16 May 2024 08:41:22 -0700 (PDT) Received: from positronik4lide.redhat.com ([87.122.57.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502bbbbf9esm19177266f8f.91.2024.05.16.08.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:41:22 -0700 (PDT) From: jmeng@redhat.com To: dev@openvswitch.org, i.maximets@ovn.org Date: Thu, 16 May 2024 17:41:11 +0200 Message-Id: <20240516154117.2306789-1-jmeng@redhat.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v12 0/6] Add global option to output JSON from ovs-appctl cmds. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Jakob Meng v12 has one tiny change compared to v11 [0]: It moves "free(msg);" up in order to work around an issue with AddressSanitizer/LeakSanitizer [1] in Ubuntu 22.04 which is not present in later releases. [0] https://patchwork.ozlabs.org/project/openvswitch/list/?series=407037&archive=both&state=* [1] https://github.com/ovsrobot/ovs/actions/runs/9110821443/job/25046630474 Best regards, Jakob Jakob Meng (6): Add global option for JSON output to ovs-appctl. python: Add option for JSON output to unixctl classes and appctl.py. appctl: Add option '--pretty' for pretty-printing JSON output. python: Add option for pretty-printing JSON output to appctl.py. vswitchd: Add JSON output for 'list-commands' command. ofproto: Add JSON output for 'dpif/show' command. Documentation/ref/ovs-appctl.8.rst | 19 +++ NEWS | 9 ++ lib/unixctl.c | 239 ++++++++++++++++++++++------- lib/unixctl.h | 20 ++- lib/util.c | 6 +- ofproto/ofproto-dpif.c | 120 +++++++++++++-- python/ovs/unixctl/client.py | 5 +- python/ovs/unixctl/server.py | 55 +++++-- python/ovs/util.py | 8 + tests/appctl.py | 40 ++++- tests/ovs-vswitchd.at | 29 ++++ tests/pmd.at | 23 +++ tests/unixctl-py.at | 8 + utilities/ovs-appctl.c | 154 ++++++++++++++++--- 14 files changed, 627 insertions(+), 108 deletions(-) diff --git a/utilities/ovs-appctl.c b/utilities/ovs-appctl.c Signed-off-by: Jakob Meng index 2ade64336..3b76740ea 100644 --- a/utilities/ovs-appctl.c +++ b/utilities/ovs-appctl.c @@ -88,6 +88,7 @@ main(int argc, char *argv[]) jsonrpc_close(client); msg = reply_to_string(cmd_error, UNIXCTL_OUTPUT_FMT_TEXT, 0); fputs(msg, stderr); + free(msg); ovs_error(0, "%s: server returned an error", args->target); exit(2); } @@ -111,11 +112,13 @@ main(int argc, char *argv[]) jsonrpc_close(client); msg = reply_to_string(cmd_error, UNIXCTL_OUTPUT_FMT_TEXT, 0); fputs(msg, stderr); + free(msg); ovs_error(0, "%s: server returned an error", args->target); exit(2); } else if (cmd_result) { msg = reply_to_string(cmd_result, args->format, args->format_flags); fputs(msg, stdout); + free(msg); } else { OVS_NOT_REACHED(); } @@ -124,7 +127,6 @@ main(int argc, char *argv[]) json_destroy(cmd_result); json_destroy(cmd_error); free(args); - free(msg); return 0; }