From patchwork Tue Aug 25 12:01:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Power, Ciara" X-Patchwork-Id: 75933 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0D2DEA04B1; Tue, 25 Aug 2020 14:01:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 56B281C1A1; Tue, 25 Aug 2020 14:01:42 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 883941C135; Tue, 25 Aug 2020 14:01:40 +0200 (CEST) IronPort-SDR: wGhfaRmyZr+vwo0als0P5ncRS33pVDs62VO0h5jTUPDxFNqugWaOaDsJlGylWe5jNg3x7hgf8a eH0HThkOnHuA== X-IronPort-AV: E=McAfee;i="6000,8403,9723"; a="155350197" X-IronPort-AV: E=Sophos;i="5.76,352,1592895600"; d="scan'208";a="155350197" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2020 05:01:39 -0700 IronPort-SDR: ZipfOdQ94EL6pGrqg1tvRtuaqIHrc9OUV1bQCL4v7zfld3Z/L4mzbHN2IXWsYXDFj7AHzmaeZy JT6O6QM9h9gQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,352,1592895600"; d="scan'208";a="336476998" Received: from silpixa00399953.ir.intel.com (HELO silpixa00399953.ger.corp.intel.com) ([10.237.222.53]) by FMSMGA003.fm.intel.com with ESMTP; 25 Aug 2020 05:01:37 -0700 From: Ciara Power To: dev@dpdk.org Cc: Ciara Power , bruce.richardson@intel.com, stable@dpdk.org, Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Nipun Gupta , Hemant Agrawal , Kevin Laatz , Keith Wiles Date: Tue, 25 Aug 2020 13:01:33 +0100 Message-Id: <20200825120133.44316-1-ciara.power@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] lib/telemetry: fix passing full params string to command X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Telemetry only passed the first param to the command handler if multiple were entered by the user, separated by commas. Telemetry is required to pass the full params string to the command, by splitting by a comma delimiter only once to remove the command part of the string. This will enable future commands to take multiple param values. Fixes: b1ad0e124536 ("rawdev: add telemetry callbacks") Fixes: c190daedb9b1 ("ethdev: add telemetry callbacks") Fixes: 6dd571fd07c3 ("telemetry: introduce new functionality") Cc: bruce.richardson@intel.com Cc: stable@dpdk.org Signed-off-by: Ciara Power --- lib/librte_ethdev/rte_ethdev.c | 10 ++++++++-- lib/librte_rawdev/rte_rawdev.c | 5 ++++- lib/librte_telemetry/telemetry.c | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 7858ad5f11..6ba09362db 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -5284,11 +5284,14 @@ handle_port_xstats(const char *cmd __rte_unused, struct rte_eth_xstat_name *xstat_names; int port_id, num_xstats; int i, ret; + char *end_param; if (params == NULL || strlen(params) == 0 || !isdigit(*params)) return -1; - port_id = atoi(params); + port_id = strtoul(params, &end_param, 0); + if (*end_param != '\0') + RTE_ETHDEV_LOG(NOTICE, "Extra params passed to telemetry command for ethdev xstats, first param in use"); if (!rte_eth_dev_is_valid_port(port_id)) return -1; @@ -5330,11 +5333,14 @@ handle_port_link_status(const char *cmd __rte_unused, static const char *status_str = "status"; int ret, port_id; struct rte_eth_link link; + char *end_param; if (params == NULL || strlen(params) == 0 || !isdigit(*params)) return -1; - port_id = atoi(params); + port_id = strtoul(params, &end_param, 0); + if (*end_param != '\0') + RTE_ETHDEV_LOG(NOTICE, "Extra params passed to telemetry command for ethdev link status, first param in use"); if (!rte_eth_dev_is_valid_port(port_id)) return -1; diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c index 8f84d0b228..51c4470b0c 100644 --- a/lib/librte_rawdev/rte_rawdev.c +++ b/lib/librte_rawdev/rte_rawdev.c @@ -565,11 +565,14 @@ handle_dev_xstats(const char *cmd __rte_unused, struct rte_rawdev_xstats_name *xstat_names; int dev_id, num_xstats, i, ret; unsigned int *ids; + char *end_param; if (params == NULL || strlen(params) == 0 || !isdigit(*params)) return -1; - dev_id = atoi(params); + dev_id = strtoul(params, &end_param, 0); + if (*end_param != '\0') + RTE_RDEV_LOG(NOTICE, "Extra params passed to telemetry command for rawdev xstats, first param in use"); if (!rte_rawdev_pmd_is_valid_dev(dev_id)) return -1; diff --git a/lib/librte_telemetry/telemetry.c b/lib/librte_telemetry/telemetry.c index 0252282735..c6c2948709 100644 --- a/lib/librte_telemetry/telemetry.c +++ b/lib/librte_telemetry/telemetry.c @@ -248,7 +248,7 @@ client_handler(void *sock_id) while (bytes > 0) { buffer[bytes] = 0; const char *cmd = strtok(buffer, ","); - const char *param = strtok(NULL, ","); + const char *param = strtok(NULL, "\0"); telemetry_cb fn = unknown_command; int i;