From patchwork Tue May 18 11:58:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1480218 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 4FkvgF2XZjz9sW5; Tue, 18 May 2021 21:59:21 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1liyNZ-00047B-Ie; Tue, 18 May 2021 11:59:17 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1liyMr-0003gx-CP for kernel-team@lists.ubuntu.com; Tue, 18 May 2021 11:58:33 +0000 Received: from mail-pg1-f198.google.com ([209.85.215.198]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1liyMr-00007k-3G for kernel-team@lists.ubuntu.com; Tue, 18 May 2021 11:58:33 +0000 Received: by mail-pg1-f198.google.com with SMTP id p21-20020a6374150000b029021aa1da6342so4735445pgc.20 for ; Tue, 18 May 2021 04:58:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OM9RftJOxCFSMAC1UwNJqiipib58nZ9w9Cja71zw934=; b=Ui1vR0nMuZZpv3MILVDg4bDdoSxqay7zEs4aCWt/tFQsWVZo1zCGUyR7B+uk3ovuFN U7EwjlbgoPxpyDcOetaQUDd0R9ypjdweP7x+ZxAhjL4WiWVoRmIYprVhn2XljeWiuFql rQJdW0PxyJZGpbG5YmKqL1uaaQ8c8pwWKl2abmj+e6X/I5Yx8kpXU/HTKoqMW27LpkmD O1G1KciQ7IBQjPCWoPVCSFj+Zdkd0Bc2IWFCZWezndkHM9RjhZHuHwS6/5c2+D42I/h8 2Prs5Ntb1Uk62jWYRqs9EEekTZSZ21EbfmW/S3QETT8Ln4FJ5bkNCyDXsaoUTJwyrG7T 3vBA== X-Gm-Message-State: AOAM5321YxXA5t5QvOceDh9qS62FPfvpcabpqmc4+RD8FCJxHdniLSMS LF/b5qzNvkvR9jdypqTW/z0/f0Ju3tHedZFqJqouFH4eSVl0PL6dtKHChozApdZL1O9GTTGPXGs yu0llM5d5AsuRdp+43pk4lTvkoJmO5jZYHqrzwsJD6g== X-Received: by 2002:a17:902:7403:b029:f3:519f:21e with SMTP id g3-20020a1709027403b02900f3519f021emr2600088pll.39.1621339111328; Tue, 18 May 2021 04:58:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJOs/dCxjrp1GQkq1kOSyI84FIoLlbnI7d+SmU5Waw7yJ85nFRoHVCQEmt+T1YoIa1E7fx5w== X-Received: by 2002:a17:902:7403:b029:f3:519f:21e with SMTP id g3-20020a1709027403b02900f3519f021emr2600070pll.39.1621339111140; Tue, 18 May 2021 04:58:31 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id f83sm7225383pfa.163.2021.05.18.04.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 04:58:30 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/6][groovy:linux-azure] hv_netvsc: Make netvsc/VF binding check both MAC and serial number Date: Tue, 18 May 2021 05:58:03 -0600 Message-Id: <20210518115808.6166-8-tim.gardner@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210518115808.6166-1-tim.gardner@canonical.com> References: <20210518115808.6166-1-tim.gardner@canonical.com> 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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Dexuan Cui BugLink: https://bugs.launchpad.net/bugs/1928788 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 3b0dc1f0ef21..e98bcde0e542 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -2237,6 +2237,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; @@ -2259,8 +2260,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,