Skip to content

Commit

Permalink
net/bnxt: fix getting statistics
Browse files Browse the repository at this point in the history
[ upstream commit 75306ee ]

Avoid overrun in rte_eth_stats struct when the number of tx/rx
rings in use is greater than RTE_ETHDEV_QUEUE_STAT_CNTRS.

Fixes: 57d5e5b ("net/bnxt: add statistics")

Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
  • Loading branch information
Lance Richardson authored and kevintraynor committed Aug 28, 2019
1 parent 0ec58c0 commit 7ce0d38
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/net/bnxt/bnxt_stats.c
Expand Up @@ -350,14 +350,18 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,
int rc = 0;
unsigned int i;
struct bnxt *bp = eth_dev->data->dev_private;
unsigned int num_q_stats;

memset(bnxt_stats, 0, sizeof(*bnxt_stats));
if (!(bp->flags & BNXT_FLAG_INIT_DONE)) {
PMD_DRV_LOG(ERR, "Device Initialization not complete!\n");
return -1;
}

for (i = 0; i < bp->rx_cp_nr_rings; i++) {
num_q_stats = RTE_MIN(bp->rx_cp_nr_rings,
(unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS);

for (i = 0; i < num_q_stats; i++) {
struct bnxt_rx_queue *rxq = bp->rx_queues[i];
struct bnxt_cp_ring_info *cpr = rxq->cp_ring;

Expand All @@ -369,7 +373,10 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,
rte_atomic64_read(&rxq->rx_mbuf_alloc_fail);
}

for (i = 0; i < bp->tx_cp_nr_rings; i++) {
num_q_stats = RTE_MIN(bp->tx_cp_nr_rings,
(unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS);

for (i = 0; i < num_q_stats; i++) {
struct bnxt_tx_queue *txq = bp->tx_queues[i];
struct bnxt_cp_ring_info *cpr = txq->cp_ring;

Expand Down

0 comments on commit 7ce0d38

Please sign in to comment.