[v3,09/13] telemetry: limit command characters
Checks
Commit Message
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.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
---
doc/guides/rel_notes/deprecation.rst | 8 --------
lib/telemetry/telemetry.c | 7 +++++++
2 files changed, 7 insertions(+), 8 deletions(-)
@@ -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
@@ -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) {