Skip to content

Commit

Permalink
net/bnxt: cap maximum number of unicast MAC addresses
Browse files Browse the repository at this point in the history
[ upstream commit 604a6be ]

The Maximum number of receive mac addr is hard coded to 128
in the ethdev library(RTE_ETH_NUM_RECEIVE_MAC_ADDR).
But the bnxt devices support more than 128 unicast MAC filters
which could result in a segfault while user tries to add more
than 128 unicast MAC addresses to the port.

Fixes: a2033fd ("net/bnxt: fix number of MAC addresses for VMDq")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
  • Loading branch information
Kalesh AP authored and bluca committed Feb 14, 2022
1 parent fa8cc81 commit 5889a24
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/net/bnxt/bnxt_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
return rc;

/* MAC Specifics */
dev_info->max_mac_addrs = bp->max_l2_ctx;
dev_info->max_mac_addrs = RTE_MIN(bp->max_l2_ctx, RTE_ETH_NUM_RECEIVE_MAC_ADDR);
dev_info->max_hash_mac_addrs = 0;

/* PF/VF specifics */
Expand Down Expand Up @@ -4781,11 +4781,15 @@ static int bnxt_alloc_stats_mem(struct bnxt *bp)
static int bnxt_setup_mac_addr(struct rte_eth_dev *eth_dev)
{
struct bnxt *bp = eth_dev->data->dev_private;
size_t max_mac_addr = RTE_MIN(bp->max_l2_ctx, RTE_ETH_NUM_RECEIVE_MAC_ADDR);
int rc = 0;

if (bp->max_l2_ctx > RTE_ETH_NUM_RECEIVE_MAC_ADDR)
PMD_DRV_LOG(INFO, "Max number of MAC addrs supported is %d, but will be limited to %d\n",
bp->max_l2_ctx, RTE_ETH_NUM_RECEIVE_MAC_ADDR);

eth_dev->data->mac_addrs = rte_zmalloc("bnxt_mac_addr_tbl",
RTE_ETHER_ADDR_LEN *
bp->max_l2_ctx,
RTE_ETHER_ADDR_LEN * max_mac_addr,
0);
if (eth_dev->data->mac_addrs == NULL) {
PMD_DRV_LOG(ERR, "Failed to alloc MAC addr tbl\n");
Expand Down

0 comments on commit 5889a24

Please sign in to comment.