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 3AB88A00C5; Wed, 27 Jul 2022 03:51:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B8B2840E03; Wed, 27 Jul 2022 03:51:11 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id A202640A89 for ; Wed, 27 Jul 2022 03:51:09 +0200 (CEST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LsxWJ5KvSz1M8G1 for ; Wed, 27 Jul 2022 09:48:12 +0800 (CST) Received: from [127.0.0.1] (10.67.100.224) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 09:51:05 +0800 Subject: Re: [PATCH v2 00/13] telemetry JSON escaping and other enhancements To: Bruce Richardson , References: <20220623164245.561371-1-bruce.richardson@intel.com> <20220725163543.875775-1-bruce.richardson@intel.com> From: fengchengwen Message-ID: Date: Wed, 27 Jul 2022 09:51:04 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20220725163543.875775-1-bruce.richardson@intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.100.224] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected 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 Hi Bruce, I think escape the string at begin (following function) seem more simple: rte_tel_data_string rte_tel_data_add_array_string rte_tel_data_add_dict_string int rte_tel_data_string(struct rte_tel_data *d, const char *str) { d->type = RTE_TEL_STRING; d->data_len = strlcpy(d->data.str, str, sizeof(d->data.str)); // e.g. do escape here! if (d->data_len >= RTE_TEL_MAX_SINGLE_STRING_LEN) { d->data_len = RTE_TEL_MAX_SINGLE_STRING_LEN - 1; return E2BIG; /* not necessarily and error, just truncation */ } return 0; } Advantages: 1. simpler implementation 2. application are directly visible the result (by judge API retval) without waiting for JSON encapsulation. Disadvantages: 1. not friend for new output format, but currently telemetry deep depend on json, so I think it's OK for it. On 2022/7/26 0:35, Bruce Richardson wrote: > This patchset contains fixes for the problem of handling characters > returned by telemetry callbacks which require escaping when encoded in > JSON format. It also includes unit tests to validate the correct > encoding in such scenarios and a number of smaller enhancements to > telemetry and telemetry testing. > > RFC->V2: > * limited characters allowed in dictionary element names and command > names to side-step the encoding problems there. > * added support for proper escaping of dictionary string values > * added more testing and test cases > * added other misc telemetry cleanups and refactoring > > Bruce Richardson (13): > test/telemetry_json: print success or failure per subtest > telemetry: fix escaping of invalid json characters > test/telemetry_json: add test for string character escaping > telemetry: add escaping of strings in arrays > test/telemetry-json: add test for escaping strings in arrays > telemetry: limit characters allowed in dictionary names > telemetry: add escaping of strings in dicts > test/telemetry_json: add test for string escaping in objects > telemetry: limit command characters > test/telemetry_data: refactor for maintainability > test/telemetry_data: add test cases for character escaping > telemetry: eliminate duplicate code for json output > telemetry: make help command more helpful > > app/test/test_telemetry_data.c | 138 +++++++++++++++++++-------- > app/test/test_telemetry_json.c | 98 +++++++++++++++++-- > doc/guides/rel_notes/deprecation.rst | 8 -- > lib/telemetry/rte_telemetry.h | 8 ++ > lib/telemetry/telemetry.c | 51 +++++----- > lib/telemetry/telemetry_data.c | 32 +++++++ > lib/telemetry/telemetry_json.h | 72 ++++++++++++-- > 7 files changed, 318 insertions(+), 89 deletions(-) > > -- > 2.34.1 > > > . >