Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2832155pxb; Mon, 19 Apr 2021 15:25:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4Ws9SbeyV07/oJ8S5DKqXAdcapPPQIy9h723EA/fUSwDQ6k1SPvGQATqg9m0apuynqb69 X-Received: by 2002:a17:90a:a4c9:: with SMTP id l9mr1393369pjw.21.1618871142741; Mon, 19 Apr 2021 15:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618871142; cv=none; d=google.com; s=arc-20160816; b=x/O0jrA2aZEkPKrGl2+fezTjBhU9soTPxA6vPOp/SVZNRQ0s2MsSVXqPAecR4gvn1B iCiy7iZe7Uan+gTT0uxMlGEIl2Hz2OYpBepPpdjF5ZyG2/gMfh258pY7+BZ19OGgwqy8 Hkv0hBANHE2hSHQY+r0wW/cwHAC+u/hqOd0cNBF0Ire+XN7Sc+MWahY5zipbKG9+MAeQ Oby+sTJJy5SwrN8psMvajVZg8slOcvYEKvXavQujHEAeobCAd8Tyv49FTGQa9f5+Ty1w E2elrYMu5oF8mId5nFAP7bVuxJV04IARtdIppwzZC/MhU2UAJfgUvKnrgXY6FBnd9oFo 9oeA== 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=F2Pn8h0WlJo8hjG9MfvR5W6r5T/TVTMkuTq7ehAaISI=; b=YZuQiN3hPfmmnuZ8dQM7G+qEhLRYOmtzpIP2C15gtV1z0ocg47t/G30fF6ehcfYuoZ oU4qSZX+h/tvoTBF+G1q5gUqhWIsuISzV4YSjB7uezluUZXA0J5bze1of7TMRzIsyeKU 71Fq5umCsyO5Kzn+WR+kwanAQpMD4VGGkKxqnyWC5JpbQgMBFrz4bsu78jWK7epZA4ub WY0bbGc8DmTeCmmVqadAknd6Mq0yCyFqaLg3jByp7n74185EVNdf+PA70XhQL0evNVKT nvoj1HjO0CTK45OljtIitzkG4w5pFMxLfh5IZe36JZ8JDd5N5UEJek4GL2u7kMzxs6T+ uhHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wb6AqxaC; 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.25.31; Mon, 19 Apr 2021 15:25:42 -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=Wb6AqxaC; 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 S243520AbhDSUwc (ORCPT + 99 others); Mon, 19 Apr 2021 16:52:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:59394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242673AbhDSUuB (ORCPT ); Mon, 19 Apr 2021 16:50:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 73F13613F9; Mon, 19 Apr 2021 20:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618865174; bh=LNmDORbHzwjYQgKNtkXmiz0lTOoSO02E+FDmaI6F82M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wb6AqxaCi4a8rPeH6RaL8l0Q1iSlsGQVUYMsbsdtkoF1mdPVzBXldMgxrMFN5+RAO /y2gY3dm4LicU3kpTVwEWBn6gzX1aye6brxacDp8mmdVistyzW67ez7lo27kMfyfNw 3LS/gicY7NAB8VxmL9F/qyyLZ3P5JnJNzDK1j0s2ezJK4SjkDkpfp719xHp5wVnKBb 4kpWlnFcVFx0hl+1Y6KybMT1QKVRCKDWQRE4Q1rjVwG8bzNXRohCmF6JBzv1+mB8MX deI4Yh3+qmaCeS/bRgNtvvGagK6NKS5K2/jI3kb7XMYj5USZ1uy4p1qXqdTDG0Ql6q szIPIPRAtItbw== 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 4.4 3/7] xen-netback: Check for hotplug-status existence before watching Date: Mon, 19 Apr 2021 16:46:04 -0400 Message-Id: <20210419204608.7191-3-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210419204608.7191-1-sashal@kernel.org> References: <20210419204608.7191-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 21c8e2720b40..683fd8560f2b 100644 --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c @@ -849,11 +849,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