From patchwork Tue Nov 8 12:46:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuang Wang X-Patchwork-Id: 17023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2687476wru; Tue, 8 Nov 2022 04:59:57 -0800 (PST) X-Google-Smtp-Source: AMsMyM6VjsrscGNKE30gNJnuUhPK8vRtXQ9yw3r8SklUrFnXe30lr0fYOvYpU5GPjX86lgBNOGdI X-Received: by 2002:aa7:d650:0:b0:462:d945:3801 with SMTP id v16-20020aa7d650000000b00462d9453801mr55292997edr.117.1667912397424; Tue, 08 Nov 2022 04:59:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667912397; cv=none; d=google.com; s=arc-20160816; b=Na/DFjYdP7igEnKxkYQ0ti4gXisFaqYMMKylTy5/Su36cFWCWb8HZMA+xozFeHKN3O rM4gK4t/I4MKS3KF/656TBK2/zZfYs07+CQUFloLxNdoyhd87UGRXmPGDj/SlBInOTEi nNMy/bwkG2edm+Jhi01Ft9laWUnw8WpzGAiC1Hy+n5Z1DLVD/jNmGZas5pamstYTxmJb WV6wfPK9rTm++pUhmZkurP7Jmu08HM/NZDigXN6KfkHtsD6BmZGokhOuEjRK/xINn7if LtpY8Jn7M/xAlf2n6DfOopSupq/ALr4BWIlA7gC0+RXXtq1MBIcsgE20azzotoruvc3G vhcA== 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=YNc/G0OgX6mRUqDaT1FnoUWK1fg7o1iEbVRmjeCcsXw=; b=zWudtvcQPscztvQ0XaZs+OCQvt7QtimtICFyqV5JrvvvM4w/zKtFpZo6A8c3WbG7jZ lcLb7MLAUohRcjK2DPtLkTxX01HB0PS0z2jFg+/Y6BqMAcO2bd1vumgj92wq6d4Cw/83 nt5DnZtgL0KXbIiT9D4Q/rdXXm4ax6lQ7B7kmCBj+1RdoNu6COZibUlypgi1ZxGcb7d9 ttv4Klxgr/Ex7GNsT5angn00hBjMYMvcLY2yIIuSYGuBwZUQVKd9VRpBnqtSuy2IO3qw xMqf7smfPQZskNl/Rr9Kq6yXMMJFLobHhTAYyWR0frN3ogfgw/PZNhrd4ExTtKwdqlJp yy1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=aKOpFVM0; 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 gv28-20020a1709072bdc00b0073ffabc3352si9294724ejc.836.2022.11.08.04.59.33; Tue, 08 Nov 2022 04:59:57 -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=aKOpFVM0; 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 S234254AbiKHMqk (ORCPT + 99 others); Tue, 8 Nov 2022 07:46:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234252AbiKHMqc (ORCPT ); Tue, 8 Nov 2022 07:46:32 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1FD152893; Tue, 8 Nov 2022 04:46:29 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id b11so13696222pjp.2; Tue, 08 Nov 2022 04:46:29 -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=YNc/G0OgX6mRUqDaT1FnoUWK1fg7o1iEbVRmjeCcsXw=; b=aKOpFVM0RW2BSTVFW5ZukFkv25qGW/AYoM5Oiakp+KCW2IZ/+/Bf+DT/AO+9xHwY/N DVPMyT9n9wlAMt2Hgks5Sf83LKIg5jobwZmEz+7UMkfOi+Y5EQKfyhc73Xyg59/llCCE 6+l4sLnPjPUuW9udf60k8UDuxlPIXDi/RDuvu10xdrshgV7OQYt84yrUCcQ1yYq0ZaC3 fk6L2Nz0IO5A0LBYhrNpCqeBCeUfcSL+cfcYS2+K7+rgerczG+tBCoJsrZCMUUzsnipa 2CRFBuMvr+aSgLk0c+BD3maXsoC+RG79n98srSo4Fv1WhokV0oOpKkLUhjzPqCQrTcjn 6Jdg== 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=YNc/G0OgX6mRUqDaT1FnoUWK1fg7o1iEbVRmjeCcsXw=; b=dJd/+TfeRlDiW5jz7QuemO2/5hv2HbWZvKfgQgyn5jUDA3FTazBPXjcLE10J6GyMxu LOsC1KEqqTb+1kVxodGx0FcV8VclBwO/Fc3d5PacqGn6VDSGdGp8Fp5j55tGO0k+IGxx So8M1aCynabj3mUFdcxtwcaDL1dUTVeX6arB9tM30sNL3zuLON/YLQ4nTOxg1R/CtD6a SSm7celjXOiJXqwq6Ee2endUT3ihImq6H87Qo8FYfDGPG/Bz293Go5pYRnvcb/lvRl3z Iy+DNp81wGOtD/1XDTP1GpP05PCDDHmDPmn7t8UPPY2R+prEMu9J5n+Jq3Tlfq3VPjku sQWA== X-Gm-Message-State: ACrzQf0Kp1m7d2Sx/suLRzl5PKURKi5U+Tw4kYSkKjc/aFK9QgSK+1Iu 1Wdk8NAoj2+TuN7Caawttx5zicgrBqI= X-Received: by 2002:a17:902:ea04:b0:187:4923:56f4 with SMTP id s4-20020a170902ea0400b00187492356f4mr33978874plg.97.1667911589396; Tue, 08 Nov 2022 04:46:29 -0800 (PST) Received: from localhost.localdomain ([47.242.114.172]) by smtp.gmail.com with ESMTPSA id u6-20020a17090341c600b0015e8d4eb26esm6785185ple.184.2022.11.08.04.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 04:46:28 -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] net: macvlan: Use built-in RCU list checking Date: Tue, 8 Nov 2022 20:46:11 +0800 Message-Id: <20221108124611.688031-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?1748932910373826299?= list_for_each_entry_rcu() has built-in RCU and lock checking. Pass cond argument to list_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 --- 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))