From: Eric Dumazet <eric.dumazet@gmail.com>
To: Stanislav Kinsbursky <skinsbursky@parallels.com>
Cc: davem@davemloft.net, ebiederm@aristanetworks.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
xemul@parallel.com, shemminger@vyatta.com, devel@openvz.org
Subject: Re: [PATCH] tun: don't hold network namespace by tun sockets
Date: Sun, 11 Mar 2012 10:29:29 -0700 [thread overview]
Message-ID: <1331486969.2449.15.camel@edumazet-laptop> (raw)
In-Reply-To: <20120311152053.30481.29572.stgit@localhost6.localdomain6>
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.
next prev parent reply other threads:[~2012-03-11 17:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-11 15:21 [PATCH] tun: don't hold network namespace by tun sockets Stanislav Kinsbursky
2012-03-11 17:29 ` Eric Dumazet [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-03-12 13:49 Stanislav Kinsbursky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1331486969.2449.15.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=devel@openvz.org \
--cc=ebiederm@aristanetworks.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
--cc=skinsbursky@parallels.com \
--cc=xemul@parallel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox