Message ID | 202308041649468563730@zte.com.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:44a:b0:3f2:4152:657d with SMTP id ez10csp134762vqb; Fri, 4 Aug 2023 02:25:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLn92xD8bOGVbxhXI53y1OWV4lR3VCkO6Z9RwDybviPbua+3Z7sdi7hbWssnESn5e3yMzM X-Received: by 2002:a05:6512:110d:b0:4f5:a181:97b8 with SMTP id l13-20020a056512110d00b004f5a18197b8mr901404lfg.25.1691141101112; Fri, 04 Aug 2023 02:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691141101; cv=none; d=google.com; s=arc-20160816; b=tsuRr19oVKD+ikvckSEg6Bdek3sYBq6eh+b12/6FDenVHuZmVTxz3UEeSyvOW9LfoK YXp4kSVaxsW8ZxsaVd4OpiCxYCLRYN9e4nIztNvSGJIGIxMyuKUiBmOy/fOCCRW4f/x7 eLjTvBLCfYHK8YMVHP2s9AJ/JJEJPWhs7pTxu2VgqUoDg8dV+Zy0IPIYdZDRzHcHeUGl QMcjLXYVr5OCU5sh6bok4cW6SdLBZp7+yM2OqPMbp7oa1ZkFyqvA1nqWCSuZwPpt5FWN d4TSRZiiQSPN53xZdX7W28i3f9KGZLv3P4Eh+zb5hiW8/DBQYvWQ0Ao/l9ThdDRSjk+0 gWrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=aM2PSPrxNrBRUkxGEBvMStt5enzfr5m+0OaHz83BDyA=; fh=VX/Ya237jnqve4054D0Ov32VyHUHRsjkplnAOdTxQfQ=; b=OFTW8DZRmTvI+I1/slEgfCiZ29CwEM5l0boOaUFBrCizdgZe44VHtk5hLVv79v239R rnpEAimKzN+SIVBFRwSw3cI4bwGk9lx8Iw3Y3kKxYXqJ9At7ucZa+NIHWsClpZXegOJS nFnDJrnVsDbrpJkrALIZ7PMLUD6H0uTjn1P4V4pTwQhDW1x6yZ+k/k4KwXtEzBWcRyYO 4bAvumcXzje5YlK/mYseHQwIJ/xreyW/K3LhG+H5HIWrqEHyEl1b+//64vTLhcZPJPOg 7ECeeq9UbJD2bt+QuXm688/80Bfu6bFEbY7WkQu9qYJ+C9E4FaOSgNcDsr+CS5Esp8SQ 1aZA== 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=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l19-20020a056402125300b0052246cfd29bsi1241283edw.543.2023.08.04.02.24.36; Fri, 04 Aug 2023 02:25:01 -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=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229715AbjHDIxQ (ORCPT <rfc822;sukrut.bellary@gmail.com> + 99 others); Fri, 4 Aug 2023 04:53:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbjHDIwu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 4 Aug 2023 04:52:50 -0400 X-Greylist: delayed 92 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 04 Aug 2023 01:50:19 PDT Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB58355B1 for <linux-kernel@vger.kernel.org>; Fri, 4 Aug 2023 01:50:19 -0700 (PDT) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4RHKD94pTFz7S5Hk; Fri, 4 Aug 2023 16:50:17 +0800 (CST) Received: from szxlzmapp02.zte.com.cn ([10.5.231.79]) by mse-fl2.zte.com.cn with SMTP id 3748nisU010349; Fri, 4 Aug 2023 16:49:44 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Fri, 4 Aug 2023 16:49:46 +0800 (CST) Date: Fri, 4 Aug 2023 16:49:46 +0800 (CST) X-Zmail-TransId: 2b0364ccbbaaffffffff989-81c32 X-Mailer: Zmail v1.0 Message-ID: <202308041649468563730@zte.com.cn> Mime-Version: 1.0 From: <yang.yang29@zte.com.cn> To: <davem@davemloft.net> Cc: <dsahern@kernel.org>, <edumazet@google.com>, <kuba@kernel.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: =?utf-8?q?=5BPATCH=5D_udp=5Ftunnel=5Fnic=3A_add_net_device_refcount?= =?utf-8?q?_tracker?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 3748nisU010349 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 64CCBBC9.001/4RHKD94pTFz7S5Hk X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773289971268256480 X-GMAIL-MSGID: 1773289971268256480 |
Series |
udp_tunnel_nic: add net device refcount tracker
|
|
Commit Message
Yang Yang
Aug. 4, 2023, 8:49 a.m. UTC
From: xu xin <xu.xin16@zte.com.cn> Add net device refcount tracker to udp_tunnel_nic.c. Signed-off-by: xu xin <xu.xin16@zte.com.cn> Reviewed-by: Yang Yang <yang.yang29@zte.com.cn> Cc: Kuang Mingfu <kuang.mingfu@zte.com.cn> --- net/ipv4/udp_tunnel_nic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Comments
On Fri, Aug 4, 2023 at 10:50 AM <yang.yang29@zte.com.cn> wrote: > > From: xu xin <xu.xin16@zte.com.cn> > > Add net device refcount tracker to udp_tunnel_nic.c. > > Signed-off-by: xu xin <xu.xin16@zte.com.cn> > Reviewed-by: Yang Yang <yang.yang29@zte.com.cn> > Cc: Kuang Mingfu <kuang.mingfu@zte.com.cn> > --- > net/ipv4/udp_tunnel_nic.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c > index 029219749785..ce8f5c82b0a1 100644 > --- a/net/ipv4/udp_tunnel_nic.c > +++ b/net/ipv4/udp_tunnel_nic.c > @@ -55,6 +55,9 @@ struct udp_tunnel_nic { > */ > static struct workqueue_struct *udp_tunnel_nic_workqueue; > > +/* To track netdev_hold and netdev_put */ > +static netdevice_tracker udp_tunnel_nic_devtracker; This looks wrong. > + > static const char *udp_tunnel_nic_tunnel_type_name(unsigned int type) > { > switch (type) { > @@ -825,7 +828,7 @@ static int udp_tunnel_nic_register(struct net_device *dev) > } > > utn->dev = dev; > - dev_hold(dev); > + netdev_hold(dev, &udp_tunnel_nic_devtracker, GFP_KERNEL); This is wrong. You need a separate netdevice_tracker per netdev_hold() For instance, this would need to be in "(struct udp_tunnel_nic)->dev_tracker" > dev->udp_tunnel_nic = utn; > > if (!(info->flags & UDP_TUNNEL_NIC_INFO_OPEN_ONLY)) > @@ -879,7 +882,7 @@ udp_tunnel_nic_unregister(struct net_device *dev, struct udp_tunnel_nic *utn) > udp_tunnel_nic_free(utn); > release_dev: > dev->udp_tunnel_nic = NULL; > - dev_put(dev); > + netdev_put(dev, &udp_tunnel_nic_devtracker); > } > > static int > -- > 2.15.2
>> --- >> net/ipv4/udp_tunnel_nic.c | 7 +++++-- >> 1 file changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c >> index 029219749785..ce8f5c82b0a1 100644 >> --- a/net/ipv4/udp_tunnel_nic.c >> +++ b/net/ipv4/udp_tunnel_nic.c >> @@ -55,6 +55,9 @@ struct udp_tunnel_nic { >> */ >> static struct workqueue_struct *udp_tunnel_nic_workqueue; >> >> +/* To track netdev_hold and netdev_put */ >> +static netdevice_tracker udp_tunnel_nic_devtracker; > >This looks wrong. > >> + >> static const char *udp_tunnel_nic_tunnel_type_name(unsigned int type) >> { >> switch (type) { >> @@ -825,7 +828,7 @@ static int udp_tunnel_nic_register(struct net_device *dev) >> } >> >> utn->dev = dev; >> - dev_hold(dev); >> + netdev_hold(dev, &udp_tunnel_nic_devtracker, GFP_KERNEL); > >This is wrong. You need a separate netdevice_tracker per netdev_hold() > >For instance, this would need to be in "(struct udp_tunnel_nic)->dev_tracker" Oh, Sorry, I misunderstand the usage of netdev_hold and its netdevice_tracker. But cound you please add this this useful information into netdev_hold()' comment, to prevent others from making the same mistakes with me. Thanks!
diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c index 029219749785..ce8f5c82b0a1 100644 --- a/net/ipv4/udp_tunnel_nic.c +++ b/net/ipv4/udp_tunnel_nic.c @@ -55,6 +55,9 @@ struct udp_tunnel_nic { */ static struct workqueue_struct *udp_tunnel_nic_workqueue; +/* To track netdev_hold and netdev_put */ +static netdevice_tracker udp_tunnel_nic_devtracker; + static const char *udp_tunnel_nic_tunnel_type_name(unsigned int type) { switch (type) { @@ -825,7 +828,7 @@ static int udp_tunnel_nic_register(struct net_device *dev) } utn->dev = dev; - dev_hold(dev); + netdev_hold(dev, &udp_tunnel_nic_devtracker, GFP_KERNEL); dev->udp_tunnel_nic = utn; if (!(info->flags & UDP_TUNNEL_NIC_INFO_OPEN_ONLY)) @@ -879,7 +882,7 @@ udp_tunnel_nic_unregister(struct net_device *dev, struct udp_tunnel_nic *utn) udp_tunnel_nic_free(utn); release_dev: dev->udp_tunnel_nic = NULL; - dev_put(dev); + netdev_put(dev, &udp_tunnel_nic_devtracker); } static int