12/10/2021 04:58, lihuisong (C): > 在 2021/10/11 18:35, Thomas Monjalon 写道: > > 11/10/2021 11:28, Min Hu (Connor): > >> From: Huisong Li <lihuis...@huawei.com> > >> > >> The dev->data->mac_addrs[0] will be changed to a new MAC address when > >> applications modify the default MAC address by > >> rte_eth_dev_default_mac_addr_set() API. However, If the new default > >> MAC address has been added as a non-default MAC address by > >> rte_eth_dev_mac_addr_add() API, the rte_eth_dev_default_mac_addr_set() > >> API doesn't remove it from dev->data->mac_addrs[]. As a result, one MAC > >> address occupies two index capacities in dev->data->mac_addrs[]. > >> > >> This patch adds the logic of removing MAC addresses for this scenario. > >> > >> Fixes: 854d8ad4ef68 ("ethdev: add default mac address modifier") > >> Cc: sta...@dpdk.org > >> > >> Signed-off-by: Huisong Li <lihuis...@huawei.com> > >> Signed-off-by: Min Hu (Connor) <humi...@huawei.com> > >> --- > >> + /* > >> + * If the address has been added as a non-default MAC address by > >> + * rte_eth_dev_mac_addr_add API, it should be removed from > >> + * dev->data->mac_addrs[]. > >> + */ > > This is the definition of mac_addrs: > > > > struct rte_ether_addr *mac_addrs; > > /**< Device Ethernet link address. > > * @see rte_eth_dev_release_port() > > */ > > > > I feel we need to explain there can be multiple addresses, > > the first one being the default. > > Do you mean that the problem mentioned in this patch is not a problem?
It is not a problem if it is expected, but nothing is defined. > Should we accept this scenario? We need to decide what is the correct behaviour. I see pros and cons on both sides. > > Another comment, > > If we remove the duplicate, we may have to copy to previous default one > > to avoid completely deleting the previous default address. > > That's not necessary. > > Because the previous default address has been removed from hardware. > > After the default MAC address is modified, the previous default one is > invalid. No you don't get it. With the current behaviour, the app could keep all the MAC addresses, and copy one as the default while keeping it in the rest of the list. You are suggesting a different behaviour where there is no duplicate. > > Not sure what should be the behaviour.