From nobody Sat Nov 30 01:40:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1618328148; cv=none; d=zohomail.com; s=zohoarc; b=CBfLKhSPQqMSbdSYtmeI/D5i+D0iR4+/PBXjsdnkT9/QXsed5CZCcuE5TVDrEw09nH+5gMeFpXhTXBPQJu30iaOZN8PaA/MQS6pral04nbhnQXg54Zqs4gf7js1/9sfVGqoN8T199jooePAOa9FeJI+z/VSKYgntxyQlFT8K2W0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618328148; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7Feonz/mO/cq/WdojMt704H1bci5kL3SK7J3cYx/4Pc=; b=Pr2r2eUXfxtlr4aNQFparKLtNr4DBSp2+3Uvj2/NghtdWmmVtQhSjdkekxWLQoom7qqHvlN6yip+eg2DrLL+4VFGLD7tKKLMvSRaG503vrHQMD5JQ7bA1DWtp3Uz3M/hwslHdLTV5zlOsyeHpbCEpbMjmg5fVK7KVPzDF7dYWBk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618328148827849.2094973859962; Tue, 13 Apr 2021 08:35:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.109947.209864 (Exim 4.92) (envelope-from ) id 1lWL4g-0007qy-RE; Tue, 13 Apr 2021 15:35:34 +0000 Received: by outflank-mailman (output) from mailman id 109947.209864; Tue, 13 Apr 2021 15:35:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWL4g-0007qr-Ng; Tue, 13 Apr 2021 15:35:34 +0000 Received: by outflank-mailman (input) for mailman id 109947; Tue, 13 Apr 2021 15:25:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWKuo-0006pY-Ko for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 15:25:22 +0000 Received: from blyat.fensystems.co.uk (unknown [54.246.183.96]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f7f3b076-0fb4-4ab2-aed3-e323e66d1b82; Tue, 13 Apr 2021 15:25:21 +0000 (UTC) Received: from dolphin.home (unknown [IPv6:2a00:23c6:5495:5e00:72b3:d5ff:feb1:e101]) by blyat.fensystems.co.uk (Postfix) with ESMTPSA id 5E5C044289; Tue, 13 Apr 2021 15:25:18 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f7f3b076-0fb4-4ab2-aed3-e323e66d1b82 From: Michael Brown To: paul@xen.org, xen-devel@lists.xenproject.org, netdev@vger.kernel.org, wei.liu@kernel.org, pdurrant@amazon.com Cc: Michael Brown Subject: [PATCH] xen-netback: Check for hotplug-status existence before watching Date: Tue, 13 Apr 2021 16:25:12 +0100 Message-Id: <20210413152512.903750-1-mbrown@fensystems.co.uk> X-Mailer: git-send-email 2.30.2 In-Reply-To: <54659eec-e315-5dc5-1578-d91633a80077@xen.org> References: <54659eec-e315-5dc5-1578-d91633a80077@xen.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on blyat.fensystems.co.uk Content-Type: text/plain; charset="utf-8" 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 1f2565780 ("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 Reviewed-by: Paul Durrant --- drivers/net/xen-netback/xenbus.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xen= bus.c index a5439c130130..d24b7a7993aa 100644 --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c @@ -824,11 +824,15 @@ static void connect(struct backend_info *be) xenvif_carrier_on(be->vif); =20 unregister_hotplug_status_watch(be); - err =3D xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, NULL, - hotplug_status_changed, - "%s/%s", dev->nodename, "hotplug-status"); - if (!err) + if (xenbus_exists(XBT_NIL, dev->nodename, "hotplug-status")) { + err =3D xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, + NULL, hotplug_status_changed, + "%s/%s", dev->nodename, + "hotplug-status"); + if (err) + goto err; be->have_hotplug_status_watch =3D 1; + } =20 netif_tx_wake_all_queues(be->vif->dev); =20 --=20 2.29.2