Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 79277
b: refs/heads/master
c: 775516b
h: refs/heads/master
i:
  79275: eb6e00d
v: v3
  • Loading branch information
Denis V. Lunev authored and David S. Miller committed Jan 28, 2008
1 parent 8a0eeda commit 69a70f4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b7c6ba6eb1234e35a74fb8ba8123232a7b1ba9e4
refs/heads/master: 775516bfa2bd7993620c9039191a0c30b8d8a496
15 changes: 2 additions & 13 deletions trunk/net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,25 +1368,14 @@ static int rtnetlink_net_init(struct net *net)
rtnetlink_rcv, &rtnl_mutex, THIS_MODULE);
if (!sk)
return -ENOMEM;

/* Don't hold an extra reference on the namespace */
put_net(sk->sk_net);
net->rtnl = sk;
return 0;
}

static void rtnetlink_net_exit(struct net *net)
{
struct sock *sk = net->rtnl;
if (sk) {
/* At the last minute lie and say this is a socket for the
* initial network namespace. So the socket will be safe to
* free.
*/
sk->sk_net = get_net(&init_net);
netlink_kernel_release(net->rtnl);
net->rtnl = NULL;
}
netlink_kernel_release(net->rtnl);
net->rtnl = NULL;
}

static struct pernet_operations rtnetlink_net_ops = {
Expand Down
7 changes: 1 addition & 6 deletions trunk/net/ipv4/fib_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,19 +869,14 @@ static int nl_fib_lookup_init(struct net *net)
nl_fib_input, NULL, THIS_MODULE);
if (sk == NULL)
return -EAFNOSUPPORT;
/* Don't hold an extra reference on the namespace */
put_net(sk->sk_net);
net->ipv4.fibnl = sk;
return 0;
}

static void nl_fib_lookup_exit(struct net *net)
{
/* At the last minute lie and say this is a socket for the
* initial network namespace. So the socket will be safe to free.
*/
net->ipv4.fibnl->sk_net = get_net(&init_net);
netlink_kernel_release(net->ipv4.fibnl);
net->ipv4.fibnl = NULL;
}

static void fib_disable_ip(struct net_device *dev, int force)
Expand Down
15 changes: 15 additions & 0 deletions trunk/net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,9 @@ netlink_kernel_create(struct net *net, int unit, unsigned int groups,
}
netlink_table_ungrab();

/* Do not hold an extra referrence to a namespace as this socket is
* internal to a namespace and does not prevent it to stop. */
put_net(net);
return sk;

out_sock_release:
Expand All @@ -1411,7 +1414,19 @@ netlink_kernel_release(struct sock *sk)
{
if (sk == NULL || sk->sk_socket == NULL)
return;

/*
* Last sock_put should drop referrence to sk->sk_net. It has already
* been dropped in netlink_kernel_create. Taking referrence to stopping
* namespace is not an option.
* Take referrence to a socket to remove it from netlink lookup table
* _alive_ and after that destroy it in the context of init_net.
*/
sock_hold(sk);
sock_release(sk->sk_socket);

sk->sk_net = get_net(&init_net);
sock_put(sk);
}
EXPORT_SYMBOL(netlink_kernel_release);

Expand Down

0 comments on commit 69a70f4

Please sign in to comment.