[dpdk-dev] net/ixgbe: Put correct id values in ixgbevf_dev_xstats_get

Message ID 2C3EBBD2-41D9-4E03-B53A-2EF140C3B15D@cisco.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/Intel-compilation success Compilation OK

Commit Message

Ido Barnea (ibarnea) March 7, 2017, 2:28 p.m. UTC
  Without setting the id, calling xstats_get twice with same array causes memory corruption.
Also, if IXGBEVF_NB_XSTATS will be different than 1 in the future, this will cause issues.

Signed-off-by: Ido Barnea <ibarnea@cisco.com>

---
 drivers/net/ixgbe/ixgbe_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Ferruh Yigit March 9, 2017, 4:46 p.m. UTC | #1
On 3/7/2017 2:28 PM, Ido Barnea (ibarnea) wrote:
> Without setting the id, calling xstats_get twice with same array causes memory corruption.
> Also, if IXGBEVF_NB_XSTATS will be different than 1 in the future, this will cause issues.
> 
> Signed-off-by: Ido Barnea <ibarnea@cisco.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
  
Ferruh Yigit March 9, 2017, 5:16 p.m. UTC | #2
On 3/9/2017 4:46 PM, Ferruh Yigit wrote:
> On 3/7/2017 2:28 PM, Ido Barnea (ibarnea) wrote:
>> Without setting the id, calling xstats_get twice with same array causes memory corruption.
>> Also, if IXGBEVF_NB_XSTATS will be different than 1 in the future, this will cause issues.
>>
>> Signed-off-by: Ido Barnea <ibarnea@cisco.com>
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 7169007..b699252 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -3249,6 +3249,7 @@  ixgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
	/* Extended stats */
 	for (i = 0; i < IXGBEVF_NB_XSTATS; i++) {
+		xstats[i].id = i;
 		xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
 			rte_ixgbevf_stats_strings[i].offset);
 	}
-- 
2.8.3