Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2829335pxb; Mon, 19 Apr 2021 15:21:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJww6L1dlJuqD4uJJzc28riXS48jvQpzIuU5J9OiWHD1FZXWFzp0hfAJPySCOH7bQGww3nvS X-Received: by 2002:a17:90a:c78d:: with SMTP id gn13mr1332321pjb.81.1618870879242; Mon, 19 Apr 2021 15:21:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618870879; cv=none; d=google.com; s=arc-20160816; b=E14JmhV9esL5VqbG306HgrnGssw8UNWQvvitnmuQbfDWsU0aZ7YK1edE2wHRRT2APU qwf57lYv0dZYB7DEvNF9BdyGjo4bp7rc7MqMfZnTs8hi8e+8AwNecXvMFOf0kf14TQiV 23jbIm0veh45KkOTpyIDvBKMbwJj5VGOtiBsuUNTfo5IdLpbnsvHucFESLG7Nx7Q1Y/x 0rZ5OZBzjQcT8+1uwnd//z3BYo+Qe84EXwQyMVs4TWv4LXTdDVCUnQb7Kv7YLQdBkMCM AkBV+Pa3Np3nDemttEbp9+ub2czLdnoC8jCoXCzZQEPgokOcbKqvZZ/XQlu23irZeK40 GgHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qggKWHxc2EsEXrvWUGdnzrItGXsXVvpicRgCI2XC/R8=; b=pthgTKJJyLzqwfSe/Ll4LktNzGvA+SozBO8qSooRoc/nzISg3o3BhhWCMzu2jNIeoS 2XcpVV6AFVM1R4dRulaR8B8h5nmMVvl/22M7nzlcHh4xbkkJk0ORjZEH9hQmWTYOXMUJ rhUpyhUmGMhrIccgp/bEd9ou4FV74IuzVJuQTD0kBIBNKTw0neXcAquciqyyLDFwXL9y 9W153n5Mtmn39rTz+xWStE8IuUKadysXUFvg7RThNsWrzf6BlZ3iyYFwCmfVWsdvzQ3+ B1wyp7G+BuEvZkHsdsFa+KQs4F/93ncaC+P/86ldHuejdSAhoREhe623Bw1nfmkRa49e 7BWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MDBJgDB5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 185si22180865pgj.455.2021.04.19.15.21.07; Mon, 19 Apr 2021 15:21:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MDBJgDB5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240273AbhDSUpS (ORCPT + 99 others); Mon, 19 Apr 2021 16:45:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:54212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242413AbhDSUog (ORCPT ); Mon, 19 Apr 2021 16:44:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E524161104; Mon, 19 Apr 2021 20:44:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618865045; bh=3m3lFg+7CrTJgU9IHDfJ4YqA/Dn5bG9FWVMD5FrUKY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MDBJgDB5j4W5MX9rnasxo5ZovYtRzLaWDg8FkZ2qabfBW8FAcW7PN0ZyWZfQ8DGAo bYLGwAryKjzHGRxKNrTfILehYFJUleLHcuWhJJGDLhhTggjYb9L1OoVf6ck8fbwwXU 04ti7rq1BPZxuZdVUfjiwU+zManH2EithFeAps3v5TbyHHrBUwewsigzq7enmgf/mK KEaMjcpCK5dk2BSUKeeho9v69Kk76PBzEw/ZHRnSfwVNnAsOArxLQriZIRMNerl9ZC UNJ8mqzk4Pf5RMnuSTPD/hNmiMNWoFGwbYj/tIB1qLupRv4gwDUfsKXVDZAy4mvVed dNoMJwe3vs9Og== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Michael Brown , Paul Durrant , "David S . Miller" , Sasha Levin , xen-devel@lists.xenproject.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.11 15/23] xen-netback: Check for hotplug-status existence before watching Date: Mon, 19 Apr 2021 16:43:34 -0400 Message-Id: <20210419204343.6134-15-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210419204343.6134-1-sashal@kernel.org> References: <20210419204343.6134-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Brown [ Upstream commit 2afeec08ab5c86ae21952151f726bfe184f6b23d ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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/xenbus.c index 6f10e0998f1c..94d19158efc1 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); unregister_hotplug_status_watch(be); - err = 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 = 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 = 1; + } netif_tx_wake_all_queues(be->vif->dev); -- 2.30.2