diff options
author | Daniel Lezcano <dlezcano@fr.ibm.com> | 2008-03-04 16:48:10 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-03-04 16:48:10 -0500 |
commit | bdb3289f739e94bcae8b51972ae844ec66c2f4df (patch) | |
tree | 2ffffce475a82a69bbe8092be3d3f260fe83b003 /net/ipv6/route.c | |
parent | 5578689a4e3c04f2d43ea39736fd3fa396d80c6e (diff) |
[NETNS][IPV6] rt6_info - make rt6_info accessed as a pointer
This patch make mindless changes and prepares the code to use dynamic
allocation for rt6_info structure. The code accesses the rt6_info
structure as a pointer instead of a global static variable.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r-- | net/ipv6/route.c | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index b3ac4901af86..8f954c1e961f 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -127,7 +127,7 @@ static struct dst_ops ip6_dst_blackhole_ops = { | |||
127 | .entries = ATOMIC_INIT(0), | 127 | .entries = ATOMIC_INIT(0), |
128 | }; | 128 | }; |
129 | 129 | ||
130 | struct rt6_info ip6_null_entry = { | 130 | static struct rt6_info ip6_null_entry_template = { |
131 | .u = { | 131 | .u = { |
132 | .dst = { | 132 | .dst = { |
133 | .__refcnt = ATOMIC_INIT(1), | 133 | .__refcnt = ATOMIC_INIT(1), |
@@ -138,7 +138,6 @@ struct rt6_info ip6_null_entry = { | |||
138 | .input = ip6_pkt_discard, | 138 | .input = ip6_pkt_discard, |
139 | .output = ip6_pkt_discard_out, | 139 | .output = ip6_pkt_discard_out, |
140 | .ops = &ip6_dst_ops, | 140 | .ops = &ip6_dst_ops, |
141 | .path = (struct dst_entry*)&ip6_null_entry, | ||
142 | } | 141 | } |
143 | }, | 142 | }, |
144 | .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), | 143 | .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), |
@@ -146,12 +145,14 @@ struct rt6_info ip6_null_entry = { | |||
146 | .rt6i_ref = ATOMIC_INIT(1), | 145 | .rt6i_ref = ATOMIC_INIT(1), |
147 | }; | 146 | }; |
148 | 147 | ||
148 | struct rt6_info *ip6_null_entry; | ||
149 | |||
149 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 150 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
150 | 151 | ||
151 | static int ip6_pkt_prohibit(struct sk_buff *skb); | 152 | static int ip6_pkt_prohibit(struct sk_buff *skb); |
152 | static int ip6_pkt_prohibit_out(struct sk_buff *skb); | 153 | static int ip6_pkt_prohibit_out(struct sk_buff *skb); |
153 | 154 | ||
154 | struct rt6_info ip6_prohibit_entry = { | 155 | struct rt6_info ip6_prohibit_entry_template = { |
155 | .u = { | 156 | .u = { |
156 | .dst = { | 157 | .dst = { |
157 | .__refcnt = ATOMIC_INIT(1), | 158 | .__refcnt = ATOMIC_INIT(1), |
@@ -162,7 +163,6 @@ struct rt6_info ip6_prohibit_entry = { | |||
162 | .input = ip6_pkt_prohibit, | 163 | .input = ip6_pkt_prohibit, |
163 | .output = ip6_pkt_prohibit_out, | 164 | .output = ip6_pkt_prohibit_out, |
164 | .ops = &ip6_dst_ops, | 165 | .ops = &ip6_dst_ops, |
165 | .path = (struct dst_entry*)&ip6_prohibit_entry, | ||
166 | } | 166 | } |
167 | }, | 167 | }, |
168 | .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), | 168 | .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), |
@@ -170,7 +170,9 @@ struct rt6_info ip6_prohibit_entry = { | |||
170 | .rt6i_ref = ATOMIC_INIT(1), | 170 | .rt6i_ref = ATOMIC_INIT(1), |
171 | }; | 171 | }; |
172 | 172 | ||
173 | struct rt6_info ip6_blk_hole_entry = { | 173 | struct rt6_info *ip6_prohibit_entry; |
174 | |||
175 | static struct rt6_info ip6_blk_hole_entry_template = { | ||
174 | .u = { | 176 | .u = { |
175 | .dst = { | 177 | .dst = { |
176 | .__refcnt = ATOMIC_INIT(1), | 178 | .__refcnt = ATOMIC_INIT(1), |
@@ -181,7 +183,6 @@ struct rt6_info ip6_blk_hole_entry = { | |||
181 | .input = dst_discard, | 183 | .input = dst_discard, |
182 | .output = dst_discard, | 184 | .output = dst_discard, |
183 | .ops = &ip6_dst_ops, | 185 | .ops = &ip6_dst_ops, |
184 | .path = (struct dst_entry*)&ip6_blk_hole_entry, | ||
185 | } | 186 | } |
186 | }, | 187 | }, |
187 | .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), | 188 | .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), |
@@ -189,6 +190,8 @@ struct rt6_info ip6_blk_hole_entry = { | |||
189 | .rt6i_ref = ATOMIC_INIT(1), | 190 | .rt6i_ref = ATOMIC_INIT(1), |
190 | }; | 191 | }; |
191 | 192 | ||
193 | struct rt6_info *ip6_blk_hole_entry; | ||
194 | |||
192 | #endif | 195 | #endif |
193 | 196 | ||
194 | /* allocate dst with ip6_dst_ops */ | 197 | /* allocate dst with ip6_dst_ops */ |
@@ -271,7 +274,7 @@ static __inline__ struct rt6_info *rt6_device_match(struct rt6_info *rt, | |||
271 | return local; | 274 | return local; |
272 | 275 | ||
273 | if (strict) | 276 | if (strict) |
274 | return &ip6_null_entry; | 277 | return ip6_null_entry; |
275 | } | 278 | } |
276 | return rt; | 279 | return rt; |
277 | } | 280 | } |
@@ -437,7 +440,7 @@ static struct rt6_info *rt6_select(struct fib6_node *fn, int oif, int strict) | |||
437 | RT6_TRACE("%s() => %p\n", | 440 | RT6_TRACE("%s() => %p\n", |
438 | __FUNCTION__, match); | 441 | __FUNCTION__, match); |
439 | 442 | ||
440 | return (match ? match : &ip6_null_entry); | 443 | return (match ? match : ip6_null_entry); |
441 | } | 444 | } |
442 | 445 | ||
443 | #ifdef CONFIG_IPV6_ROUTE_INFO | 446 | #ifdef CONFIG_IPV6_ROUTE_INFO |
@@ -522,7 +525,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, | |||
522 | 525 | ||
523 | #define BACKTRACK(saddr) \ | 526 | #define BACKTRACK(saddr) \ |
524 | do { \ | 527 | do { \ |
525 | if (rt == &ip6_null_entry) { \ | 528 | if (rt == ip6_null_entry) { \ |
526 | struct fib6_node *pn; \ | 529 | struct fib6_node *pn; \ |
527 | while (1) { \ | 530 | while (1) { \ |
528 | if (fn->fn_flags & RTN_TL_ROOT) \ | 531 | if (fn->fn_flags & RTN_TL_ROOT) \ |
@@ -686,7 +689,7 @@ restart_2: | |||
686 | restart: | 689 | restart: |
687 | rt = rt6_select(fn, oif, strict | reachable); | 690 | rt = rt6_select(fn, oif, strict | reachable); |
688 | BACKTRACK(&fl->fl6_src); | 691 | BACKTRACK(&fl->fl6_src); |
689 | if (rt == &ip6_null_entry || | 692 | if (rt == ip6_null_entry || |
690 | rt->rt6i_flags & RTF_CACHE) | 693 | rt->rt6i_flags & RTF_CACHE) |
691 | goto out; | 694 | goto out; |
692 | 695 | ||
@@ -704,7 +707,7 @@ restart: | |||
704 | } | 707 | } |
705 | 708 | ||
706 | dst_release(&rt->u.dst); | 709 | dst_release(&rt->u.dst); |
707 | rt = nrt ? : &ip6_null_entry; | 710 | rt = nrt ? : ip6_null_entry; |
708 | 711 | ||
709 | dst_hold(&rt->u.dst); | 712 | dst_hold(&rt->u.dst); |
710 | if (nrt) { | 713 | if (nrt) { |
@@ -1257,7 +1260,7 @@ static int __ip6_del_rt(struct rt6_info *rt, struct nl_info *info) | |||
1257 | int err; | 1260 | int err; |
1258 | struct fib6_table *table; | 1261 | struct fib6_table *table; |
1259 | 1262 | ||
1260 | if (rt == &ip6_null_entry) | 1263 | if (rt == ip6_null_entry) |
1261 | return -ENOENT; | 1264 | return -ENOENT; |
1262 | 1265 | ||
1263 | table = rt->rt6i_table; | 1266 | table = rt->rt6i_table; |
@@ -1369,7 +1372,7 @@ restart: | |||
1369 | } | 1372 | } |
1370 | 1373 | ||
1371 | if (!rt) | 1374 | if (!rt) |
1372 | rt = &ip6_null_entry; | 1375 | rt = ip6_null_entry; |
1373 | BACKTRACK(&fl->fl6_src); | 1376 | BACKTRACK(&fl->fl6_src); |
1374 | out: | 1377 | out: |
1375 | dst_hold(&rt->u.dst); | 1378 | dst_hold(&rt->u.dst); |
@@ -1415,7 +1418,7 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *src, | |||
1415 | 1418 | ||
1416 | rt = ip6_route_redirect(dest, src, saddr, neigh->dev); | 1419 | rt = ip6_route_redirect(dest, src, saddr, neigh->dev); |
1417 | 1420 | ||
1418 | if (rt == &ip6_null_entry) { | 1421 | if (rt == ip6_null_entry) { |
1419 | if (net_ratelimit()) | 1422 | if (net_ratelimit()) |
1420 | printk(KERN_DEBUG "rt6_redirect: source isn't a valid nexthop " | 1423 | printk(KERN_DEBUG "rt6_redirect: source isn't a valid nexthop " |
1421 | "for redirect target\n"); | 1424 | "for redirect target\n"); |
@@ -1886,7 +1889,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, | |||
1886 | static int fib6_ifdown(struct rt6_info *rt, void *arg) | 1889 | static int fib6_ifdown(struct rt6_info *rt, void *arg) |
1887 | { | 1890 | { |
1888 | if (((void*)rt->rt6i_dev == arg || arg == NULL) && | 1891 | if (((void*)rt->rt6i_dev == arg || arg == NULL) && |
1889 | rt != &ip6_null_entry) { | 1892 | rt != ip6_null_entry) { |
1890 | RT6_TRACE("deleted by ifdown %p\n", rt); | 1893 | RT6_TRACE("deleted by ifdown %p\n", rt); |
1891 | return -1; | 1894 | return -1; |
1892 | } | 1895 | } |
@@ -2565,9 +2568,30 @@ int __init ip6_route_init(void) | |||
2565 | 2568 | ||
2566 | ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops.kmem_cachep; | 2569 | ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops.kmem_cachep; |
2567 | 2570 | ||
2571 | ret = -ENOMEM; | ||
2572 | ip6_null_entry = kmemdup(&ip6_null_entry_template, | ||
2573 | sizeof(*ip6_null_entry), GFP_KERNEL); | ||
2574 | if (!ip6_null_entry) | ||
2575 | goto out_kmem_cache; | ||
2576 | ip6_null_entry->u.dst.path = (struct dst_entry *)ip6_null_entry; | ||
2577 | |||
2578 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | ||
2579 | ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template, | ||
2580 | sizeof(*ip6_prohibit_entry), GFP_KERNEL); | ||
2581 | if (!ip6_prohibit_entry) | ||
2582 | goto out_ip6_null_entry; | ||
2583 | ip6_prohibit_entry->u.dst.path = (struct dst_entry *)ip6_prohibit_entry; | ||
2584 | |||
2585 | ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template, | ||
2586 | sizeof(*ip6_blk_hole_entry), GFP_KERNEL); | ||
2587 | if (!ip6_blk_hole_entry) | ||
2588 | goto out_ip6_prohibit_entry; | ||
2589 | ip6_blk_hole_entry->u.dst.path = (struct dst_entry *)ip6_blk_hole_entry; | ||
2590 | #endif | ||
2591 | |||
2568 | ret = fib6_init(); | 2592 | ret = fib6_init(); |
2569 | if (ret) | 2593 | if (ret) |
2570 | goto out_kmem_cache; | 2594 | goto out_ip6_blk_hole_entry; |
2571 | 2595 | ||
2572 | ret = xfrm6_init(); | 2596 | ret = xfrm6_init(); |
2573 | if (ret) | 2597 | if (ret) |
@@ -2595,6 +2619,14 @@ xfrm6_init: | |||
2595 | xfrm6_fini(); | 2619 | xfrm6_fini(); |
2596 | out_fib6_init: | 2620 | out_fib6_init: |
2597 | fib6_gc_cleanup(); | 2621 | fib6_gc_cleanup(); |
2622 | out_ip6_blk_hole_entry: | ||
2623 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | ||
2624 | kfree(ip6_blk_hole_entry); | ||
2625 | out_ip6_prohibit_entry: | ||
2626 | kfree(ip6_prohibit_entry); | ||
2627 | out_ip6_null_entry: | ||
2628 | #endif | ||
2629 | kfree(ip6_null_entry); | ||
2598 | out_kmem_cache: | 2630 | out_kmem_cache: |
2599 | kmem_cache_destroy(ip6_dst_ops.kmem_cachep); | 2631 | kmem_cache_destroy(ip6_dst_ops.kmem_cachep); |
2600 | goto out; | 2632 | goto out; |
@@ -2607,4 +2639,10 @@ void ip6_route_cleanup(void) | |||
2607 | xfrm6_fini(); | 2639 | xfrm6_fini(); |
2608 | fib6_gc_cleanup(); | 2640 | fib6_gc_cleanup(); |
2609 | kmem_cache_destroy(ip6_dst_ops.kmem_cachep); | 2641 | kmem_cache_destroy(ip6_dst_ops.kmem_cachep); |
2642 | |||
2643 | kfree(ip6_null_entry); | ||
2644 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | ||
2645 | kfree(ip6_prohibit_entry); | ||
2646 | kfree(ip6_blk_hole_entry); | ||
2647 | #endif | ||
2610 | } | 2648 | } |