From patchwork Tue Nov 8 12:52:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuang Wang X-Patchwork-Id: 17025 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2689899wru; Tue, 8 Nov 2022 05:03:32 -0800 (PST) X-Google-Smtp-Source: AMsMyM5ad4NdTXA1eNQIeLkHd4RQ0Klm3tr8lB3yNlICt6TpbcvQKwIGizsXYGAmzx/kFUNmxFLS X-Received: by 2002:aa7:81cf:0:b0:561:7d72:73ef with SMTP id c15-20020aa781cf000000b005617d7273efmr55552860pfn.16.1667912611780; Tue, 08 Nov 2022 05:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667912611; cv=none; d=google.com; s=arc-20160816; b=B3hEPvnJdZzRvVnnQZxhFfXQh85K/xQEnyHbZO8yRx+KFV4xOHKoFVy7o6TuY6VC7J J/seJOCwNvEwNg5WJ7cLVsRvp4a+x4aZCYVlB0gwDth4lRjsP8SVuYLjuulD2HbgRiYQ P/M7j+rDjpfqtkG3tsUDdauQ0gfM2KOta1qfcIsA3kHpAzhmQXSwiXVgqQ9QNnBAUv/l pyoVki9OHH93ZLjfca5jKHr9nSFxFKXzFP/wgc9DnCQN6YdMFF4Xt3qhA+gTMKMXNEqo DBEwTU/8QWpabq//qfzEqo/NRZfKa03tQxUwYwvcQvsY7RNTvwPDkjUVO2DYIEVedGLm wXKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=mNtuOEXDefEJXOGS36uoL5ZWOWYNWQBLQOQ1lh+QjkM=; b=PSMWW6/uiDAju6ZhpNzLhMTvnYAbscqtvPfLqItzZKxXsXl1KoyRLZ9+8b9123DeXF VEZDF2yZn+fGx5+0qZ6oskNG96fcWOTwZs3nk9lAzIqEXjCRSmZ9Dn/u/vGQp0iswkwo dCtFgZA4hoNadwq42WR2jyGHp/m0DEhZAB+gbJlWpUuwf9g+4stcYgBpwjqVx0JBLtqa yAqZhv6w0GsywLzE0svuNcv321yGkfvtV3Qwmivs37Lzu8QI/+vFE8irItCnJ9t7nbc3 Dwj536ATYYk4dlb2aO7Afx+GhyVDGyrY9oYExKDG10aeF7T/tHZl3/dhNoSkXUWHK0CC Ud/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=jZv8R9Yf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a056a000a8500b0056e4c95266bsi14720982pfl.77.2022.11.08.05.03.16; Tue, 08 Nov 2022 05:03:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=jZv8R9Yf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234159AbiKHMxP (ORCPT + 99 others); Tue, 8 Nov 2022 07:53:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233829AbiKHMxL (ORCPT ); Tue, 8 Nov 2022 07:53:11 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25AB563A7; Tue, 8 Nov 2022 04:53:11 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id v28so13707573pfi.12; Tue, 08 Nov 2022 04:53:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mNtuOEXDefEJXOGS36uoL5ZWOWYNWQBLQOQ1lh+QjkM=; b=jZv8R9YfnkF1S82Q0owrujyqmGBwB0NmQzOz+VxZdLY9mXaCSJ2214E/QOUcufWa3a fsqmr0nvYjFUf6cUykcGxU9NaXPJjMcWc13aBgH5Bg2ZFW4/bTmEnEdWrTWGgBu/YteR ui/qliXaZAKl4SlWM/S9GOoZ1DU12WdMLCMrWshhYfHy2isUgyblc9K6ItKkUSRX/EYG nQ5eUX46Ff9A8K45uI9ltjVUTrEU6jDwi3SKTt7crsXUxlL3Z5BOAARz7eAswEQoMvYl 8jg1DHdSjbrjqM40wwLob+jvzHZwMqNH9YnHJOqxcjiXwsMVG+q8W1+QjiVeoE8moqYp Ooqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mNtuOEXDefEJXOGS36uoL5ZWOWYNWQBLQOQ1lh+QjkM=; b=55YT6MK9HErREe2EIYigzQlMCnsM1m5IHSeO5/p1ygWxFfRcpUVz0sf/G7VoJkdMx+ qKb9+x+2zeUFZKJ1Kq87zGBEU6b3a3tOncljSQLnmZiFpJE4NoAcES5ZTnSCTeeEkbDV W3fDXTM+S6GM8g7bgOKdAdJwMUxtxWhHQOywsdGSJRjghOU3cVhJ4a0SyqkANWa7eFWD Ajzj+Zm7rD8I6u807dWstO9rHap4pfJegJyfMjJ4aadO3MyNzEvETUtjiQ0Nuif3M7CJ TBvsJNWkxytCpF5Erp0fe+IFOdL03nt3CvYDcLRq899sN/4eXtqXvTADuKgPx4mYyKwY K6tA== X-Gm-Message-State: ACrzQf2eg3e8RmVfLIv7u0hEgXvRglV+fjx4aOL/jU0w0beGYlUlmSew nsARGDEOkk3maTqDyzIq5r8= X-Received: by 2002:a05:6a00:2285:b0:56d:5d42:3aa8 with SMTP id f5-20020a056a00228500b0056d5d423aa8mr48146805pfe.79.1667911990653; Tue, 08 Nov 2022 04:53:10 -0800 (PST) Received: from localhost.localdomain ([47.242.114.172]) by smtp.gmail.com with ESMTPSA id c1-20020a170902b68100b00186a2444a43sm6807845pls.27.2022.11.08.04.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 04:53:10 -0800 (PST) From: Chuang Wang Cc: Chuang Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1] net: macvlan: Use built-in RCU list checking Date: Tue, 8 Nov 2022 20:52:54 +0800 Message-Id: <20221108125254.688234-1-nashuiliang@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748932910373826299?= X-GMAIL-MSGID: =?utf-8?q?1748933134661993393?= hlist_for_each_entry_rcu() has built-in RCU and lock checking. Pass cond argument to hlist_for_each_entry_rcu() to silence false lockdep warning when CONFIG_PROVE_RCU_LIST is enabled. Execute as follow: ip link add link eth0 type macvlan mode source macaddr add The rtnl_lock is held when macvlan_hash_lookup_source() or macvlan_fill_info_macaddr() are called in the non-RCU read side section. So, pass lockdep_rtnl_is_held() to silence false lockdep warning. Signed-off-by: Chuang Wang --- v0 -> v1: - fix typo drivers/net/macvlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index c58fea63be7d..deb7929004a7 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -141,7 +141,7 @@ static struct macvlan_source_entry *macvlan_hash_lookup_source( u32 idx = macvlan_eth_hash(addr); struct hlist_head *h = &vlan->port->vlan_source_hash[idx]; - hlist_for_each_entry_rcu(entry, h, hlist) { + hlist_for_each_entry_rcu(entry, h, hlist, lockdep_rtnl_is_held()) { if (ether_addr_equal_64bits(entry->addr, addr) && entry->vlan == vlan) return entry; @@ -1645,7 +1645,7 @@ static int macvlan_fill_info_macaddr(struct sk_buff *skb, struct hlist_head *h = &vlan->port->vlan_source_hash[i]; struct macvlan_source_entry *entry; - hlist_for_each_entry_rcu(entry, h, hlist) { + hlist_for_each_entry_rcu(entry, h, hlist, lockdep_rtnl_is_held()) { if (entry->vlan != vlan) continue; if (nla_put(skb, IFLA_MACVLAN_MACADDR, ETH_ALEN, entry->addr))