提交 16ba3266 编写于 作者: S stephen hemminger 提交者: David S. Miller

netvsc: propagate MAC address change to VF slave

If VF is slaved to synthetic device, then any change to netvsc
MAC address should be propagated to the slave device.

If slave device doesn't support MAC address change then it
should also be an error to attempt to change synthetic NIC MAC
address.

It also fixes the error unwind in the original code.
If give a bad address, the old code would change the device
MAC address anyway.
Reviewed-by: NHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: NStephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 5e20d55a
...@@ -1053,27 +1053,31 @@ static void netvsc_get_stats64(struct net_device *net, ...@@ -1053,27 +1053,31 @@ static void netvsc_get_stats64(struct net_device *net,
static int netvsc_set_mac_addr(struct net_device *ndev, void *p) static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
{ {
struct net_device_context *ndc = netdev_priv(ndev); struct net_device_context *ndc = netdev_priv(ndev);
struct net_device *vf_netdev = rtnl_dereference(ndc->vf_netdev);
struct netvsc_device *nvdev = rtnl_dereference(ndc->nvdev); struct netvsc_device *nvdev = rtnl_dereference(ndc->nvdev);
struct sockaddr *addr = p; struct sockaddr *addr = p;
char save_adr[ETH_ALEN];
unsigned char save_aatype;
int err; int err;
memcpy(save_adr, ndev->dev_addr, ETH_ALEN); err = eth_prepare_mac_addr_change(ndev, p);
save_aatype = ndev->addr_assign_type; if (err)
err = eth_mac_addr(ndev, p);
if (err != 0)
return err; return err;
if (!nvdev) if (!nvdev)
return -ENODEV; return -ENODEV;
if (vf_netdev) {
err = dev_set_mac_address(vf_netdev, addr);
if (err)
return err;
}
err = rndis_filter_set_device_mac(nvdev, addr->sa_data); err = rndis_filter_set_device_mac(nvdev, addr->sa_data);
if (err != 0) { if (!err) {
/* roll back to saved MAC */ eth_commit_mac_addr_change(ndev, p);
memcpy(ndev->dev_addr, save_adr, ETH_ALEN); } else if (vf_netdev) {
ndev->addr_assign_type = save_aatype; /* rollback change on VF */
memcpy(addr->sa_data, ndev->dev_addr, ETH_ALEN);
dev_set_mac_address(vf_netdev, addr);
} }
return err; return err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册