Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1132017pxp; Sun, 20 Mar 2022 07:05:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwehw74s/Rzn36TiriSnpuhlo3J8jarP2rjZMB/h6+MCoADryixIheoC7g1qM0PjGqd84rd X-Received: by 2002:a17:907:2dab:b0:6db:f0a6:761a with SMTP id gt43-20020a1709072dab00b006dbf0a6761amr17020845ejc.584.1647785116339; Sun, 20 Mar 2022 07:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647785116; cv=none; d=google.com; s=arc-20160816; b=J1n68MM71go+CcI6cYp1NYuCkK0i9iY7XjyYs6nXc3HCHTC8nG4vL9Wzs4ffgNj09v gStlqUn7S0u9dpPOTlxtj+KcCKKHEP9XGPdlxsyrZR+PJ5n4g/MNFgmWLynfTtoD+HEM c3PsKpID2jmNDCOloeqMSDnI5JF9tBd1CP2oHRanS7QrmUAQZ6NeZmafLucrUEefKOWZ Fw49UZzKtQLc0JiByVDGuY4dnoUz8sz/dQUXEWYb0mi1xC5YUGID4c5cZWftzWdRxAVU Nlv5/+Ix4mxyiRyHoj99Pt+Vh/aVhqyk+M9zI/U4G6hw2Jgs1yK5pAPWA85tKFrMNAem NCsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=eHtvzLxHYxBAwJ2xHrwf3zPAGlZTeCIqU+KZe0KTPws=; b=De7QyB1F6gd3sDSd9TWaS/SgNMCZshg/9EeB+DYfBUXT7QrwFyxPA/jYi1hkYLQZ/O HjzMg1Vs55srw9QkBFaIXRqfPVEKu2QM5VgSHM2htHjuPhqKdmOKX0vwu9Mo9ScbFiT5 VbxvDUOm541Dpff3oybjB8vspE+hix3lOn0+W3MYfwvU3VN49a2lygP8if6N4AxZ2Pkr 4bJh0ZQ7SKuJDxYHBabLGIMqJxygLxDvjUkoKlY64vcbDDvAOkf936ndqAjG7w2MRSGs IO23qq0e4FSapQ9XXNtY1/Pj8lxzbtlZ+8yfqcZKtL1qThKBWFFp4+OdxlJB64y8gWLy 7ljQ== ARC-Authentication-Results: i=1; mx.google.com; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 18-20020a170906001200b006df76385c79si6429743eja.281.2022.03.20.07.04.49; Sun, 20 Mar 2022 07:05:16 -0700 (PDT) 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; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242609AbiCSJgz (ORCPT + 99 others); Sat, 19 Mar 2022 05:36:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240092AbiCSJgw (ORCPT ); Sat, 19 Mar 2022 05:36:52 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D528270872; Sat, 19 Mar 2022 02:35:32 -0700 (PDT) Received: from canpemm500006.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KLFy23VyFz9smB; Sat, 19 Mar 2022 17:31:38 +0800 (CST) Received: from localhost.localdomain (10.175.104.82) by canpemm500006.china.huawei.com (7.192.105.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Sat, 19 Mar 2022 17:35:29 +0800 From: Ziyang Xuan To: , , , CC: , , Subject: [PATCH net-next v3 2/3] net: ipvlan: add net device refcount tracker Date: Sat, 19 Mar 2022 17:53:13 +0800 Message-ID: <185e45470629ad7a0aeef7a61b608d5cf13fcbf3.1647664114.git.william.xuanziyang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.82] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add net device refcount tracker to ipvlan. Signed-off-by: Ziyang Xuan --- drivers/net/ipvlan/ipvlan.h | 1 + drivers/net/ipvlan/ipvlan_main.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ipvlan/ipvlan.h b/drivers/net/ipvlan/ipvlan.h index 3837c897832e..6605199305b7 100644 --- a/drivers/net/ipvlan/ipvlan.h +++ b/drivers/net/ipvlan/ipvlan.h @@ -64,6 +64,7 @@ struct ipvl_dev { struct list_head pnode; struct ipvl_port *port; struct net_device *phy_dev; + netdevice_tracker dev_tracker; struct list_head addrs; struct ipvl_pcpu_stats __percpu *pcpu_stats; DECLARE_BITMAP(mac_filters, IPVLAN_MAC_FILTER_SIZE); diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index dcdc01403f22..be06f122092e 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -160,7 +160,7 @@ static int ipvlan_init(struct net_device *dev) port->count += 1; /* Get ipvlan's reference to phy_dev */ - dev_hold(phy_dev); + dev_hold_track(phy_dev, &ipvlan->dev_tracker, GFP_KERNEL); return 0; } @@ -674,7 +674,7 @@ static void ipvlan_dev_free(struct net_device *dev) struct ipvl_dev *ipvlan = netdev_priv(dev); /* Get rid of the ipvlan's reference to phy_dev */ - dev_put(ipvlan->phy_dev); + dev_put_track(ipvlan->phy_dev, &ipvlan->dev_tracker); } void ipvlan_link_setup(struct net_device *dev) -- 2.25.1