Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp677905img; Thu, 28 Feb 2019 06:12:45 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib+rwW+Fy2hfbBb45RKPXn8tgQvTgpAaJfxq67IwwNfqXp0gK001F9bWtcMVhfInCWWLByX X-Received: by 2002:a17:902:e090:: with SMTP id cb16mr7978427plb.32.1551363165334; Thu, 28 Feb 2019 06:12:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551363165; cv=none; d=google.com; s=arc-20160816; b=lUPo2Ja73ocrb9yhOxJF3XulQkEkyxjbGp1AmMnZ6/iTh7gxqeKKE1m0tstjb5dl1I ECimTflmO1OrwYsRwKt9w01nr3At0BmxDAI7bU+ENNe1malfR4NDPWdInUrgyTfQ+W8O 8mOqgESnOQduv0l+4dppwidA2Sdt5Pi27CPm3yMopCVZbfKj3nq8kldnFlgu+OjS38BH MOKBn4im1W6NUXbjXy8sN0F9fIRqiGbxT7jcncKQfhFOeixjlJbtWK+KTNhiz8WsBMw0 9G/ssbRsZ9IpHMaSWojIWtFTPejUrGH272EbLzAyLDwcvZpvpbTvjRNNbH3IX3btovqM aHIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=ZGSBMTQD3IzVA1l1/DtwS4ouLNPnvmRRCFpnUnNWeMA=; b=LQhqSoFAcHdBX1b2E6S0pD32njX6VPl9lSh2AuHApfCWTbJFXD8JAxFai0ZUBNJihp jso5C9VpbJ6dMhFiJx41hdSJfz6WVy5kqrdGljXeUlB0Q+mNG/rQYARLWtl8LwXMbLew PpcHLptB2Lml4fRtmP/OHsdWqzofryBRZsy9qP2pd54WgaZ5E84pOtR1QeUN8qeWlGeZ kALAFlHDUSQPjCNGl3v+h7bWtriyQA0gAQ+O/PsMsJsvkAzo020qfUKptl2N7fCn8TVq t9wWl66Ff0gtPUVHxkbeOnyP5UrT4O0hdHWO0QeduVF80WIOCLTzNba5M2E4eG81wtBY NBFA== ARC-Authentication-Results: i=1; mx.google.com; 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 s35si8695563pgl.101.2019.02.28.06.12.29; Thu, 28 Feb 2019 06:12:45 -0800 (PST) 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; 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 S1732412AbfB1OMC (ORCPT + 99 others); Thu, 28 Feb 2019 09:12:02 -0500 Received: from smtp03.citrix.com ([162.221.156.55]:31780 "EHLO SMTP03.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728038AbfB1OMC (ORCPT ); Thu, 28 Feb 2019 09:12:02 -0500 X-IronPort-AV: E=Sophos;i="5.58,423,1544486400"; d="scan'208";a="79327735" From: Igor Druzhinin To: , , CC: , , , Igor Druzhinin Subject: [PATCH] xen-netback: don't populate the hash cache on XenBus disconnect Date: Thu, 28 Feb 2019 14:11:26 +0000 Message-ID: <1551363086-29652-1-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Occasionally, during the disconnection procedure on XenBus which includes hash cache deinitialization there might be some packets still in-flight on other processors. Handling of these packets includes hashing and hash cache population that finally results in hash cache data structure corruption. In order to avoid this we prevent hashing of those packets if there are no queues initialized. In that case RCU protection of queues guards the hash cache as well. Signed-off-by: Igor Druzhinin --- Found this while applying the previous patch to our patchqueue. Seems it never went to the mailing list and, to my knowledge, the problem is still present. From my recollection, it only happened on stress frontend on/off test with Windows guests (since only those detach the frontend completely). So better late than never. --- drivers/net/xen-netback/hash.c | 2 ++ drivers/net/xen-netback/interface.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c index 0ccb021..10d580c 100644 --- a/drivers/net/xen-netback/hash.c +++ b/drivers/net/xen-netback/hash.c @@ -454,6 +454,8 @@ void xenvif_init_hash(struct xenvif *vif) if (xenvif_hash_cache_size == 0) return; + BUG_ON(vif->hash.cache.count); + spin_lock_init(&vif->hash.cache.lock); INIT_LIST_HEAD(&vif->hash.cache.list); } diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c index 182d677..6da1251 100644 --- a/drivers/net/xen-netback/interface.c +++ b/drivers/net/xen-netback/interface.c @@ -153,6 +153,13 @@ static u16 xenvif_select_queue(struct net_device *dev, struct sk_buff *skb, { struct xenvif *vif = netdev_priv(dev); unsigned int size = vif->hash.size; + unsigned int num_queues; + + /* If queues are not set up internally - always return 0 + * as the packet going to be dropped anyway */ + num_queues = READ_ONCE(vif->num_queues); + if (num_queues < 1) + return 0; if (vif->hash.alg == XEN_NETIF_CTRL_HASH_ALGORITHM_NONE) return fallback(dev, skb, NULL) % dev->real_num_tx_queues; -- 2.7.4