From patchwork Thu Oct 21 12:23:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1544340 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=Fh/Mp3lO; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HZmrZ74VGz9sRR for ; Thu, 21 Oct 2021 23:24:46 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mdX7c-000364-HU; Thu, 21 Oct 2021 12:24:36 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mdX7J-0002tG-Rg for kernel-team@lists.ubuntu.com; Thu, 21 Oct 2021 12:24:17 +0000 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 8153140010 for ; Thu, 21 Oct 2021 12:24:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1634819057; bh=QVKBtYLxh0fq9iC7dFM2ZVJcnTi6elGTwNpfAWrHpeQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Fh/Mp3lOFT2FKoP/U3NcpKjs3X+dlqZmcV+uKrlKi5Z/L2eUp7uvQtNEl0zvhEvKA aUdw5Aqx08CIMiFXkfr8V715wmHXHk/7hhAfhPGQorU7prMSho8GM/rwItPLreWrY1 7bRELjVSu4CAVe6GuItJVDQIsZPZKgak46H6kqJMrPa0Yly122Wt9+++1rFMPEizzj 8sACKIIxGX2Pv2K8EbKVtoeUWRctEhEhL1BSmKBzFk1VXXqSy1PfP0wMZPJsEpLINx /m59qzxpdX8ZnUXAOwOi2eLZolSCXyXttobqRBmgrML4SLA0xjnhZ2FAc0UKKN6dAQ q8TWZ3fxPwwwA== Received: by mail-pj1-f72.google.com with SMTP id r13-20020a17090a1bcd00b001a1b1747cd2so281822pjr.9 for ; Thu, 21 Oct 2021 05:24:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QVKBtYLxh0fq9iC7dFM2ZVJcnTi6elGTwNpfAWrHpeQ=; b=Ht/Rt9wxsT+1+Yn8B8kn4UNy+nPua3Lq4yy7PKpE51ryZk3FGC5zZ4ZEW4OkyDlsre bJ7W/Z2rLNlI7ibDrYmeOA/e5xVPcShvzU8/R0fn7QXpDMRkHsRoL/gx+afemJiwVL7+ 1vYbUhJFk0mNUGMNbRpScpS0ObJEvrpEs0sSIGDgUVrjKEJv7twKSAK5j4CU1+I1ScYg cMo9H0R0qm4im+Q7wUh8YTzGtYvs6rpfOG8ycf1JXfRrD2V1H7q5HUhSNVjANjz0h2oE CIVPKZcc2GVT9b4Z1YVl92laSVe61ygJYzqiwzys+JEEwLlLMzFOHyblj9Y9ro4NjSLd 7SQg== X-Gm-Message-State: AOAM533c18IpIGl53GrT2VHNvcTfogmpOClQouwydg2wYSH7F4rLPG8v d8xUtzFat7Qoi9smix2acevZgXuKzWEJ4zceNuRoK1TE1xJy0Oy5P+Q2CPAIZ0GZ1A+kmvU19fT VpOU2bPexmGCk2RM2X2CaumAcmPkD+nBdOxIpxuFFHA== X-Received: by 2002:a62:17d3:0:b0:44c:6022:9428 with SMTP id 202-20020a6217d3000000b0044c60229428mr5036796pfx.65.1634819055986; Thu, 21 Oct 2021 05:24:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytLaUNJprNu2P7wOhyG7a6EucnmAiDMukpN7Tr7+1g5N5UzThEi/w5XoWOBaZSF6RSYXazQg== X-Received: by 2002:a62:17d3:0:b0:44c:6022:9428 with SMTP id 202-20020a6217d3000000b0044c60229428mr5036765pfx.65.1634819055711; Thu, 21 Oct 2021 05:24:15 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id g25sm5192869pge.12.2021.10.21.05.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 05:24:15 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 01/13][Hirsute/linux-azure] hv_netvsc: Make netvsc/VF binding check both MAC and serial number Date: Thu, 21 Oct 2021 06:23:42 -0600 Message-Id: <20211021122400.10390-9-tim.gardner@canonical.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211021122400.10390-1-tim.gardner@canonical.com> References: <20211021122400.10390-1-tim.gardner@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Dexuan Cui BugLink: https://bugs.launchpad.net/bugs/1947859 Currently the netvsc/VF binding logic only checks the PCI serial number. The Microsoft Azure Network Adapter (MANA) supports multiple net_device interfaces (each such interface is called a "vPort", and has its unique MAC address) which are backed by the same VF PCI device, so the binding logic should check both the MAC address and the PCI serial number. The change should not break any other existing VF drivers, because Hyper-V NIC SR-IOV implementation requires the netvsc network interface and the VF network interface have the same MAC address. Co-developed-by: Haiyang Zhang Signed-off-by: Haiyang Zhang Co-developed-by: Shachar Raindel Signed-off-by: Shachar Raindel Acked-by: Stephen Hemminger Signed-off-by: Dexuan Cui Signed-off-by: David S. Miller (cherry picked from commit 64ff412ad41fe3a5bf759ff4844dc1382176485c) Signed-off-by: Tim Gardner --- drivers/net/hyperv/netvsc_drv.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index f32f28311d57..ec30b7fb2e51 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -2285,6 +2285,7 @@ static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev) { struct device *parent = vf_netdev->dev.parent; struct net_device_context *ndev_ctx; + struct net_device *ndev; struct pci_dev *pdev; u32 serial; @@ -2307,8 +2308,17 @@ static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev) if (!ndev_ctx->vf_alloc) continue; - if (ndev_ctx->vf_serial == serial) - return hv_get_drvdata(ndev_ctx->device_ctx); + if (ndev_ctx->vf_serial != serial) + continue; + + ndev = hv_get_drvdata(ndev_ctx->device_ctx); + if (ndev->addr_len != vf_netdev->addr_len || + memcmp(ndev->perm_addr, vf_netdev->perm_addr, + ndev->addr_len) != 0) + continue; + + return ndev; + } netdev_notice(vf_netdev,