aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2007-12-07 03:38:10 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:56:44 -0500
commit5a3e55d68ec5baac578bf32ba67607088c763657 (patch)
tree9e8f9dfae66c8a85735122ece8a9c85cdb5c31c4 /net
parentb84a2189c4e1835c51fd6b974a0497be9bc4ba87 (diff)
[NET]: Multiple namespaces in the all dst_ifdown routines.
Move dst entries to a namespace loopback to catch refcounting leaks. Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/dst.c4
-rw-r--r--net/ipv4/route.c5
-rw-r--r--net/ipv4/xfrm4_policy.c3
-rw-r--r--net/ipv6/route.c7
-rw-r--r--net/ipv6/xfrm6_policy.c3
-rw-r--r--net/xfrm/xfrm_policy.c2
6 files changed, 15 insertions, 9 deletions
diff --git a/net/core/dst.c b/net/core/dst.c
index f538061f4b93..5c6cfc4e7fdb 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -279,11 +279,11 @@ static inline void dst_ifdown(struct dst_entry *dst, struct net_device *dev,
279 if (!unregister) { 279 if (!unregister) {
280 dst->input = dst->output = dst_discard; 280 dst->input = dst->output = dst_discard;
281 } else { 281 } else {
282 dst->dev = init_net.loopback_dev; 282 dst->dev = dst->dev->nd_net->loopback_dev;
283 dev_hold(dst->dev); 283 dev_hold(dst->dev);
284 dev_put(dev); 284 dev_put(dev);
285 if (dst->neighbour && dst->neighbour->dev == dev) { 285 if (dst->neighbour && dst->neighbour->dev == dev) {
286 dst->neighbour->dev = init_net.loopback_dev; 286 dst->neighbour->dev = dst->dev;
287 dev_put(dev); 287 dev_put(dev);
288 dev_hold(dst->neighbour->dev); 288 dev_hold(dst->neighbour->dev);
289 } 289 }
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index d95e48e8d65c..b576f8cd4019 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1512,8 +1512,9 @@ static void ipv4_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
1512{ 1512{
1513 struct rtable *rt = (struct rtable *) dst; 1513 struct rtable *rt = (struct rtable *) dst;
1514 struct in_device *idev = rt->idev; 1514 struct in_device *idev = rt->idev;
1515 if (dev != init_net.loopback_dev && idev && idev->dev == dev) { 1515 if (dev != dev->nd_net->loopback_dev && idev && idev->dev == dev) {
1516 struct in_device *loopback_idev = in_dev_get(init_net.loopback_dev); 1516 struct in_device *loopback_idev =
1517 in_dev_get(dev->nd_net->loopback_dev);
1517 if (loopback_idev) { 1518 if (loopback_idev) {
1518 rt->idev = loopback_idev; 1519 rt->idev = loopback_idev;
1519 in_dev_put(idev); 1520 in_dev_put(idev);
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index b4948c170b3e..10b72d185bb9 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -214,7 +214,8 @@ static void xfrm4_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
214 214
215 xdst = (struct xfrm_dst *)dst; 215 xdst = (struct xfrm_dst *)dst;
216 if (xdst->u.rt.idev->dev == dev) { 216 if (xdst->u.rt.idev->dev == dev) {
217 struct in_device *loopback_idev = in_dev_get(init_net.loopback_dev); 217 struct in_device *loopback_idev =
218 in_dev_get(dev->nd_net->loopback_dev);
218 BUG_ON(!loopback_idev); 219 BUG_ON(!loopback_idev);
219 220
220 do { 221 do {
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index e2c980dbe52d..452111fa4c52 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -216,9 +216,12 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
216{ 216{
217 struct rt6_info *rt = (struct rt6_info *)dst; 217 struct rt6_info *rt = (struct rt6_info *)dst;
218 struct inet6_dev *idev = rt->rt6i_idev; 218 struct inet6_dev *idev = rt->rt6i_idev;
219 struct net_device *loopback_dev =
220 dev->nd_net->loopback_dev;
219 221
220 if (dev != init_net.loopback_dev && idev != NULL && idev->dev == dev) { 222 if (dev != loopback_dev && idev != NULL && idev->dev == dev) {
221 struct inet6_dev *loopback_idev = in6_dev_get(init_net.loopback_dev); 223 struct inet6_dev *loopback_idev =
224 in6_dev_get(loopback_dev);
222 if (loopback_idev != NULL) { 225 if (loopback_idev != NULL) {
223 rt->rt6i_idev = loopback_idev; 226 rt->rt6i_idev = loopback_idev;
224 in6_dev_put(idev); 227 in6_dev_put(idev);
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index a31dd531e191..4d54951cea08 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -229,7 +229,8 @@ static void xfrm6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
229 229
230 xdst = (struct xfrm_dst *)dst; 230 xdst = (struct xfrm_dst *)dst;
231 if (xdst->u.rt6.rt6i_idev->dev == dev) { 231 if (xdst->u.rt6.rt6i_idev->dev == dev) {
232 struct inet6_dev *loopback_idev = in6_dev_get(init_net.loopback_dev); 232 struct inet6_dev *loopback_idev =
233 in6_dev_get(dev->nd_net->loopback_dev);
233 BUG_ON(!loopback_idev); 234 BUG_ON(!loopback_idev);
234 235
235 do { 236 do {
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index a76280a14e72..95dc581861e8 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1934,7 +1934,7 @@ static int stale_bundle(struct dst_entry *dst)
1934void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev) 1934void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev)
1935{ 1935{
1936 while ((dst = dst->child) && dst->xfrm && dst->dev == dev) { 1936 while ((dst = dst->child) && dst->xfrm && dst->dev == dev) {
1937 dst->dev = init_net.loopback_dev; 1937 dst->dev = dev->nd_net->loopback_dev;
1938 dev_hold(dst->dev); 1938 dev_hold(dst->dev);
1939 dev_put(dev); 1939 dev_put(dev);
1940 } 1940 }