#define MAX_OUTPUT_LEN (1024 * 16)
#define MAX_CONNECTIONS 10
-/** Maximum number of telemetry callbacks. */
-#define TELEMETRY_MAX_CALLBACKS 64
-
#ifndef RTE_EXEC_ENV_WINDOWS
static void *
client_handler(void *socket);
rte_log_ptr(RTE_LOG_ ## l, logtype, "TELEMETRY: " __VA_ARGS__)
/* list of command callbacks, with one command registered by default */
-static struct cmd_callback callbacks[TELEMETRY_MAX_CALLBACKS];
+static struct cmd_callback *callbacks;
static int num_callbacks; /* How many commands are registered */
/* Used when accessing or modifying list of command callbacks */
static rte_spinlock_t callback_sl = RTE_SPINLOCK_INITIALIZER;
int
rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help)
{
+ struct cmd_callback *new_callbacks;
int i = 0;
if (strlen(cmd) >= MAX_CMD_LEN || fn == NULL || cmd[0] != '/'
|| strlen(help) >= MAX_HELP_LEN)
return -EINVAL;
- if (num_callbacks >= TELEMETRY_MAX_CALLBACKS)
- return -ENOENT;
rte_spinlock_lock(&callback_sl);
+ new_callbacks = realloc(callbacks, sizeof(callbacks[0]) * (num_callbacks + 1));
+ if (new_callbacks == NULL) {
+ rte_spinlock_unlock(&callback_sl);
+ return -ENOMEM;
+ }
+ callbacks = new_callbacks;
+
while (i < num_callbacks && strcmp(cmd, callbacks[i].cmd) > 0)
i++;
if (i != num_callbacks)