Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3405606pxy; Mon, 26 Apr 2021 00:33:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGUxQOXclyqpqGp74rXyBndCy56onElxBeKa0EVSGvZmDFThzdCTywODRb+BhSECQyW8y3 X-Received: by 2002:a17:906:cb1:: with SMTP id k17mr17009066ejh.307.1619422434978; Mon, 26 Apr 2021 00:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619422434; cv=none; d=google.com; s=arc-20160816; b=QdujrvDnwMoO+FyhcOMpATOynK0mr0vo6kk39guFfaWsTGTv2m7DppffmV90+oOSD5 JPFHAqVWpL86oa0K/wNpiOatt264KBwfoRYCgfAyrZXuml44L0B8ERqJ/aPzUxyLU3rv OOk+T3XBZOSmvuJxx9XFkkBrFO2Q5AiLRYljyJGx9G0950jhgIfZIycibZiU43ct8HJ4 yWUXSfG13aZ1s6jSB+/qCdv0vdpheTyyeFHV51DBK8rKYoYJETJ0/IR8WZSjtEf5lfrq zz1hh8CtaFX66oOWnc8FG4isEX0zpjoH7irCus/L7De84mVRfYEUvJZK9X99xLzPsmAo S+Gw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F2Pn8h0WlJo8hjG9MfvR5W6r5T/TVTMkuTq7ehAaISI=; b=zLxQbKfP3YmhScTgygAAsW2FDRDnJudHESheufOJkZovl31guVAjbutBhLpKi26hRn OCfJJQDHGrslR0F+XOvjiNwhT+oNX6G+fC/+qYwwN88P9Xl26zi0j/ofOiT7E2iAhJmi KMJ+ukBhfznZGsKk6cEhtmjhFBlD6BbULlMm+DMKg/Tx5VN97aF2zmk0WwY8+CrHrv49 SykUAKZ8YHayl1zUGie0ur/SNMGu1+MSNn5cjcwf1VfwG8yoOGOv89S+forALQF5JNFc X2vVszbu/SZ/XQTeAJQxUWTPWYtnBHYDOkXwLE3rnByOqGDNzUR5bl1cZwyDzaHDT6Xi dDzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="OueoRh/m"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cr12si12834165ejc.735.2021.04.26.00.33.31; Mon, 26 Apr 2021 00:33:54 -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=@linuxfoundation.org header.s=korg header.b="OueoRh/m"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232173AbhDZHcw (ORCPT + 99 others); Mon, 26 Apr 2021 03:32:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:43982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232475AbhDZHcl (ORCPT ); Mon, 26 Apr 2021 03:32:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E195F6105A; Mon, 26 Apr 2021 07:31:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1619422320; bh=LNmDORbHzwjYQgKNtkXmiz0lTOoSO02E+FDmaI6F82M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OueoRh/m03hneV9mCkgdBunIlTgFBpPS5ta9Qv6RbQU/cHcwNgK5pzc03x7jWoLlF OnZQaCkQ0gxC0sVxKhcFCDcLvix+rQbEEYRX6Q3oIq9VHQa/KmCgLixcW/E91As4io k5hTNa9LoeTmM54LMd3HQAhvMscVsoJ83qRnXlOw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Brown , Paul Durrant , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 26/32] xen-netback: Check for hotplug-status existence before watching Date: Mon, 26 Apr 2021 09:29:24 +0200 Message-Id: <20210426072817.450766952@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210426072816.574319312@linuxfoundation.org> References: <20210426072816.574319312@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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