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 | |
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>
-rw-r--r-- | drivers/net/loopback.c | 6 | ||||
-rw-r--r-- | include/linux/netdevice.h | 2 | ||||
-rw-r--r-- | net/core/dst.c | 8 | ||||
-rw-r--r-- | net/decnet/dn_dev.c | 4 | ||||
-rw-r--r-- | net/decnet/dn_route.c | 14 | ||||
-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 | ||||
-rw-r--r-- | net/ipv6/addrconf.c | 15 | ||||
-rw-r--r-- | net/ipv6/ip6_input.c | 2 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6t_REJECT.c | 2 | ||||
-rw-r--r-- | net/ipv6/route.c | 15 | ||||
-rw-r--r-- | net/ipv6/xfrm6_policy.c | 2 | ||||
-rw-r--r-- | net/xfrm/xfrm_policy.c | 4 |
16 files changed, 55 insertions, 53 deletions
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 0e2252fd71ab..588092e13186 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c | |||
@@ -202,7 +202,7 @@ static const struct ethtool_ops loopback_ethtool_ops = { | |||
202 | * The loopback device is special. There is only one instance and | 202 | * The loopback device is special. There is only one instance and |
203 | * it is statically allocated. Don't do this for other devices. | 203 | * it is statically allocated. Don't do this for other devices. |
204 | */ | 204 | */ |
205 | struct net_device loopback_dev = { | 205 | struct net_device __loopback_dev = { |
206 | .name = "lo", | 206 | .name = "lo", |
207 | .get_stats = &get_stats, | 207 | .get_stats = &get_stats, |
208 | .mtu = (16 * 1024) + 20 + 20 + 12, | 208 | .mtu = (16 * 1024) + 20 + 20 + 12, |
@@ -227,10 +227,12 @@ struct net_device loopback_dev = { | |||
227 | .nd_net = &init_net, | 227 | .nd_net = &init_net, |
228 | }; | 228 | }; |
229 | 229 | ||
230 | struct net_device *loopback_dev = &__loopback_dev; | ||
231 | |||
230 | /* Setup and register the loopback device. */ | 232 | /* Setup and register the loopback device. */ |
231 | static int __init loopback_init(void) | 233 | static int __init loopback_init(void) |
232 | { | 234 | { |
233 | int err = register_netdev(&loopback_dev); | 235 | int err = register_netdev(loopback_dev); |
234 | 236 | ||
235 | if (err) | 237 | if (err) |
236 | panic("loopback: Failed to register netdevice: %d\n", err); | 238 | panic("loopback: Failed to register netdevice: %d\n", err); |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index cf89ce677e41..baa915f0d285 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -741,7 +741,7 @@ struct packet_type { | |||
741 | #include <linux/interrupt.h> | 741 | #include <linux/interrupt.h> |
742 | #include <linux/notifier.h> | 742 | #include <linux/notifier.h> |
743 | 743 | ||
744 | extern struct net_device loopback_dev; /* The loopback */ | 744 | extern struct net_device *loopback_dev; /* The loopback */ |
745 | extern rwlock_t dev_base_lock; /* Device list lock */ | 745 | extern rwlock_t dev_base_lock; /* Device list lock */ |
746 | 746 | ||
747 | 747 | ||
diff --git a/net/core/dst.c b/net/core/dst.c index 38c741ac5d08..ad5ffa19d809 100644 --- a/net/core/dst.c +++ b/net/core/dst.c | |||
@@ -278,13 +278,13 @@ static inline void dst_ifdown(struct dst_entry *dst, struct net_device *dev, | |||
278 | if (!unregister) { | 278 | if (!unregister) { |
279 | dst->input = dst->output = dst_discard; | 279 | dst->input = dst->output = dst_discard; |
280 | } else { | 280 | } else { |
281 | dst->dev = &loopback_dev; | 281 | dst->dev = loopback_dev; |
282 | dev_hold(&loopback_dev); | 282 | dev_hold(dst->dev); |
283 | dev_put(dev); | 283 | dev_put(dev); |
284 | if (dst->neighbour && dst->neighbour->dev == dev) { | 284 | if (dst->neighbour && dst->neighbour->dev == dev) { |
285 | dst->neighbour->dev = &loopback_dev; | 285 | dst->neighbour->dev = loopback_dev; |
286 | dev_put(dev); | 286 | dev_put(dev); |
287 | dev_hold(&loopback_dev); | 287 | dev_hold(dst->neighbour->dev); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | } | 290 | } |
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c index fa24614b5a37..bcaf4c5aa68e 100644 --- a/net/decnet/dn_dev.c +++ b/net/decnet/dn_dev.c | |||
@@ -869,10 +869,10 @@ last_chance: | |||
869 | rv = dn_dev_get_first(dev, addr); | 869 | rv = dn_dev_get_first(dev, addr); |
870 | read_unlock(&dev_base_lock); | 870 | read_unlock(&dev_base_lock); |
871 | dev_put(dev); | 871 | dev_put(dev); |
872 | if (rv == 0 || dev == &loopback_dev) | 872 | if (rv == 0 || dev == loopback_dev) |
873 | return rv; | 873 | return rv; |
874 | } | 874 | } |
875 | dev = &loopback_dev; | 875 | dev = loopback_dev; |
876 | dev_hold(dev); | 876 | dev_hold(dev); |
877 | goto last_chance; | 877 | goto last_chance; |
878 | } | 878 | } |
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index 70b1c3fa00f3..96fe0aa1638e 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c | |||
@@ -887,7 +887,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old | |||
887 | .scope = RT_SCOPE_UNIVERSE, | 887 | .scope = RT_SCOPE_UNIVERSE, |
888 | } }, | 888 | } }, |
889 | .mark = oldflp->mark, | 889 | .mark = oldflp->mark, |
890 | .iif = loopback_dev.ifindex, | 890 | .iif = loopback_dev->ifindex, |
891 | .oif = oldflp->oif }; | 891 | .oif = oldflp->oif }; |
892 | struct dn_route *rt = NULL; | 892 | struct dn_route *rt = NULL; |
893 | struct net_device *dev_out = NULL, *dev; | 893 | struct net_device *dev_out = NULL, *dev; |
@@ -904,7 +904,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old | |||
904 | "dn_route_output_slow: dst=%04x src=%04x mark=%d" | 904 | "dn_route_output_slow: dst=%04x src=%04x mark=%d" |
905 | " iif=%d oif=%d\n", dn_ntohs(oldflp->fld_dst), | 905 | " iif=%d oif=%d\n", dn_ntohs(oldflp->fld_dst), |
906 | dn_ntohs(oldflp->fld_src), | 906 | dn_ntohs(oldflp->fld_src), |
907 | oldflp->mark, loopback_dev.ifindex, oldflp->oif); | 907 | oldflp->mark, loopback_dev->ifindex, oldflp->oif); |
908 | 908 | ||
909 | /* If we have an output interface, verify its a DECnet device */ | 909 | /* If we have an output interface, verify its a DECnet device */ |
910 | if (oldflp->oif) { | 910 | if (oldflp->oif) { |
@@ -957,7 +957,7 @@ source_ok: | |||
957 | err = -EADDRNOTAVAIL; | 957 | err = -EADDRNOTAVAIL; |
958 | if (dev_out) | 958 | if (dev_out) |
959 | dev_put(dev_out); | 959 | dev_put(dev_out); |
960 | dev_out = &loopback_dev; | 960 | dev_out = loopback_dev; |
961 | dev_hold(dev_out); | 961 | dev_hold(dev_out); |
962 | if (!fl.fld_dst) { | 962 | if (!fl.fld_dst) { |
963 | fl.fld_dst = | 963 | fl.fld_dst = |
@@ -966,7 +966,7 @@ source_ok: | |||
966 | if (!fl.fld_dst) | 966 | if (!fl.fld_dst) |
967 | goto out; | 967 | goto out; |
968 | } | 968 | } |
969 | fl.oif = loopback_dev.ifindex; | 969 | fl.oif = loopback_dev->ifindex; |
970 | res.type = RTN_LOCAL; | 970 | res.type = RTN_LOCAL; |
971 | goto make_route; | 971 | goto make_route; |
972 | } | 972 | } |
@@ -1012,7 +1012,7 @@ source_ok: | |||
1012 | if (dev_out) | 1012 | if (dev_out) |
1013 | dev_put(dev_out); | 1013 | dev_put(dev_out); |
1014 | if (dn_dev_islocal(neigh->dev, fl.fld_dst)) { | 1014 | if (dn_dev_islocal(neigh->dev, fl.fld_dst)) { |
1015 | dev_out = &loopback_dev; | 1015 | dev_out = loopback_dev; |
1016 | res.type = RTN_LOCAL; | 1016 | res.type = RTN_LOCAL; |
1017 | } else { | 1017 | } else { |
1018 | dev_out = neigh->dev; | 1018 | dev_out = neigh->dev; |
@@ -1033,7 +1033,7 @@ source_ok: | |||
1033 | /* Possible improvement - check all devices for local addr */ | 1033 | /* Possible improvement - check all devices for local addr */ |
1034 | if (dn_dev_islocal(dev_out, fl.fld_dst)) { | 1034 | if (dn_dev_islocal(dev_out, fl.fld_dst)) { |
1035 | dev_put(dev_out); | 1035 | dev_put(dev_out); |
1036 | dev_out = &loopback_dev; | 1036 | dev_out = loopback_dev; |
1037 | dev_hold(dev_out); | 1037 | dev_hold(dev_out); |
1038 | res.type = RTN_LOCAL; | 1038 | res.type = RTN_LOCAL; |
1039 | goto select_source; | 1039 | goto select_source; |
@@ -1069,7 +1069,7 @@ select_source: | |||
1069 | fl.fld_src = fl.fld_dst; | 1069 | fl.fld_src = fl.fld_dst; |
1070 | if (dev_out) | 1070 | if (dev_out) |
1071 | dev_put(dev_out); | 1071 | dev_put(dev_out); |
1072 | dev_out = &loopback_dev; | 1072 | dev_out = loopback_dev; |
1073 | dev_hold(dev_out); | 1073 | dev_hold(dev_out); |
1074 | fl.oif = dev_out->ifindex; | 1074 | fl.oif = dev_out->ifindex; |
1075 | if (res.fi) | 1075 | if (res.fi) |
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 { |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 9c2e94f1c637..b43574f73375 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -2410,7 +2410,7 @@ static int addrconf_ifdown(struct net_device *dev, int how) | |||
2410 | 2410 | ||
2411 | ASSERT_RTNL(); | 2411 | ASSERT_RTNL(); |
2412 | 2412 | ||
2413 | if (dev == &loopback_dev && how == 1) | 2413 | if (dev == loopback_dev && how == 1) |
2414 | how = 0; | 2414 | how = 0; |
2415 | 2415 | ||
2416 | rt6_ifdown(dev); | 2416 | rt6_ifdown(dev); |
@@ -4212,16 +4212,19 @@ int __init addrconf_init(void) | |||
4212 | * device and it being up should be removed. | 4212 | * device and it being up should be removed. |
4213 | */ | 4213 | */ |
4214 | rtnl_lock(); | 4214 | rtnl_lock(); |
4215 | if (!ipv6_add_dev(&loopback_dev)) | 4215 | if (!ipv6_add_dev(loopback_dev)) |
4216 | err = -ENOMEM; | 4216 | err = -ENOMEM; |
4217 | rtnl_unlock(); | 4217 | rtnl_unlock(); |
4218 | if (err) | 4218 | if (err) |
4219 | return err; | 4219 | return err; |
4220 | 4220 | ||
4221 | ip6_null_entry.rt6i_idev = in6_dev_get(&loopback_dev); | 4221 | ip6_null_entry.u.dst.dev = loopback_dev; |
4222 | ip6_null_entry.rt6i_idev = in6_dev_get(loopback_dev); | ||
4222 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 4223 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
4223 | ip6_prohibit_entry.rt6i_idev = in6_dev_get(&loopback_dev); | 4224 | ip6_prohibit_entry.u.dst.dev = loopback_dev; |
4224 | ip6_blk_hole_entry.rt6i_idev = in6_dev_get(&loopback_dev); | 4225 | ip6_prohibit_entry.rt6i_idev = in6_dev_get(loopback_dev); |
4226 | ip6_blk_hole_entry.u.dst.dev = loopback_dev; | ||
4227 | ip6_blk_hole_entry.rt6i_idev = in6_dev_get(loopback_dev); | ||
4225 | #endif | 4228 | #endif |
4226 | 4229 | ||
4227 | register_netdevice_notifier(&ipv6_dev_notf); | 4230 | register_netdevice_notifier(&ipv6_dev_notf); |
@@ -4276,7 +4279,7 @@ void __exit addrconf_cleanup(void) | |||
4276 | continue; | 4279 | continue; |
4277 | addrconf_ifdown(dev, 1); | 4280 | addrconf_ifdown(dev, 1); |
4278 | } | 4281 | } |
4279 | addrconf_ifdown(&loopback_dev, 2); | 4282 | addrconf_ifdown(loopback_dev, 2); |
4280 | 4283 | ||
4281 | /* | 4284 | /* |
4282 | * Check hash table. | 4285 | * Check hash table. |
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index 7d18cac3f110..9149fc239759 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c | |||
@@ -91,7 +91,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt | |||
91 | * | 91 | * |
92 | * BTW, when we send a packet for our own local address on a | 92 | * BTW, when we send a packet for our own local address on a |
93 | * non-loopback interface (e.g. ethX), it is being delivered | 93 | * non-loopback interface (e.g. ethX), it is being delivered |
94 | * via the loopback interface (lo) here; skb->dev = &loopback_dev. | 94 | * via the loopback interface (lo) here; skb->dev = loopback_dev. |
95 | * It, however, should be considered as if it is being | 95 | * It, however, should be considered as if it is being |
96 | * arrived via the sending interface (ethX), because of the | 96 | * arrived via the sending interface (ethX), because of the |
97 | * nature of scoping architecture. --yoshfuji | 97 | * nature of scoping architecture. --yoshfuji |
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c index 2f487cda3b6b..50860531cd3c 100644 --- a/net/ipv6/netfilter/ip6t_REJECT.c +++ b/net/ipv6/netfilter/ip6t_REJECT.c | |||
@@ -167,7 +167,7 @@ static inline void | |||
167 | send_unreach(struct sk_buff *skb_in, unsigned char code, unsigned int hooknum) | 167 | send_unreach(struct sk_buff *skb_in, unsigned char code, unsigned int hooknum) |
168 | { | 168 | { |
169 | if (hooknum == NF_IP6_LOCAL_OUT && skb_in->dev == NULL) | 169 | if (hooknum == NF_IP6_LOCAL_OUT && skb_in->dev == NULL) |
170 | skb_in->dev = &loopback_dev; | 170 | skb_in->dev = loopback_dev; |
171 | 171 | ||
172 | icmpv6_send(skb_in, ICMPV6_DEST_UNREACH, code, 0, NULL); | 172 | icmpv6_send(skb_in, ICMPV6_DEST_UNREACH, code, 0, NULL); |
173 | } | 173 | } |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 104070e92cea..a7a21a7ba790 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -138,7 +138,6 @@ struct rt6_info ip6_null_entry = { | |||
138 | .dst = { | 138 | .dst = { |
139 | .__refcnt = ATOMIC_INIT(1), | 139 | .__refcnt = ATOMIC_INIT(1), |
140 | .__use = 1, | 140 | .__use = 1, |
141 | .dev = &loopback_dev, | ||
142 | .obsolete = -1, | 141 | .obsolete = -1, |
143 | .error = -ENETUNREACH, | 142 | .error = -ENETUNREACH, |
144 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, | 143 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, |
@@ -164,7 +163,6 @@ struct rt6_info ip6_prohibit_entry = { | |||
164 | .dst = { | 163 | .dst = { |
165 | .__refcnt = ATOMIC_INIT(1), | 164 | .__refcnt = ATOMIC_INIT(1), |
166 | .__use = 1, | 165 | .__use = 1, |
167 | .dev = &loopback_dev, | ||
168 | .obsolete = -1, | 166 | .obsolete = -1, |
169 | .error = -EACCES, | 167 | .error = -EACCES, |
170 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, | 168 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, |
@@ -184,7 +182,6 @@ struct rt6_info ip6_blk_hole_entry = { | |||
184 | .dst = { | 182 | .dst = { |
185 | .__refcnt = ATOMIC_INIT(1), | 183 | .__refcnt = ATOMIC_INIT(1), |
186 | .__use = 1, | 184 | .__use = 1, |
187 | .dev = &loopback_dev, | ||
188 | .obsolete = -1, | 185 | .obsolete = -1, |
189 | .error = -EINVAL, | 186 | .error = -EINVAL, |
190 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, | 187 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, |
@@ -224,8 +221,8 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, | |||
224 | struct rt6_info *rt = (struct rt6_info *)dst; | 221 | struct rt6_info *rt = (struct rt6_info *)dst; |
225 | struct inet6_dev *idev = rt->rt6i_idev; | 222 | struct inet6_dev *idev = rt->rt6i_idev; |
226 | 223 | ||
227 | if (dev != &loopback_dev && idev != NULL && idev->dev == dev) { | 224 | if (dev != loopback_dev && idev != NULL && idev->dev == dev) { |
228 | struct inet6_dev *loopback_idev = in6_dev_get(&loopback_dev); | 225 | struct inet6_dev *loopback_idev = in6_dev_get(loopback_dev); |
229 | if (loopback_idev != NULL) { | 226 | if (loopback_idev != NULL) { |
230 | rt->rt6i_idev = loopback_idev; | 227 | rt->rt6i_idev = loopback_idev; |
231 | in6_dev_put(idev); | 228 | in6_dev_put(idev); |
@@ -1188,12 +1185,12 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1188 | if ((cfg->fc_flags & RTF_REJECT) || | 1185 | if ((cfg->fc_flags & RTF_REJECT) || |
1189 | (dev && (dev->flags&IFF_LOOPBACK) && !(addr_type&IPV6_ADDR_LOOPBACK))) { | 1186 | (dev && (dev->flags&IFF_LOOPBACK) && !(addr_type&IPV6_ADDR_LOOPBACK))) { |
1190 | /* hold loopback dev/idev if we haven't done so. */ | 1187 | /* hold loopback dev/idev if we haven't done so. */ |
1191 | if (dev != &loopback_dev) { | 1188 | if (dev != loopback_dev) { |
1192 | if (dev) { | 1189 | if (dev) { |
1193 | dev_put(dev); | 1190 | dev_put(dev); |
1194 | in6_dev_put(idev); | 1191 | in6_dev_put(idev); |
1195 | } | 1192 | } |
1196 | dev = &loopback_dev; | 1193 | dev = loopback_dev; |
1197 | dev_hold(dev); | 1194 | dev_hold(dev); |
1198 | idev = in6_dev_get(dev); | 1195 | idev = in6_dev_get(dev); |
1199 | if (!idev) { | 1196 | if (!idev) { |
@@ -1897,13 +1894,13 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, | |||
1897 | if (rt == NULL) | 1894 | if (rt == NULL) |
1898 | return ERR_PTR(-ENOMEM); | 1895 | return ERR_PTR(-ENOMEM); |
1899 | 1896 | ||
1900 | dev_hold(&loopback_dev); | 1897 | dev_hold(loopback_dev); |
1901 | in6_dev_hold(idev); | 1898 | in6_dev_hold(idev); |
1902 | 1899 | ||
1903 | rt->u.dst.flags = DST_HOST; | 1900 | rt->u.dst.flags = DST_HOST; |
1904 | rt->u.dst.input = ip6_input; | 1901 | rt->u.dst.input = ip6_input; |
1905 | rt->u.dst.output = ip6_output; | 1902 | rt->u.dst.output = ip6_output; |
1906 | rt->rt6i_dev = &loopback_dev; | 1903 | rt->rt6i_dev = loopback_dev; |
1907 | rt->rt6i_idev = idev; | 1904 | rt->rt6i_idev = idev; |
1908 | rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev); | 1905 | rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev); |
1909 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_mtu(&rt->u.dst)); | 1906 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_mtu(&rt->u.dst)); |
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 3ec0c4770ee3..cc07216cfd59 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
@@ -375,7 +375,7 @@ static void xfrm6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, | |||
375 | 375 | ||
376 | xdst = (struct xfrm_dst *)dst; | 376 | xdst = (struct xfrm_dst *)dst; |
377 | if (xdst->u.rt6.rt6i_idev->dev == dev) { | 377 | if (xdst->u.rt6.rt6i_idev->dev == dev) { |
378 | struct inet6_dev *loopback_idev = in6_dev_get(&loopback_dev); | 378 | struct inet6_dev *loopback_idev = in6_dev_get(loopback_dev); |
379 | BUG_ON(!loopback_idev); | 379 | BUG_ON(!loopback_idev); |
380 | 380 | ||
381 | do { | 381 | do { |
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 50682d3cd7a9..d6dfd7d1948f 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -1949,8 +1949,8 @@ static int stale_bundle(struct dst_entry *dst) | |||
1949 | void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev) | 1949 | void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev) |
1950 | { | 1950 | { |
1951 | while ((dst = dst->child) && dst->xfrm && dst->dev == dev) { | 1951 | while ((dst = dst->child) && dst->xfrm && dst->dev == dev) { |
1952 | dst->dev = &loopback_dev; | 1952 | dst->dev = loopback_dev; |
1953 | dev_hold(&loopback_dev); | 1953 | dev_hold(dst->dev); |
1954 | dev_put(dev); | 1954 | dev_put(dev); |
1955 | } | 1955 | } |
1956 | } | 1956 | } |