lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <qfswutrrnmk6cksyamjx4ywv4kkxcb76vfqqszodzo7ltze5r6@c2dsseiez4ik>
Date: Wed, 5 Nov 2025 10:12:52 +0000
From: Dragos Tatulea <dtatulea@...dia.com>
To: Cindy Lu <lulu@...hat.com>, mst@...hat.com, jasowang@...hat.com, 
	netdev@...r.kernel.org, virtualization@...ts.linux-foundation.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] vdpa/mlx5: update MAC address handling in
 mlx5_vdpa_set_attr()

On Wed, Nov 05, 2025 at 04:01:42PM +0800, Cindy Lu wrote:
> Improve MAC address handling in mlx5_vdpa_set_attr() to ensure
> that old MAC entries are properly removed from the MPFS table
> before adding a new one. The new MAC address is then added to
> both the MPFS and VLAN tables.
> 
> Warnings are issued if deleting or adding a MAC entry fails, but
> the function continues to execute in order to keep the configuration
> as consistent as possible with the hardware state.
> 
> This change fixes an issue where the updated MAC address would not
> take effect until the qemu was rebooted
>
Can you remind me how you provision the MAC address throug .set_attr()
instead ofa the CVQ route?

> Signed-off-by: Cindy Lu <lulu@...hat.com>
> ---
>  drivers/vdpa/mlx5/net/mlx5_vnet.c | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index e38aa3a335fc..4bc39cb76268 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -4067,10 +4067,26 @@ static int mlx5_vdpa_set_attr(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *
>  	down_write(&ndev->reslock);
>  	if (add_config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) {
>  		pfmdev = pci_get_drvdata(pci_physfn(mdev->pdev));
> -		err = mlx5_mpfs_add_mac(pfmdev, config->mac);
> -		if (!err)
> +		if (!is_zero_ether_addr(ndev->config.mac)) {
> +			if (mlx5_mpfs_del_mac(pfmdev, ndev->config.mac)) {
> +				mlx5_vdpa_warn(mvdev,"failed to delete old MAC %pM from MPFS table\n",
> +					ndev->config.mac);
> +			}
> +		}
> +		err = mlx5_mpfs_add_mac(pfmdev, (u8 *)add_config->net.mac);
> +		if (!err) {
> +			mac_vlan_del(ndev, config->mac, 0, false);
>  			ether_addr_copy(config->mac, add_config->net.mac);
> +		} else {
> +			mlx5_vdpa_warn(mvdev,"failed to add new MAC %pM to MPFS table\n",
> +				(u8 *)add_config->net.mac);
> +			up_write(&ndev->reslock);
> +			return err;
> +		}
Code reorg suggestion for this block:
err = mlx5_mpfs_add_mac();
if (err) {
	warn();
	return err;
}

mac_vlan_del();
ether_addr_copy();

>  	}
> +	if (mac_vlan_add(ndev, ndev->config.mac, 0, false))
> +		mlx5_vdpa_warn(mvdev,"failed to add new MAC %pM to vlan table\n",
> +			       (u8 *)add_config->net.mac);
>
Have you considered factoring out the MAC changing code from
hanle_ctrl_mac() into a function and using it here? Most of the
operations are the same.


Thanks,
Dragos

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ