From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesper Dangaard Brouer Subject: Re: [bpf-next V1-RFC PATCH 10/14] tun: setup xdp_rxq_info Date: Thu, 21 Dec 2017 16:42:28 +0100 Message-ID: <20171221164228.1d1a89b0@redhat.com> References: <151316391502.14967.13292358380181773729.stgit@firesoul> <151316401179.14967.17180656885206924171.stgit@firesoul> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Daniel Borkmann , Alexei Starovoitov , Willem de Bruijn , "Michael S. Tsirkin" , netdev@vger.kernel.org, dsahern@gmail.com, gospo@broadcom.com, bjorn.topel@intel.com, michael.chan@broadcom.com, brouer@redhat.com To: Jason Wang Return-path: Received: from mx1.redhat.com ([209.132.183.28]:55140 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752477AbdLUPmi (ORCPT ); Thu, 21 Dec 2017 10:42:38 -0500 In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: On Wed, 20 Dec 2017 15:48:01 +0800 Jason Wang wrote: > > diff --git a/drivers/net/tun.c b/drivers/net/tun.c > > index e367d6310353..f1df08c2c541 100644 > > --- a/drivers/net/tun.c > > +++ b/drivers/net/tun.c > > @@ -180,6 +180,7 @@ struct tun_file { > > struct list_head next; > > struct tun_struct *detached; > > struct skb_array tx_array; > > + struct xdp_rxq_info xdp_rxq; > > }; > > > > struct tun_flow_entry { > > @@ -687,8 +688,10 @@ static void __tun_detach(struct tun_file *tfile, bool clean) > > tun->dev->reg_state == NETREG_REGISTERED) > > unregister_netdevice(tun->dev); > > } > > - if (tun) > > + if (tun) { > > skb_array_cleanup(&tfile->tx_array); > > + xdp_rxq_info_unreg(&tfile->xdp_rxq); > > + } > > sock_put(&tfile->sk); > > } > > } > > @@ -728,11 +731,15 @@ static void tun_detach_all(struct net_device *dev) > > tun_napi_del(tun, tfile); > > /* Drop read queue */ > > tun_queue_purge(tfile); > > + skb_array_cleanup(&tfile->tx_array); > > Looks like this is unnecessary, skb array will be cleaned up only when > fd is closed otherwise there will be a double free. What code path is called on "fd close" which call skb_array_cleanup() ? (Is it __tun_detach()?) Then, I guess I don't need below xdp_rxq_info_unreg() either, right? > > + xdp_rxq_info_unreg(&tfile->xdp_rxq); > > sock_put(&tfile->sk); -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer