diff options
author | Daniel Lezcano <dlezcano@fr.ibm.com> | 2007-09-25 22:16:28 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:52:14 -0400 |
commit | de3cb747ffac5f2a4a6bb156e7e2fd5229e688e5 (patch) | |
tree | fe79764b8093843934c9b9f82f573e7a92cef406 /net/ipv4 | |
parent | 556829657397b9b05baec6691ead4e22ee8d1567 (diff) |
[NET]: Dynamically allocate the loopback device, part 1.
This patch replaces all occurences to the static variable
loopback_dev to a pointer loopback_dev. That provides the
mindless, trivial, uninteressting change part for the dynamic
allocation for the loopback.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Acked-By: Kirill Korotaev <dev@sw.ru>
Acked-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/devinet.c | 6 | ||||
-rw-r--r-- | net/ipv4/ipconfig.c | 6 | ||||
-rw-r--r-- | net/ipv4/ipvs/ip_vs_core.c | 2 | ||||
-rw-r--r-- | net/ipv4/route.c | 18 | ||||
-rw-r--r-- | net/ipv4/xfrm4_policy.c | 2 |
5 files changed, 17 insertions, 17 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 721b89b60963..affea9b121fc 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -203,7 +203,7 @@ static void inetdev_destroy(struct in_device *in_dev) | |||
203 | ASSERT_RTNL(); | 203 | ASSERT_RTNL(); |
204 | 204 | ||
205 | dev = in_dev->dev; | 205 | dev = in_dev->dev; |
206 | if (dev == &loopback_dev) | 206 | if (dev == loopback_dev) |
207 | return; | 207 | return; |
208 | 208 | ||
209 | in_dev->dead = 1; | 209 | in_dev->dead = 1; |
@@ -1061,7 +1061,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1061 | in_dev = inetdev_init(dev); | 1061 | in_dev = inetdev_init(dev); |
1062 | if (!in_dev) | 1062 | if (!in_dev) |
1063 | return notifier_from_errno(-ENOMEM); | 1063 | return notifier_from_errno(-ENOMEM); |
1064 | if (dev == &loopback_dev) { | 1064 | if (dev == loopback_dev) { |
1065 | IN_DEV_CONF_SET(in_dev, NOXFRM, 1); | 1065 | IN_DEV_CONF_SET(in_dev, NOXFRM, 1); |
1066 | IN_DEV_CONF_SET(in_dev, NOPOLICY, 1); | 1066 | IN_DEV_CONF_SET(in_dev, NOPOLICY, 1); |
1067 | } | 1067 | } |
@@ -1077,7 +1077,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1077 | case NETDEV_UP: | 1077 | case NETDEV_UP: |
1078 | if (dev->mtu < 68) | 1078 | if (dev->mtu < 68) |
1079 | break; | 1079 | break; |
1080 | if (dev == &loopback_dev) { | 1080 | if (dev == loopback_dev) { |
1081 | struct in_ifaddr *ifa; | 1081 | struct in_ifaddr *ifa; |
1082 | if ((ifa = inet_alloc_ifa()) != NULL) { | 1082 | if ((ifa = inet_alloc_ifa()) != NULL) { |
1083 | ifa->ifa_local = | 1083 | ifa->ifa_local = |
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 4303851749f6..2d2e0cda0470 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c | |||
@@ -190,11 +190,11 @@ static int __init ic_open_devs(void) | |||
190 | rtnl_lock(); | 190 | rtnl_lock(); |
191 | 191 | ||
192 | /* bring loopback device up first */ | 192 | /* bring loopback device up first */ |
193 | if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0) | 193 | if (dev_change_flags(loopback_dev, loopback_dev->flags | IFF_UP) < 0) |
194 | printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev.name); | 194 | printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev->name); |
195 | 195 | ||
196 | for_each_netdev(&init_net, dev) { | 196 | for_each_netdev(&init_net, dev) { |
197 | if (dev == &loopback_dev) | 197 | if (dev == loopback_dev) |
198 | continue; | 198 | continue; |
199 | if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) : | 199 | if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) : |
200 | (!(dev->flags & IFF_LOOPBACK) && | 200 | (!(dev->flags & IFF_LOOPBACK) && |
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c index f005a2f929f4..74503267e5d4 100644 --- a/net/ipv4/ipvs/ip_vs_core.c +++ b/net/ipv4/ipvs/ip_vs_core.c | |||
@@ -961,7 +961,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff **pskb, | |||
961 | * ... don't know why 1st test DOES NOT include 2nd (?) | 961 | * ... don't know why 1st test DOES NOT include 2nd (?) |
962 | */ | 962 | */ |
963 | if (unlikely(skb->pkt_type != PACKET_HOST | 963 | if (unlikely(skb->pkt_type != PACKET_HOST |
964 | || skb->dev == &loopback_dev || skb->sk)) { | 964 | || skb->dev == loopback_dev || skb->sk)) { |
965 | IP_VS_DBG(12, "packet type=%d proto=%d daddr=%d.%d.%d.%d ignored\n", | 965 | IP_VS_DBG(12, "packet type=%d proto=%d daddr=%d.%d.%d.%d ignored\n", |
966 | skb->pkt_type, | 966 | skb->pkt_type, |
967 | ip_hdr(skb)->protocol, | 967 | ip_hdr(skb)->protocol, |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 006d6058a806..ca2878dc6188 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 != 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(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 = 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 | 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 = 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 = 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 = loopback_dev; |
2247 | dev_hold(dev_out); | 2247 | dev_hold(dev_out); |
2248 | fl.oif = loopback_dev.ifindex; | 2248 | fl.oif = 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 = 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) |
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 4ff8ed30024f..29ab3de8c47f 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c | |||
@@ -306,7 +306,7 @@ static void xfrm4_dst_ifdown(struct dst_entry *dst, struct net_device *dev, | |||
306 | 306 | ||
307 | xdst = (struct xfrm_dst *)dst; | 307 | xdst = (struct xfrm_dst *)dst; |
308 | if (xdst->u.rt.idev->dev == dev) { | 308 | if (xdst->u.rt.idev->dev == dev) { |
309 | struct in_device *loopback_idev = in_dev_get(&loopback_dev); | 309 | struct in_device *loopback_idev = in_dev_get(loopback_dev); |
310 | BUG_ON(!loopback_idev); | 310 | BUG_ON(!loopback_idev); |
311 | 311 | ||
312 | do { | 312 | do { |