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 <bruce.richard...@intel.com>
---
 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

Reply via email to