telemetry: remove internal symbol from public header
PATCH 1/1 telemetry: remove internal symbol from public header
From: Jerin Jacob <[email protected]>
Remove TELEMETRY_MAX_CALLBACKS symbol from publicrte_telemetry.h header file.
--- lib/telemetry/rte_telemetry.h | 2 -- lib/telemetry/telemetry.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-)
lib/telemetry/rte_telemetry.h +0 -2
@@ -10,8 +10,6 @@#ifndef _RTE_TELEMETRY_H_#define _RTE_TELEMETRY_H_ -/** Maximum number of telemetry callbacks. */ -#define TELEMETRY_MAX_CALLBACKS 64/** Maximum length for string used in object. */ #define RTE_TEL_MAX_STRING_LEN 64/** Maximum length of string. */
lib/telemetry/telemetry.c +3 -0
@@ -27,6 +27,9 @@#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);
Signature · 1 line
2.31.1
Quoted 7 lines · On Mon, May 03, 2021 at 10:04:28PM +0530, [email protected] wrote:
From: Jerin Jacob <[email protected]>
Remove
TELEMETRY_MAX_CALLBACKSsymbol from publicrte_telemetry.hheader file.Signed-off-by Jerin Jacob <[email protected]>---
Power, Ciara
Acked-byQuoted 9 lines
-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: Tuesday 4 May 2021 13:14
To: [email protected]
Cc: Power, Ciara <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] telemetry: remove internal symbol from public headerOn Mon, May 03, 2021 at 10:04:28PM +0530, [email protected] wrote:
Quoted 8 lines
Quoted 7 lines
From: Jerin Jacob <[email protected]>
Remove
TELEMETRY_MAX_CALLBACKSsymbol from publicrte_telemetry.hheader file.Signed-off-by Jerin Jacob <[email protected]>---
Acked-by Bruce Richardson <[email protected]>
Thanks,
Quoted 15 lines · Ciara
Quoted 15 lines
-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: Tuesday 4 May 2021 13:14
To: [email protected]
Cc: Power, Ciara <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] telemetry: remove internal symbol from public headerQuoted 5 lines · On Mon, May 03, 2021 at 10:04:28PM +0530, [email protected] wrote:
From: Jerin Jacob <[email protected]>
Remove
TELEMETRY_MAX_CALLBACKSsymbol from publicrte_telemetry.hheader file.
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Signed-off-by Jerin Jacob <[email protected]>---
Acked-by Bruce Richardson <[email protected]>Thanks,
Acked-by Ciara Power <[email protected]>
I agree this define should be hidden.
Just, what do you think of using a dynamic allocation and remove the limitation entirely?
lib/telemetry/rte_telemetry.h +1 -3
@@ -10,8 +10,6 @@#ifndef _RTE_TELEMETRY_H_#define _RTE_TELEMETRY_H_ -/** Maximum number of telemetry callbacks. */ -#define TELEMETRY_MAX_CALLBACKS 64/** Maximum length for string used in object. */ #define RTE_TEL_MAX_STRING_LEN 64/** Maximum length of string. */
@@ -285,7 +283,7 @@ typedef void * (*handler)(void *sock_id);* @return * -EINVAL for invalid parameters failure. * @return -* -ENOENT if max callbacks limit has been reached. +* -ENOMEM for mem allocation failure. */ __rte_experimental int
lib/telemetry/telemetry.c +3 -3
@@ -59,7 +59,7 @@ static uint32_t logtype; 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 ;
@@ -70,15 +70,21 @@ static uint16_t v2_clients;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)And there is a race to fix in list_commands() (which accesses the callbacks array without taking the lock).
Signature · 1 line
David Marchand
Quoted 21 lines · David Marchand
Quoted 19 lines · Ciara
Quoted 18 lines
-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: Tuesday 4 May 2021 13:14
To: [email protected]
Cc: Power, Ciara <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] telemetry: remove internal symbol from public headerQuoted 7 lines · On Mon, May 03, 2021 at 10:04:28PM +0530, [email protected] wrote:
From: Jerin Jacob <[email protected]>
Remove
TELEMETRY_MAX_CALLBACKSsymbol from publicrte_telemetry.hheader file.Signed-off-by Jerin Jacob <[email protected]>---
Acked-by Bruce Richardson <[email protected]>
Quoted 7 lines
Quoted 2 lines
Thanks,
Acked-by Ciara Power <[email protected]>I agree this define should be hidden.
Just, what do you think of using a dynamic allocation and remove the limitation entirely?
I think, that may be better. Probably this patch can go in rc2.
The dynamic feature can be pushed to the next release.
I will leave it to the maintainers to decide. I am fine with any scheme.
Quoted 70 lines
lib/telemetry/rte_telemetry.h +1
-3@@ -10,8 +10,6 @@#ifndef _RTE_TELEMETRY_H_#define _RTE_TELEMETRY_H_ -/** Maximum number of telemetry callbacks. */ -#define TELEMETRY_MAX_CALLBACKS 64/** Maximum length for string used in object. */ #define RTE_TEL_MAX_STRING_LEN 64/** Maximum length of string. */ @@ -285,7 +283,7 @@ typedef void * (*handler)(void *sock_id);* @return * -EINVAL for invalid parameters failure. * @return -* -ENOENT if max callbacks limit has been reached. +* -ENOMEM for mem allocation failure. */ __rte_experimental intlib/telemetry/telemetry.c +9
-3@@ -59,7 +59,7 @@ static uint32_t logtype; 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 ;@@ -70,15 +70,21 @@ static uint16_t v2_clients;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)And there is a race to fix in
list_commands()(which accesses the callbacks array without taking the lock).--
David Marchand
Quoted 42 lines
-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Wednesday 5 May 2021 11:25
To: David Marchand <[email protected]>
Cc: Power, Ciara <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH] telemetry: remove internal symbol from public headerQuoted 2 lines · David Marchand
On Tue, May 4, 2021 at 6:19 PM Power, Ciara <[email protected]>
Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 10 lines
-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: Tuesday 4 May 2021 13:14
To: [email protected]
Cc: Power, Ciara <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] telemetry: remove internal symbol from public headerQuoted 4 lines
Quoted 4 lines
Quoted 4 lines · On Mon, May 03, 2021 at 10:04:28PM +0530, [email protected] wrote:
Quoted 3 lines
From: Jerin Jacob <[email protected]>
Remove
TELEMETRY_MAX_CALLBACKSsymbol from public
rte_telemetry.hQuoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
header file.
Signed-off-by Jerin Jacob <[email protected]>---
Acked-by Bruce Richardson <[email protected]>Thanks,
Acked-by Ciara Power <[email protected]>I agree this define should be hidden.
Quoted 9 lines
Quoted 2 lines
Just, what do you think of using a dynamic allocation and remove the limitation entirely?
I think, that may be better. Probably this patch can go in rc2.
The dynamic feature can be pushed to the next release.
I will leave it to the maintainers to decide. I am fine with any scheme.
+1 for the dynamic allocation idea.
I am ok with using this small fix patch for now and making the change to dynamic allocation at a later stage, if it isn't suitable at this point in the release cycle.
Quoted 64 lines
Quoted 64 lines
(quoted diff) +0
-0
b/lib/telemetry/rte_telemetry.hindex031db9e968..8776998b54100644lib/telemetry/rte_telemetry.h +0
-1@@ -10,8 +10,6 @@#ifndef _RTE_TELEMETRY_H_#define _RTE_TELEMETRY_H_ -/** Maximum number of telemetry callbacks. */ -#define
TELEMETRY_MAX_CALLBACKS64
/** Maximum length for string used in object. */ #defineRTE_TEL_MAX_STRING_LEN64
/** Maximum length of string. */lib/telemetry/rte_telemetry.h +1
-1@@ -285,7 +283,7 @@ typedef void * (*handler)(void *sock_id);* @return * -EINVAL for invalid parameters failure. * @return -* -ENOENT if max callbacks limit has been reached. +* -ENOMEM for mem allocation failure. */ __rte_experimental intlib/telemetry/telemetry.c +1
-0@@ -59,7 +59,7 @@ static uint32_t logtype; 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_tcallback_sl=RTE_SPINLOCK_INITIALIZER; @@ -70,15 +70,21 @@ staticuint16_tv2_clients; intrte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help){lib/telemetry/telemetry.c +2
-2+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));lib/telemetry/telemetry.c +6
-0+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)
Quoted 6 lines
Quoted 6 lines
And there is a race to fix in
list_commands()(which accesses the callbacks array without taking the lock).--
David Marchand
Good catch, I can send a fix patch for this list commands function. Thanks David.
- Ciara
David Marchand
AppliedQuoted 6 lines · Ciara
Quoted 5 lines
Quoted 4 lines
Remove
TELEMETRY_MAX_CALLBACKSsymbol from publicrte_telemetry.hheader file.Signed-off-by Jerin Jacob <[email protected]>Acked-by Bruce Richardson <[email protected]>Acked-by Ciara Power <[email protected]>
Applied, thanks.
I'll post my suggestion as a patch aimed at 21.08.
Signature · 1 line
David Marchand