Skip to contentSkip to conversation

hv_netvsc: notification and namespace fixes

PATCH In review Stephen Hemminger 3 participants 7 messages Jun 11, 2018 – Jun 12, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover hv_netvsc: notification and namespace fixes

This set of patches addresses two set of fixes. First it backs out the common callback model which was merged in net-next without completing all the review feedback or getting maintainer approval.

Then it fixes the transparent VF management code to handle network namespaces.

Stephen Hemminger (3):
hv_netvsc: drop common code until callback model fixed
hv_netvsc: fix network namespace issues with VF support
hv_netvsc: move VF to same namespace as netvsc device

 drivers/net/hyperv/Kconfig      |   1 -
 drivers/net/hyperv/hyperv_net.h |   4 +-
 drivers/net/hyperv/netvsc_drv.c | 242 ++++++++++++++++++++++++--------
 3 files changed, 184 insertions(+), 63 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/3 hv_netvsc: drop common code until callback model fixed

The callback model of handling network failover is not suitable in the current form.
1. It was merged without addressing all the review feedback.
2. It was merged without approval of any of the netvsc maintainers.
3. Design discussion on how to handle PV/VF fallback is still not complete.
4. IMHO the code model using callbacks is trying to make something common which isn't.

Revert the netvsc specific changes for now. Does not impact ongoing development of failover model for virtio.
Revisit this after a simpler library based failover kernel routines are extracted.

This reverts
commit 9c6ffbacdb57 ("hv_netvsc: fix error return code in netvsc_probe()")
and
commit 1ff78076d8dd ("netvsc: refactor notifier/event handling code to use the failover framework")

---
 drivers/net/hyperv/Kconfig      |   1 -
 drivers/net/hyperv/hyperv_net.h |   2 -
 drivers/net/hyperv/netvsc_drv.c | 224 +++++++++++++++++++++++---------
 3 files changed, 165 insertions(+), 62 deletions(-)
drivers/net/hyperv/Kconfig +0 -1
index 23a2d145813a..0765d5f61714 100644
@@ -2,6 +2,5 @@ config HYPERV_NET
 	tristate "Microsoft Hyper-V virtual network driver"
 	depends on HYPERV
 	select UCS2_STRING
-	select FAILOVER
 	help
 	  Select this option to enable the Hyper-V virtual network driver.
drivers/net/hyperv/hyperv_net.h +0 -2
index 99d8e7398a5b..1be34d2e3563 100644
@@ -932,8 +932,6 @@ struct net_device_context {
 	u32 vf_alloc;
 	/* Serial number of the VF to team with */
 	u32 vf_serial;
-
-	struct failover *failover;
 };
 
 /* Per channel data */
drivers/net/hyperv/netvsc_drv.c +165 -59

324 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/3 hv_netvsc: fix network namespace issues with VF support

In reply to Stephen Hemminger

When finding the parent netvsc device, the search needs to be across all netvsc device instances (independent of network namespace).

Find parent device of VF using upper_dev_get routine which searches only adjacent list.

Fixes e8ff40d4bff1 ("hv_netvsc: improve VF device matching")

netns aware byref

---
 drivers/net/hyperv/hyperv_net.h |  2 ++
 drivers/net/hyperv/netvsc_drv.c | 43 +++++++++++++++------------------
 2 files changed, 22 insertions(+), 23 deletions(-)
drivers/net/hyperv/hyperv_net.h +2 -0
index 1be34d2e3563..c0b3f3c125d4 100644
@@ -902,6 +902,8 @@ struct net_device_context {
 	struct hv_device *device_ctx;
 	/* netvsc_device */
 	struct netvsc_device __rcu *nvdev;
+	/* list of netvsc net_devices */
+	struct list_head list;
 	/* reconfigure work */
 	struct delayed_work dwork;
 	/* last reconfig time */
drivers/net/hyperv/netvsc_drv.c +20 -23

85 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

Re: [PATCH net 2/3] hv_netvsc: fix network namespace issues with VF support

Quoted 10 lines · Stephen Hemminger

When finding the parent netvsc device, the search needs to be across all netvsc device instances (independent of network namespace).

Find parent device of VF using upper_dev_get routine which searches only adjacent list.

Fixes e8ff40d4bff1 ("hv_netvsc: improve VF device matching")

netns aware byref

What? Presumably that wasn't supposed to be part of the commit message.

Quoted 1 line

---

regards,
dan carpenter

#4 lore raw

Re: [PATCH net 2/3] hv_netvsc: fix network namespace issues with VF support

Quoted 7 lines · On Tue, 12 Jun 2018 12:51:28 +0300 Dan Carpenter <[email protected]>…
Quoted 6 lines · Stephen Hemminger

When finding the parent netvsc device, the search needs to be across all netvsc device instances (independent of network namespace).

Find parent device of VF using upper_dev_get routine which searches only adjacent list.

Quoted 6 lines
Quoted 4 lines
Fixes e8ff40d4bff1 ("hv_netvsc: improve VF device matching")

netns aware byref

What? Presumably that wasn't supposed to be part of the commit message.

That was leftover from earlier commit message

#5 lore raw

PATCH 3/3 hv_netvsc: move VF to same namespace as netvsc device

In reply to Stephen Hemminger

When VF is added, the paravirtual device is already present and may have been moved to another network namespace. For example, sometimes the management interface is put in another net namespace in some environments.

The VF should get moved to where the netvsc device is when the VF is discovered. The user can move it later (if desired).

---
 drivers/net/hyperv/netvsc_drv.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/net/hyperv/netvsc_drv.c +20 -1
index 8cb21e013d1d..bf1b845c1147 100644
@@ -1930,6 +1930,7 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
 	struct net_device *ndev;
 	struct net_device_context *net_device_ctx;
 	struct netvsc_device *netvsc_dev;
+	int ret;
 
 	if (vf_netdev->addr_len != ETH_ALEN)
 		return NOTIFY_DONE;
@@ -1948,11 +1949,29 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
 	if (!netvsc_dev || rtnl_dereference(net_device_ctx->vf_netdev))
 		return NOTIFY_DONE;
 
-	if (netvsc_vf_join(vf_netdev, ndev) != 0)
+	/* if syntihetic interface is a different namespace,
+	 * then move the VF to that namespace; join will be
+	 * done again in that context.
+	 */
+	if (!net_eq(dev_net(ndev), dev_net(vf_netdev))) {
+		ret = dev_change_net_namespace(vf_netdev,
+					       dev_net(ndev), "eth%d");
+		if (ret)
+			netdev_err(vf_netdev,
+				   "could not move to same namespace as %s: %d\n",
+				   ndev->name, ret);
+		else
+			netdev_info(vf_netdev,
+				    "VF moved to namespace with: %s\n",
+				    ndev->name);
 		return NOTIFY_DONE;
+	}
 
 	netdev_info(ndev, "VF registering: %s\n", vf_netdev->name);
 
+	if (netvsc_vf_join(vf_netdev, ndev) != 0)
+		return NOTIFY_DONE;
+
 	dev_hold(vf_netdev);
 	rcu_assign_pointer(net_device_ctx->vf_netdev, vf_netdev);
 	return NOTIFY_OK;
Signature · 1 line
2.17.1
maintainer
#6 lore raw
In reply to Stephen Hemminger

From: Stephen Hemminger <[email protected]>
Date: Mon, 11 Jun 2018 12:44:53 -0700

Quoted 6 lines

This set of patches addresses two set of fixes. First it backs out the common callback model which was merged in net-next without completing all the review feedback or getting maintainer approval.

Then it fixes the transparent VF management code to handle network namespaces.

Series applied.