Received: by 2002:ac2:48a3:0:0:0:0:0 with SMTP id u3csp572344lfg; Fri, 11 Mar 2022 13:42:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3SINGjRsJcxSV4LdNKt1rEYAkUlYb2HCZyXMkQ++hyOFxzVXMwAKjzfMSPNWClEnm+L0o X-Received: by 2002:a62:8389:0:b0:4f7:2b72:3589 with SMTP id h131-20020a628389000000b004f72b723589mr11900528pfe.57.1647034944187; Fri, 11 Mar 2022 13:42:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647034944; cv=none; d=google.com; s=arc-20160816; b=Kv24S/buHB6z7SFZlknxcnUl8MMt5jikxCHvKv/GUygYPCijOGbAmQXQE4qVmLLXe2 rql04G5n3HWM0TLCpn5wq2wihCmDLad1i2+NSsooa2r+oJq8VQjPdkGyttfiEv8RpqP0 rSCuQG9Toleb5mY1i2/yAPaWZCBSOi9a5TFEe2kdwJiVIneonyJI58Op2gWh8j9kHHTc plgEULOJH5kGWeIHIm3dWrZ8NdE0BZbkxInAyaM2fu5HnhAByQC7QTE2Eiur/2j0Q9er +LYsmAbL35YwgPirAdJLQ2VfsacHm/CYLQ6ivuP6EZ67OGzelqE6bJLg/0Nmfu2sIsB6 NJhg== 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=yP1nWRHPpfI6D9IVpR8EiABKeedi56uRsGoxkt9VMoM=; b=xTQ1ROJ/HCk1NZCzIxXv5I2w7RLNTqv9Dg/xKURrXwyP0KMQHv63CpoGZnYV9aRmhl Fa6d3Seh3d94Mvg0ooyXbAP8AQLTb8PY47hOxg9i8gN7+Gm6LUJhD/HZ7VHWo2aMnPHY TDfUY4CALB0itmzJUjLzkaBMjItp2HqkMOqwX0WRPc3cSFHOhpB0eR2zwRa3edpjl1DP G4k0lUj+y9Hbyob0MTRvQ63i6PKrSebpbxWy5+SL9Q+Rtn5k7vOX/VLa/pWdse7XbQZF BDAkMiw3whh3pfomNE1qCbpnTSBExPZN7eMCKGByW8R9tXXhk+m6BKra/B6Qut03uOgd fmJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l72-20020a63914b000000b0037c8c25e8e9si9264576pge.213.2022.03.11.13.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 13:42:24 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2B106CFE; Fri, 11 Mar 2022 13:07:38 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240348AbiCKIrZ (ORCPT + 99 others); Fri, 11 Mar 2022 03:47:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiCKIrW (ORCPT ); Fri, 11 Mar 2022 03:47:22 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C61841BA927; Fri, 11 Mar 2022 00:46:19 -0800 (PST) Received: from canpemm500006.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KFKHn44rbzfYtt; Fri, 11 Mar 2022 16:44:53 +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; Fri, 11 Mar 2022 16:46:17 +0800 From: Ziyang Xuan To: , , CC: Subject: [PATCH net-next 2/2] net: macvlan: add net device refcount tracker Date: Fri, 11 Mar 2022 17:04:03 +0800 Message-ID: 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: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 macvlan. Signed-off-by: Ziyang Xuan --- drivers/net/macvlan.c | 4 ++-- include/linux/if_macvlan.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index d36af413e372..d6241ad66c0c 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -912,7 +912,7 @@ static int macvlan_init(struct net_device *dev) port->count += 1; /* Get macvlan's reference to lowerdev */ - dev_hold(lowerdev); + dev_hold_track(lowerdev, &vlan->dev_tracker, GFP_KERNEL); return 0; } @@ -1181,7 +1181,7 @@ static void macvlan_dev_free(struct net_device *dev) struct macvlan_dev *vlan = netdev_priv(dev); /* Get rid of the macvlan's reference to lowerdev */ - dev_put(vlan->lowerdev); + dev_put_track(vlan->lowerdev, &vlan->dev_tracker); } void macvlan_common_setup(struct net_device *dev) diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h index 10c94a3936ca..b42294739063 100644 --- a/include/linux/if_macvlan.h +++ b/include/linux/if_macvlan.h @@ -21,6 +21,7 @@ struct macvlan_dev { struct hlist_node hlist; struct macvlan_port *port; struct net_device *lowerdev; + netdevice_tracker dev_tracker; void *accel_priv; struct vlan_pcpu_stats __percpu *pcpu_stats; -- 2.25.1