Thread (34 messages) 34 messages, 7 authors, 2017-12-21

Re: [bpf-next V1-RFC PATCH 10/14] tun: setup xdp_rxq_info

From: Jesper Dangaard Brouer <hidden>
Date: 2017-12-21 15:42:38

On Wed, 20 Dec 2017 15:48:01 +0800
Jason Wang [off-list ref] wrote:
quoted
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?
 
quoted
+		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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help