From: Stephen Hemminger <stephen@networkplumber.org>
To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com
Cc: devel@linuxdriverproject.org, netdev@vger.kernel.org
Subject: [PATCH net-next 03/10] netvsc: propagate MAC address change to VF slave
Date: Wed, 9 Aug 2017 17:46:05 -0700 [thread overview]
Message-ID: <20170810004612.22163-4-sthemmin@microsoft.com> (raw)
In-Reply-To: <20170810004612.22163-1-sthemmin@microsoft.com>
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: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
drivers/net/hyperv/netvsc_drv.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index e059375a6d8c..07015b1c42c6 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -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)
{
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 sockaddr *addr = p;
- char save_adr[ETH_ALEN];
- unsigned char save_aatype;
int err;
- memcpy(save_adr, ndev->dev_addr, ETH_ALEN);
- save_aatype = ndev->addr_assign_type;
-
- err = eth_mac_addr(ndev, p);
- if (err != 0)
+ err = eth_prepare_mac_addr_change(ndev, p);
+ if (err)
return err;
if (!nvdev)
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);
- if (err != 0) {
- /* roll back to saved MAC */
- memcpy(ndev->dev_addr, save_adr, ETH_ALEN);
- ndev->addr_assign_type = save_aatype;
+ if (!err) {
+ eth_commit_mac_addr_change(ndev, p);
+ } else if (vf_netdev) {
+ /* rollback change on VF */
+ memcpy(addr->sa_data, ndev->dev_addr, ETH_ALEN);
+ dev_set_mac_address(vf_netdev, addr);
}
return err;
--
2.11.0
next prev parent reply other threads:[~2017-08-10 0:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-10 0:46 [PATCH net-next 00/10] netvsc: minor fixes and improvements Stephen Hemminger
2017-08-10 0:46 ` [PATCH net-next 01/10] netvsc: delay setup of VF device Stephen Hemminger
2017-08-10 0:46 ` [PATCH net-next 02/10] netvsc: don't signal host twice if empty Stephen Hemminger
2017-08-10 0:46 ` Stephen Hemminger [this message]
2017-08-10 0:46 ` [PATCH net-next 04/10] netvsc: check error return when restoring channels and mtu Stephen Hemminger
2017-08-10 0:46 ` [PATCH net-next 05/10] netvsc: no need to allocate send/receive on numa node Stephen Hemminger
2017-08-10 0:46 ` [PATCH net-next 06/10] netvsc: whitespace cleanup Stephen Hemminger
2017-08-10 0:46 ` [PATCH net-next 07/10] netvsc: remove unnecessary cast of void pointer Stephen Hemminger
2017-08-10 0:46 ` [PATCH net-next 08/10] netvsc: remove unnecessary check for NULL hdr Stephen Hemminger
2017-08-10 0:46 ` [PATCH net-next 09/10] netvsc: allow controlling send/recv buffer size Stephen Hemminger
2017-08-10 0:46 ` [PATCH net-next 10/10] netvsc: keep track of some non-fatal overload conditions Stephen Hemminger
2017-08-11 21:00 ` [PATCH net-next 00/10] netvsc: minor fixes and improvements David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170810004612.22163-4-sthemmin@microsoft.com \
--to=stephen@networkplumber.org \
--cc=devel@linuxdriverproject.org \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=sthemmin@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox