Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2234662imm; Thu, 18 Oct 2018 11:08:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV61H4GAizxtXeXR3AhWOP7BbAlj5V4UyfkfHad4FK12uQkvvWjhS2WK6GznhgFegwebfXgZZ X-Received: by 2002:a17:902:a5cc:: with SMTP id t12-v6mr31700886plq.229.1539886095249; Thu, 18 Oct 2018 11:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539886095; cv=none; d=google.com; s=arc-20160816; b=hValae4p1whto9bvywhHzLWJgX0YUrCSEcOK4+m+jeGUe+dMvHLUzq9v5bm61NWsTv pFEB7J0YAQ3F4C0zQO3nsjpLDbH7lTN0Hhbm6F0Y+BQdWwtlP4fBjeUOBx+Ah/1z4p6b d2geBXlUBWWDGYHLyMKUwDU+/OvyO7nr5QNm5KHMPFxIM9sFnC19eUUs+/o7xUCxXXGm WvvX47fBoOl1Ug8aniHiO2yJo9voDNAUvY1iRzSPAc4G0jMFwX8GhQHAylfmQ+96ZFuF XjFVlB5TG93Vdj6dNwTLSZsAgmRv/Mqy5U428eFDZbAOOPNIgdwH07vZ28C9cayaJMPL tuBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H+QEzmAXChHMQ8zvCaTa6XZnXlTgE9+odnxPxaEDVlU=; b=i6q4yKkPpQprkfNWJtChdV2rkaFMWavAbvEFtC4vil75Qk+3RHpUgckhkLDDoAKbgR JOplaqjJAXsw6230BOQqzgTsCQTH/jsMfVfs9k0P9XVFjLJ4nVCWO0Cw1GPBhiKIegi8 b26nTC/yfUwGkpo4VkMFhU9C4YrhpAEwS22AuAeUTsMoziU/fZZikKRn3TtPZmLP1Dkm JmXfyciJ7L/S29TKu2GOZHj2wikN0MceO7S1VTxdWl0q/M5s9GPswXBN7xWOxc5jMqnU eO4NUSsvAxHdG8VloTfryCFl4IzE+lkDBh/P5atWcFihl49+d8c9Q7lKyP1s+aCAvtz1 pc2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="aeAUvp/X"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 204-v6si22287169pfx.155.2018.10.18.11.08.00; Thu, 18 Oct 2018 11:08:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="aeAUvp/X"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730591AbeJSCJE (ORCPT + 99 others); Thu, 18 Oct 2018 22:09:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:58360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729925AbeJSCJD (ORCPT ); Thu, 18 Oct 2018 22:09:03 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7F71A204FD; Thu, 18 Oct 2018 18:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539886016; bh=bsSUSDkIovqOw60lwWa3Yl+3Y5rMmRIl2wEVmHWxSBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aeAUvp/XgBNiSjlw5uIz+iFfvCaJ84xTg/JNevRrfyGFtHbuhn+k5Jn0oYWey440C d2iSdFUpEF3Pm0nsVPeXfFeHjbyLGsQJA8K3L12Mj5+LJgkCVmR4yVHNH3EetZdIAg aX4GPTgg9q25uHkONDUVsvMt6Os08IZNo89eg8jI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Kuznetsov , "K. Y. Srinivasan" , Dexuan Cui Subject: [PATCH 4.4 47/48] Drivers: hv: kvp: fix IP Failover Date: Thu, 18 Oct 2018 19:55:22 +0200 Message-Id: <20181018175430.411024179@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175427.133690306@linuxfoundation.org> References: <20181018175427.133690306@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vitaly Kuznetsov commit 4dbfc2e68004c60edab7e8fd26784383dd3ee9bc upstream. Hyper-V VMs can be replicated to another hosts and there is a feature to set different IP for replicas, it is called 'Failover TCP/IP'. When such guest starts Hyper-V host sends it KVP_OP_SET_IP_INFO message as soon as we finish negotiation procedure. The problem is that it can happen (and it actually happens) before userspace daemon connects and we reply with HV_E_FAIL to the message. As there are no repetitions we fail to set the requested IP. Solve the issue by postponing our reply to the negotiation message till userspace daemon is connected. We can't wait too long as there is a host-side timeout (cca. 75 seconds) and if we fail to reply in this time frame the whole KVP service will become inactive. The solution is not ideal - if it takes userspace daemon more than 60 seconds to connect IP Failover will still fail but I don't see a solution with our current separation between kernel and userspace parts. Other two modules (VSS and FCOPY) don't require such delay, leave them untouched. Signed-off-by: Vitaly Kuznetsov Signed-off-by: K. Y. Srinivasan Signed-off-by: Dexuan Cui Signed-off-by: Greg Kroah-Hartman --- drivers/hv/hv_kvp.c | 31 +++++++++++++++++++++++++++++++ drivers/hv/hyperv_vmbus.h | 5 +++++ 2 files changed, 36 insertions(+) --- a/drivers/hv/hv_kvp.c +++ b/drivers/hv/hv_kvp.c @@ -78,9 +78,11 @@ static void kvp_send_key(struct work_str static void kvp_respond_to_host(struct hv_kvp_msg *msg, int error); static void kvp_timeout_func(struct work_struct *dummy); +static void kvp_host_handshake_func(struct work_struct *dummy); static void kvp_register(int); static DECLARE_DELAYED_WORK(kvp_timeout_work, kvp_timeout_func); +static DECLARE_DELAYED_WORK(kvp_host_handshake_work, kvp_host_handshake_func); static DECLARE_WORK(kvp_sendkey_work, kvp_send_key); static const char kvp_devname[] = "vmbus/hv_kvp"; @@ -131,6 +133,11 @@ static void kvp_timeout_func(struct work hv_poll_channel(kvp_transaction.recv_channel, kvp_poll_wrapper); } +static void kvp_host_handshake_func(struct work_struct *dummy) +{ + hv_poll_channel(kvp_transaction.recv_channel, hv_kvp_onchannelcallback); +} + static int kvp_handle_handshake(struct hv_kvp_msg *msg) { switch (msg->kvp_hdr.operation) { @@ -155,6 +162,12 @@ static int kvp_handle_handshake(struct h pr_debug("KVP: userspace daemon ver. %d registered\n", KVP_OP_REGISTER); kvp_register(dm_reg_value); + + /* + * If we're still negotiating with the host cancel the timeout + * work to not poll the channel twice. + */ + cancel_delayed_work_sync(&kvp_host_handshake_work); hv_poll_channel(kvp_transaction.recv_channel, kvp_poll_wrapper); return 0; @@ -595,7 +608,22 @@ void hv_kvp_onchannelcallback(void *cont struct icmsg_negotiate *negop = NULL; int util_fw_version; int kvp_srv_version; + static enum {NEGO_NOT_STARTED, + NEGO_IN_PROGRESS, + NEGO_FINISHED} host_negotiatied = NEGO_NOT_STARTED; + if (host_negotiatied == NEGO_NOT_STARTED && + kvp_transaction.state < HVUTIL_READY) { + /* + * If userspace daemon is not connected and host is asking + * us to negotiate we need to delay to not lose messages. + * This is important for Failover IP setting. + */ + host_negotiatied = NEGO_IN_PROGRESS; + schedule_delayed_work(&kvp_host_handshake_work, + HV_UTIL_NEGO_TIMEOUT * HZ); + return; + } if (kvp_transaction.state > HVUTIL_READY) return; @@ -673,6 +701,8 @@ void hv_kvp_onchannelcallback(void *cont vmbus_sendpacket(channel, recv_buffer, recvlen, requestid, VM_PKT_DATA_INBAND, 0); + + host_negotiatied = NEGO_FINISHED; } } @@ -711,6 +741,7 @@ hv_kvp_init(struct hv_util_service *srv) void hv_kvp_deinit(void) { kvp_transaction.state = HVUTIL_DEVICE_DYING; + cancel_delayed_work_sync(&kvp_host_handshake_work); cancel_delayed_work_sync(&kvp_timeout_work); cancel_work_sync(&kvp_sendkey_work); hvutil_transport_destroy(hvt); --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -36,6 +36,11 @@ #define HV_UTIL_TIMEOUT 30 /* + * Timeout for guest-host handshake for services. + */ +#define HV_UTIL_NEGO_TIMEOUT 60 + +/* * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent * is set by CPUID(HVCPUID_VERSION_FEATURES). */