On Wed, 20 Dec 2017 15:48:01 +0800
Jason Wang <[email protected]> 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