OpenVZ Forum


Home » Mailing lists » Devel » [PATCH] tun: don't hold network namespace by tun sockets
Re: [PATCH] tun: don't hold network namespace by tun sockets [message #45462 is a reply to message #45461] Sun, 11 March 2012 17:29 Go to previous message
Eric Dumazet is currently offline  Eric Dumazet
Messages: 36
Registered: July 2006
Member
Le dimanche 11 mars 2012 à 19:21 +0400, Stanislav Kinsbursky a écrit :
> TUN was designed to destroy it's socket on network namesapce shutdown. But this
> will never happen for persistent device, because it's socket holds network
> namespace.
> This patch removes of holding network namespace by TUN socket and replaces it
> by creating socket in init_net and then changing it's net it to desired one. On
> shutdown socket is moved back to init_net prior to final put.
>
> Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
>
> ---
> drivers/net/tun.c | 10 +++++++---
> 1 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 2c5d349..92ef539 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -358,8 +358,11 @@ static void tun_net_uninit(struct net_device *dev)
> static void tun_free_netdev(struct net_device *dev)
> {
> struct tun_struct *tun = netdev_priv(dev);
> + struct sock *sk = tun->socket.sk;
>
> - sock_put(tun->socket.sk);
> + release_net(sock_net(sk));
> + sock_net_set(sk, get_net(&init_net));
> + sock_put(sk);


Hmm, maybe use sk_release_kernel(), as its should be the thing
associated with sk_change_net().

Or at least make intent clear, since its not obvious.
 
Read Message
Read Message
Previous Topic: [PATCH 0/2] NFS: blocklayout PipeFS conteinerization fixes
Next Topic: Re: [PATCH v2 02/13] memcg: Kernel memory accounting infrastructure.
Goto Forum:
  


Current Time: Wed Oct 15 05:51:48 GMT 2025

Total time taken to generate the page: 0.27628 seconds