From patchwork Mon Aug 26 08:12:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jijie Shao X-Patchwork-Id: 13777411 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 579BC1465BB; Mon, 26 Aug 2024 08:19:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724660398; cv=none; b=nFHk5+Nbl0eLFVungvzFts5RCgMJGqgWTjBuPz3mpYH7YXXPOjJ9AFIJf0iJjcWj0OGeXIYXPkWhnVNwkKczkOzaPlMvRwrqZtQshTQjYbCj396oBM5z4x4oSZzKJdhIqpkoGg8MYAQvYY3z0CXqbWVPrSiyQ3altps5hoIw+Qc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724660398; c=relaxed/simple; bh=eEypYZoG6QJSIUdINWthfnAlOoisMVXiIIU515ncHzA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dTqYIfc6lRIz+8XvzrjwPo/iNpfHdLnMq5HSNFpEkcijknh8wS8yGgEflTXvEvkZhLbvQTDmtfMNgcfs3M5yEXOjH7a5DiAU+OGoSSj+6w6wVGCIEBm9xzYFPxlMO+iD8JuPnKQiE4+B3EUOMZh1Oks42SPJ/PZO72OlxTN1V64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Wsk6D30Zbz1HHN9; Mon, 26 Aug 2024 16:16:36 +0800 (CST) Received: from kwepemm000007.china.huawei.com (unknown [7.193.23.189]) by mail.maildlp.com (Postfix) with ESMTPS id D240A140135; Mon, 26 Aug 2024 16:19:53 +0800 (CST) Received: from localhost.localdomain (10.90.30.45) by kwepemm000007.china.huawei.com (7.193.23.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 26 Aug 2024 16:19:52 +0800 From: Jijie Shao To: , , , CC: , , , , , , , , , , , , , , , , Subject: [PATCH V4 net-next 11/11] net: add ndo_validate_addr check in dev_set_mac_address Date: Mon, 26 Aug 2024 16:12:58 +0800 Message-ID: <20240826081258.1881385-12-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240826081258.1881385-1-shaojijie@huawei.com> References: <20240826081258.1881385-1-shaojijie@huawei.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm000007.china.huawei.com (7.193.23.189) X-Patchwork-Delegate: kuba@kernel.org If driver implements ndo_validate_addr, core should check the mac address before ndo_set_mac_address. Signed-off-by: Jijie Shao Reviewed-by: Andrew Lunn --- net/core/dev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/core/dev.c b/net/core/dev.c index e7260889d4cb..7e9c3017e705 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9087,6 +9087,11 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa, return -EOPNOTSUPP; if (sa->sa_family != dev->type) return -EINVAL; + if (ops->ndo_validate_addr) { + err = ops->ndo_validate_addr(dev); + if (err) + return err; + } if (!netif_device_present(dev)) return -ENODEV; err = dev_pre_changeaddr_notify(dev, sa->sa_data, extack);