Skip to contentSkip to conversation

telemetry: fix struct reset after value assignment

PATCH Applied Ciara Power 3 participants 5 messages Feb 27, 2020 – Mar 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 telemetry: fix struct reset after value assignment

The ep struct is used to track what type of stats are required by the client. For PORT_STATS type, it contains the lists of port and metric ids to query, and the number of ids in each list.

The ep struct has values set (num of port and metric ids) when a request for port stats values by name is received. However, after this value assignment, the struct is reset to all 0 values, meaning the number of port and metric ids required now both show as 0, and the client will not receive the requested data in response. To fix this issue, the memset call is now moved above the ep struct value assignment.

Fixes 4080e46c8078 ("telemetry: support global metrics")
---
 lib/librte_telemetry/rte_telemetry_parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_telemetry/rte_telemetry_parser.c +1 -1
index 960132397..e8c269e85 100644
@@ -456,9 +456,9 @@ rte_telemetry_command_ports_stats_values_by_name(struct telemetry_impl
 	size_t index;
 	json_t *value;
 
+	memset(&ep, 0, sizeof(ep));
 	ep.pp.num_port_ids = json_array_size(port_ids_json);
 	ep.pp.num_metric_ids = num_stat_names;
-	memset(&ep, 0, sizeof(ep));
 	if (telemetry == NULL) {
 		TELEMETRY_LOG_ERR("Invalid telemetry argument");
 		return -1;
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines

The ep struct is used to track what type of stats are required by the client. For PORT_STATS type, it contains the lists of port and metric ids to query, and the number of ids in each list.

The ep struct has values set (num of port and metric ids) when a request for port stats values by name is received. However, after this value assignment, the struct is reset to all 0 values, meaning the number of port and metric ids required now both show as 0, and the client will not receive the requested data in response. To fix this issue, the memset call is now moved above the ep struct value assignment.

Quoted 5 lines
Fixes 4080e46c8078 ("telemetry: support global metrics")
#2 lore raw

Hello,

Quoted 12 lines · Kevin
Quoted 12 lines

The ep struct is used to track what type of stats are required by the client. For PORT_STATS type, it contains the lists of port and metric ids to query, and the number of ids in each list.

The ep struct has values set (num of port and metric ids) when a request for port stats values by name is received. However, after this value assignment, the struct is reset to all 0 values, meaning the number of port and metric ids required now both show as 0, and the client will not receive the requested data in response. To fix this issue, the memset call is now moved above the ep struct value assignment.

Quoted 8 lines
Quoted 5 lines
Fixes 4080e46c8078 ("telemetry: support global metrics")

For the title, how about:
telemetry: fix port stats retrieval

I can fix while applying.

Signature · 1 line
David Marchand
#3 lore raw

Hi David,

Quoted 27 lines

Hello,

Quoted 2 lines · Kevin
Quoted 2 lines

The ep struct is used to track what type of stats are required by the

client.

Quoted 9 lines
Quoted 9 lines

For PORT_STATS type, it contains the lists of port and metric ids to query, and the number of ids in each list.

The ep struct has values set (num of port and metric ids) when a request for port stats values by name is received. However, after this value assignment, the struct is reset to all 0 values, meaning the number of port and metric ids required now both show as 0, and the client will not receive the requested data in response. To fix this issue, the memset call is now moved above the ep struct value

assignment.

Quoted 9 lines
Quoted 6 lines
Fixes 4080e46c8078 ("telemetry: support global metrics")
Quoted 8 lines

For the title, how about:
telemetry: fix port stats retrieval

I can fix while applying.

--
David Marchand

That title change is okay with me, thanks.

- Ciara

#4 lore raw
In reply to Laatz, Kevin
Quoted 12 lines · Kevin
Quoted 12 lines

The ep struct is used to track what type of stats are required by the client. For PORT_STATS type, it contains the lists of port and metric ids to query, and the number of ids in each list.

The ep struct has values set (num of port and metric ids) when a request for port stats values by name is received. However, after this value assignment, the struct is reset to all 0 values, meaning the number of port and metric ids required now both show as 0, and the client will not receive the requested data in response. To fix this issue, the memset call is now moved above the ep struct value assignment.

Quoted 7 lines
Quoted 5 lines
Fixes 4080e46c8078 ("telemetry: support global metrics")

Applied, thanks.

Signature · 1 line
David Marchand