aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-09-27 01:10:56 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:52:49 -0400
commit2774c7aba6c97a2535be3309a2209770953780b3 (patch)
tree9327c795707f6d723c6395c31e1c060e70b5e0db /net/ipv4/route.c
parent0cc217e16cb8ca8ef2544363571fce94259900e0 (diff)
[NET]: Make the loopback device per network namespace.
This patch makes loopback_dev per network namespace. Adding code to create a different loopback device for each network namespace and adding the code to free a loopback device when a network namespace exits. This patch modifies all users the loopback_dev so they access it as init_net.loopback_dev, keeping all of the code compiling and working. A later pass will be needed to update the users to use something other than the initial network namespace. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index ca2878dc6188..2a9b363e820c 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1402,8 +1402,8 @@ static void ipv4_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
1402{ 1402{
1403 struct rtable *rt = (struct rtable *) dst; 1403 struct rtable *rt = (struct rtable *) dst;
1404 struct in_device *idev = rt->idev; 1404 struct in_device *idev = rt->idev;
1405 if (dev != loopback_dev && idev && idev->dev == dev) { 1405 if (dev != init_net.loopback_dev && idev && idev->dev == dev) {
1406 struct in_device *loopback_idev = in_dev_get(loopback_dev); 1406 struct in_device *loopback_idev = in_dev_get(init_net.loopback_dev);
1407 if (loopback_idev) { 1407 if (loopback_idev) {
1408 rt->idev = loopback_idev; 1408 rt->idev = loopback_idev;
1409 in_dev_put(idev); 1409 in_dev_put(idev);
@@ -1555,7 +1555,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1555#endif 1555#endif
1556 rth->rt_iif = 1556 rth->rt_iif =
1557 rth->fl.iif = dev->ifindex; 1557 rth->fl.iif = dev->ifindex;
1558 rth->u.dst.dev = loopback_dev; 1558 rth->u.dst.dev = init_net.loopback_dev;
1559 dev_hold(rth->u.dst.dev); 1559 dev_hold(rth->u.dst.dev);
1560 rth->idev = in_dev_get(rth->u.dst.dev); 1560 rth->idev = in_dev_get(rth->u.dst.dev);
1561 rth->fl.oif = 0; 1561 rth->fl.oif = 0;
@@ -1812,7 +1812,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1812 if (res.type == RTN_LOCAL) { 1812 if (res.type == RTN_LOCAL) {
1813 int result; 1813 int result;
1814 result = fib_validate_source(saddr, daddr, tos, 1814 result = fib_validate_source(saddr, daddr, tos,
1815 loopback_dev->ifindex, 1815 init_net.loopback_dev->ifindex,
1816 dev, &spec_dst, &itag); 1816 dev, &spec_dst, &itag);
1817 if (result < 0) 1817 if (result < 0)
1818 goto martian_source; 1818 goto martian_source;
@@ -1879,7 +1879,7 @@ local_input:
1879#endif 1879#endif
1880 rth->rt_iif = 1880 rth->rt_iif =
1881 rth->fl.iif = dev->ifindex; 1881 rth->fl.iif = dev->ifindex;
1882 rth->u.dst.dev = loopback_dev; 1882 rth->u.dst.dev = init_net.loopback_dev;
1883 dev_hold(rth->u.dst.dev); 1883 dev_hold(rth->u.dst.dev);
1884 rth->idev = in_dev_get(rth->u.dst.dev); 1884 rth->idev = in_dev_get(rth->u.dst.dev);
1885 rth->rt_gateway = daddr; 1885 rth->rt_gateway = daddr;
@@ -2149,7 +2149,7 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
2149 RT_SCOPE_UNIVERSE), 2149 RT_SCOPE_UNIVERSE),
2150 } }, 2150 } },
2151 .mark = oldflp->mark, 2151 .mark = oldflp->mark,
2152 .iif = loopback_dev->ifindex, 2152 .iif = init_net.loopback_dev->ifindex,
2153 .oif = oldflp->oif }; 2153 .oif = oldflp->oif };
2154 struct fib_result res; 2154 struct fib_result res;
2155 unsigned flags = 0; 2155 unsigned flags = 0;
@@ -2243,9 +2243,9 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
2243 fl.fl4_dst = fl.fl4_src = htonl(INADDR_LOOPBACK); 2243 fl.fl4_dst = fl.fl4_src = htonl(INADDR_LOOPBACK);
2244 if (dev_out) 2244 if (dev_out)
2245 dev_put(dev_out); 2245 dev_put(dev_out);
2246 dev_out = loopback_dev; 2246 dev_out = init_net.loopback_dev;
2247 dev_hold(dev_out); 2247 dev_hold(dev_out);
2248 fl.oif = loopback_dev->ifindex; 2248 fl.oif = init_net.loopback_dev->ifindex;
2249 res.type = RTN_LOCAL; 2249 res.type = RTN_LOCAL;
2250 flags |= RTCF_LOCAL; 2250 flags |= RTCF_LOCAL;
2251 goto make_route; 2251 goto make_route;
@@ -2290,7 +2290,7 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
2290 fl.fl4_src = fl.fl4_dst; 2290 fl.fl4_src = fl.fl4_dst;
2291 if (dev_out) 2291 if (dev_out)
2292 dev_put(dev_out); 2292 dev_put(dev_out);
2293 dev_out = loopback_dev; 2293 dev_out = init_net.loopback_dev;
2294 dev_hold(dev_out); 2294 dev_hold(dev_out);
2295 fl.oif = dev_out->ifindex; 2295 fl.oif = dev_out->ifindex;
2296 if (res.fi) 2296 if (res.fi)