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 CFB94A0540; Fri, 9 Sep 2022 11:36:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E456442B8E; Fri, 9 Sep 2022 11:35:55 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id B061242829 for ; Fri, 9 Sep 2022 11:35:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662716151; x=1694252151; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GnQTKladdNCFmAE4dqRh46rqOJm9KH1WTCgMQJrDXLw=; b=fpIrL18ptIxfAzc1Ju80LLcAOT7HsuV9NyX/lce+OCTkvVzP8Xl+iUX2 RfnatflTthHtMO6ehn39f2C1ptDfK583p58aH+fhnSgUzl+6zGANH33Fm +7v/vndnYTAyK69GYL2/5oiZehFPGa4Mutcqje5tyhp9lG+hfMq+ySa5A MVQy0pGPawmwdocntjDItUo87WAciPLepb4NbJL4e0Ve0/Bg5qXyolxFC kdNOQTXZvJ8K+1dKwaHmbh1bUMJKbcbf1+O10mx1pPv6RaZSSFmsomDI5 vAOCBr2YxcbmHUe/yC2XMQWo7bRgcg93gtH1Wa3XuWDc7DLQhxi4dbZl5 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="297437141" X-IronPort-AV: E=Sophos;i="5.93,302,1654585200"; d="scan'208";a="297437141" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2022 02:35:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,302,1654585200"; d="scan'208";a="740996439" Received: from silpixa00401385.ir.intel.com ([10.237.214.161]) by orsmga004.jf.intel.com with ESMTP; 09 Sep 2022 02:35:49 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Ciara Power , =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH v3 09/13] telemetry: limit command characters Date: Fri, 9 Sep 2022 10:35:19 +0100 Message-Id: <20220909093523.471727-10-bruce.richardson@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220909093523.471727-1-bruce.richardson@intel.com> References: <20220623164245.561371-1-bruce.richardson@intel.com> <20220909093523.471727-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 Acked-by: Ciara Power Acked-by: Morten Brørup --- 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