From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E6FA1A0548; Wed, 15 Jun 2022 18:55:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 99DFF427EB; Wed, 15 Jun 2022 18:55:45 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 6541B410D0 for ; Wed, 15 Jun 2022 18:55:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655312144; x=1686848144; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=kvyDksgubBSdNiGbzxdT6/dunxBo+T5a+P2ptcPP8iY=; b=HL1GURvLHFbYakixRzOvTuLpI4VrFLG9T68gxKnrBjtzL5W0vI9mAG1J BFiEj+PEQnMXGP1bcHZrlE6b25ZEC0LlmhdOghJ51ET5K12tkVehyguKQ Of9VeQmnWMdaNHjpCExn2fBU6Pe+9exXwjf55SNdSyYHZw5tjhY3rdF99 l0is8CsPeqoTcSr3i8YzacFmWJyb6XFvQUShn6IgL9OXJk2y5VMRaRgNs phDzqcEdIffMI//cOUVx1nMkW9ywlNlt5CzR4N3Kovjt7wbgDSiHIFV62 ZAYmHRyAAj2vXOAqr1emsWDZzkLw8iP6ilQPdGSTYboT5xuri9qXA7Wx1 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10379"; a="340688609" X-IronPort-AV: E=Sophos;i="5.91,302,1647327600"; d="scan'208";a="340688609" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2022 09:55:01 -0700 X-IronPort-AV: E=Sophos;i="5.91,302,1647327600"; d="scan'208";a="641099837" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.9.180]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 15 Jun 2022 09:54:58 -0700 Date: Wed, 15 Jun 2022 17:54:55 +0100 From: Bruce Richardson To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: Chengwen Feng , thomas@monjalon.net, ferruh.yigit@xilinx.com, kevin.laatz@intel.com, andrew.rybchenko@oktetlabs.ru, jerinj@marvell.com, sachin.saxena@oss.nxp.com, hemant.agrawal@nxp.com, dev@dpdk.org Subject: Re: [PATCH 1/5] usertools: use non-strict when json-loads in telemetry Message-ID: References: <20220615073915.14041-1-fengchengwen@huawei.com> <20220615073915.14041-2-fengchengwen@huawei.com> <98CBD80474FA8B44BF855DF32C47DC35D87126@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D87126@smartserver.smartshare.dk> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, Jun 15, 2022 at 03:54:57PM +0200, Morten Brørup wrote: > > From: Chengwen Feng [mailto:fengchengwen@huawei.com] > > Sent: Wednesday, 15 June 2022 09.39 > > > > Use 'strict=False' in json-loads, it will ignore control characters > > (e.g. '\n\t'), this patch is prepared for the support of telemetry dump > > in the future. > > > > Signed-off-by: Chengwen Feng > > --- > > usertools/dpdk-telemetry.py | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/usertools/dpdk-telemetry.py b/usertools/dpdk-telemetry.py > > index a81868a547..63f8004566 100755 > > --- a/usertools/dpdk-telemetry.py > > +++ b/usertools/dpdk-telemetry.py > > @@ -27,7 +27,7 @@ def read_socket(sock, buf_len, echo=True): > > """ Read data from socket and return it in JSON format """ > > reply = sock.recv(buf_len).decode() > > try: > > - ret = json.loads(reply) > > + ret = json.loads(reply, strict=False) > > except json.JSONDecodeError: > > print("Error in reply: ", reply) > > sock.close() > > -- > > 2.33.0 > > > > As I understand this patch, it accepts non-JSON data from the telemetry socket. > > Isn't it is a major protocol violation if the telemetry socket produces output requiring this modification? Doing that would break other applications expecting strictly JSON formatted output from the telemetry socket. > I would tend to agree. As an alternative, I think you should add to the telemetry library an "escape string" function which can then be used by the telemetry functions to properly json encode the strings back from the dump functions before sending them out. /Bruce