Skip to content

Commit 2afeec0

Browse files
mcb30davem330
authored andcommitted
xen-netback: Check for hotplug-status existence before watching
The logic in connect() is currently written with the assumption that xenbus_watch_pathfmt() will return an error for a node that does not exist. This assumption is incorrect: xenstore does allow a watch to be registered for a nonexistent node (and will send notifications should the node be subsequently created). As of commit 1f25657 ("xen-netback: remove 'hotplug-status' once it has served its purpose"), this leads to a failure when a domU transitions into XenbusStateConnected more than once. On the first domU transition into Connected state, the "hotplug-status" node will be deleted by the hotplug_status_changed() callback in dom0. On the second or subsequent domU transition into Connected state, the hotplug_status_changed() callback will therefore never be invoked, and so the backend will remain stuck in InitWait. This failure prevents scenarios such as reloading the xen-netfront module within a domU, or booting a domU via iPXE. There is unfortunately no way for the domU to work around this dom0 bug. Fix by explicitly checking for existence of the "hotplug-status" node, thereby creating the behaviour that was previously assumed to exist. Signed-off-by: Michael Brown <mbrown@fensystems.co.uk> Reviewed-by: Paul Durrant <paul@xen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 38ec494 commit 2afeec0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/net/xen-netback/xenbus.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -824,11 +824,15 @@ static void connect(struct backend_info *be)
824824
xenvif_carrier_on(be->vif);
825825

826826
unregister_hotplug_status_watch(be);
827-
err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, NULL,
828-
hotplug_status_changed,
829-
"%s/%s", dev->nodename, "hotplug-status");
830-
if (!err)
827+
if (xenbus_exists(XBT_NIL, dev->nodename, "hotplug-status")) {
828+
err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch,
829+
NULL, hotplug_status_changed,
830+
"%s/%s", dev->nodename,
831+
"hotplug-status");
832+
if (err)
833+
goto err;
831834
be->have_hotplug_status_watch = 1;
835+
}
832836

833837
netif_tx_wake_all_queues(be->vif->dev);
834838

0 commit comments

Comments
 (0)