patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH v2] lib/telemetry: fix passing full params string to command
@ 2020-08-27  8:39 Ciara Power
  2020-08-27  9:14 ` Bruce Richardson
  0 siblings, 1 reply; 3+ messages in thread
From: Ciara Power @ 2020-08-27  8:39 UTC (permalink / raw)
  To: dev
  Cc: mike.ximing.chen, gage.eads, sundar.vedantham, Ciara Power,
	bruce.richardson, stable, Thomas Monjalon, Ferruh Yigit,
	Andrew Rybchenko, Nipun Gupta, Hemant Agrawal, Kevin Laatz,
	Keith Wiles

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 <ciara.power@intel.com>

---
v2: modified log string
---
 lib/librte_ethdev/rte_ethdev.c   | 12 ++++++++++--
 lib/librte_rawdev/rte_rawdev.c   |  6 +++++-
 lib/librte_telemetry/telemetry.c |  2 +-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 7858ad5f11..a00a9e4d36 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -5284,11 +5284,15 @@ 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 parameters passed to ethdev telemetry command, ignoring");
 	if (!rte_eth_dev_is_valid_port(port_id))
 		return -1;
 
@@ -5330,11 +5334,15 @@ 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 parameters passed to ethdev telemetry command, ignoring");
 	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..5e5f8f0cca 100644
--- a/lib/librte_rawdev/rte_rawdev.c
+++ b/lib/librte_rawdev/rte_rawdev.c
@@ -565,11 +565,15 @@ 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 parameters passed to rawdev telemetry command, ignoring");
 	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;
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH v2] lib/telemetry: fix passing full params string to command
  2020-08-27  8:39 [dpdk-stable] [PATCH v2] lib/telemetry: fix passing full params string to command Ciara Power
@ 2020-08-27  9:14 ` Bruce Richardson
  2020-10-06 20:32   ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2020-08-27  9:14 UTC (permalink / raw)
  To: Ciara Power
  Cc: dev, mike.ximing.chen, gage.eads, sundar.vedantham, stable,
	Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, Nipun Gupta,
	Hemant Agrawal, Kevin Laatz, Keith Wiles

On Thu, Aug 27, 2020 at 09:39:22AM +0100, Ciara Power wrote:
> 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 <ciara.power@intel.com>
> 
Missed threading with V1, but otherwise LGTM.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH v2] lib/telemetry: fix passing full params string to command
  2020-08-27  9:14 ` Bruce Richardson
@ 2020-10-06 20:32   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2020-10-06 20:32 UTC (permalink / raw)
  To: Ciara Power
  Cc: dev, mike.ximing.chen, gage.eads, sundar.vedantham, stable,
	Ferruh Yigit, Andrew Rybchenko, Nipun Gupta, Hemant Agrawal,
	Kevin Laatz, Keith Wiles, Bruce Richardson

27/08/2020 11:14, Bruce Richardson:
> On Thu, Aug 27, 2020 at 09:39:22AM +0100, Ciara Power wrote:
> > 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 <ciara.power@intel.com>
> > 
> Missed threading with V1, but otherwise LGTM.
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-06 20:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-27  8:39 [dpdk-stable] [PATCH v2] lib/telemetry: fix passing full params string to command Ciara Power
2020-08-27  9:14 ` Bruce Richardson
2020-10-06 20:32   ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).