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 12402A00C4; Mon, 25 Jul 2022 18:36:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2FF3442B72; Mon, 25 Jul 2022 18:36:30 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id A6A7842B85 for ; Mon, 25 Jul 2022 18:36:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658766988; x=1690302988; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RmkWV8JLBCLs6vpJ2qD29oK9VqHjzT8RCgZmeh/ciFM=; b=Cm4RLTMh1qJaDW5WcYx6r8g/A7xY8/naZyKnOE5Ei6C9itGwvMSd0qQ9 57a4qG1Ufu+k3RhW89rubRiZ5V5Ok9qDnTPXHiOkf+P3eBfG9cyo1Ok4r MvJHskfTWn688L2zi9/HiFXttIbODyl/0rYJKhSjIuoqwneS+/VB2AM+p z5X4JaU4Md40yTEQkxb66HXr+ei7CXtnOt19cOOOyDEzZW+wp62rdo8uW e+8VZjYm46iPF3mWv9mGVx1Ca2PxVXt7fcq5mKS6WdRbMAjZnt0ojOLeV PlpMu0QW6c8aO8ldcUaMy4IDuqlB9znTZXs8SvZvil+g4nchh2RCAF+Yt w==; X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="288499123" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="288499123" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 09:36:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="575122732" Received: from silpixa00401385.ir.intel.com (HELO silpixa00401385.ger.corp.intel.com.) ([10.237.223.47]) by orsmga006.jf.intel.com with ESMTP; 25 Jul 2022 09:36:26 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Ray Kinsella , Ciara Power Subject: [PATCH v2 09/13] telemetry: limit command characters Date: Mon, 25 Jul 2022 17:35:38 +0100 Message-Id: <20220725163543.875775-10-bruce.richardson@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220725163543.875775-1-bruce.richardson@intel.com> References: <20220623164245.561371-1-bruce.richardson@intel.com> <20220725163543.875775-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Limit the telemetry command characters to the minimum set needed for current implementations. This prevents issues with invalid json characters needing to be escaped on replies. Signed-off-by: Bruce Richardson --- doc/guides/rel_notes/deprecation.rst | 8 -------- lib/telemetry/telemetry.c | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index e7583cae4c..d1c93ca7e3 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -212,14 +212,6 @@ Deprecation Notices * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``. -* telemetry: The allowed characters in names for dictionary values - will be limited to alphanumeric characters - and a small subset of additional printable characters. - This will ensure that all dictionary parameter names can be output - without escaping in JSON - or in any future output format used. - Names for the telemetry commands will be similarly limited. - The parameters for telemetry commands are unaffected by this change. - * net/octeontx_ep: The driver ``octeontx_ep`` was to support OCTEON TX line of products. It will be renamed to ``octeon_ep`` in DPDK 22.11 to apply for diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 7188b1905c..03651e947d 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -70,12 +70,19 @@ int rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help) { struct cmd_callback *new_callbacks; + const char *cmdp = cmd; int i = 0; if (strlen(cmd) >= MAX_CMD_LEN || fn == NULL || cmd[0] != '/' || strlen(help) >= RTE_TEL_MAX_STRING_LEN) return -EINVAL; + while (*cmdp != '\0') { + if (!isalnum(*cmdp) && *cmdp != '_' && *cmdp != '/') + return -EINVAL; + cmdp++; + } + rte_spinlock_lock(&callback_sl); new_callbacks = realloc(callbacks, sizeof(callbacks[0]) * (num_callbacks + 1)); if (new_callbacks == NULL) { -- 2.34.1