Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Daniel Lezcano and committed by
David S. Miller
bdb3289f 5578689a

+78 -40
+3 -3
include/net/ip6_route.h
··· 34 34 #define RT6_LOOKUP_F_REACHABLE 0x2 35 35 #define RT6_LOOKUP_F_HAS_SADDR 0x4 36 36 37 - extern struct rt6_info ip6_null_entry; 37 + extern struct rt6_info *ip6_null_entry; 38 38 39 39 #ifdef CONFIG_IPV6_MULTIPLE_TABLES 40 - extern struct rt6_info ip6_prohibit_entry; 41 - extern struct rt6_info ip6_blk_hole_entry; 40 + extern struct rt6_info *ip6_prohibit_entry; 41 + extern struct rt6_info *ip6_blk_hole_entry; 42 42 #endif 43 43 44 44 extern void ip6_route_input(struct sk_buff *skb);
+6 -6
net/ipv6/addrconf.c
··· 4301 4301 if (err) 4302 4302 goto errlo; 4303 4303 4304 - ip6_null_entry.u.dst.dev = init_net.loopback_dev; 4305 - ip6_null_entry.rt6i_idev = in6_dev_get(init_net.loopback_dev); 4304 + ip6_null_entry->u.dst.dev = init_net.loopback_dev; 4305 + ip6_null_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); 4306 4306 #ifdef CONFIG_IPV6_MULTIPLE_TABLES 4307 - ip6_prohibit_entry.u.dst.dev = init_net.loopback_dev; 4308 - ip6_prohibit_entry.rt6i_idev = in6_dev_get(init_net.loopback_dev); 4309 - ip6_blk_hole_entry.u.dst.dev = init_net.loopback_dev; 4310 - ip6_blk_hole_entry.rt6i_idev = in6_dev_get(init_net.loopback_dev); 4307 + ip6_prohibit_entry->u.dst.dev = init_net.loopback_dev; 4308 + ip6_prohibit_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); 4309 + ip6_blk_hole_entry->u.dst.dev = init_net.loopback_dev; 4310 + ip6_blk_hole_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); 4311 4311 #endif 4312 4312 4313 4313 register_netdevice_notifier(&ipv6_dev_notf);
+6 -6
net/ipv6/fib6_rules.c
··· 43 43 if (arg.result) 44 44 return arg.result; 45 45 46 - dst_hold(&ip6_null_entry.u.dst); 47 - return &ip6_null_entry.u.dst; 46 + dst_hold(&ip6_null_entry->u.dst); 47 + return &ip6_null_entry->u.dst; 48 48 } 49 49 50 50 static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp, ··· 58 58 case FR_ACT_TO_TBL: 59 59 break; 60 60 case FR_ACT_UNREACHABLE: 61 - rt = &ip6_null_entry; 61 + rt = ip6_null_entry; 62 62 goto discard_pkt; 63 63 default: 64 64 case FR_ACT_BLACKHOLE: 65 - rt = &ip6_blk_hole_entry; 65 + rt = ip6_blk_hole_entry; 66 66 goto discard_pkt; 67 67 case FR_ACT_PROHIBIT: 68 - rt = &ip6_prohibit_entry; 68 + rt = ip6_prohibit_entry; 69 69 goto discard_pkt; 70 70 } 71 71 ··· 73 73 if (table) 74 74 rt = lookup(table, flp, flags); 75 75 76 - if (rt != &ip6_null_entry) { 76 + if (rt != ip6_null_entry) { 77 77 struct fib6_rule *r = (struct fib6_rule *)rule; 78 78 79 79 /*
+9 -9
net/ipv6/ip6_fib.c
··· 200 200 table = kzalloc(sizeof(*table), GFP_ATOMIC); 201 201 if (table != NULL) { 202 202 table->tb6_id = id; 203 - table->tb6_root.leaf = &ip6_null_entry; 203 + table->tb6_root.leaf = ip6_null_entry; 204 204 table->tb6_root.fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO; 205 205 } 206 206 ··· 717 717 if (sfn == NULL) 718 718 goto st_failure; 719 719 720 - sfn->leaf = &ip6_null_entry; 721 - atomic_inc(&ip6_null_entry.rt6i_ref); 720 + sfn->leaf = ip6_null_entry; 721 + atomic_inc(&ip6_null_entry->rt6i_ref); 722 722 sfn->fn_flags = RTN_ROOT; 723 723 sfn->fn_sernum = fib6_new_sernum(); 724 724 ··· 777 777 #if RT6_DEBUG >= 2 778 778 if (!pn->leaf) { 779 779 BUG_TRAP(pn->leaf != NULL); 780 - pn->leaf = &ip6_null_entry; 780 + pn->leaf = ip6_null_entry; 781 781 } 782 782 #endif 783 783 atomic_inc(&pn->leaf->rt6i_ref); ··· 962 962 static struct rt6_info * fib6_find_prefix(struct fib6_node *fn) 963 963 { 964 964 if (fn->fn_flags&RTN_ROOT) 965 - return &ip6_null_entry; 965 + return ip6_null_entry; 966 966 967 967 while(fn) { 968 968 if(fn->left) ··· 1012 1012 #if RT6_DEBUG >= 2 1013 1013 if (fn->leaf==NULL) { 1014 1014 BUG_TRAP(fn->leaf); 1015 - fn->leaf = &ip6_null_entry; 1015 + fn->leaf = ip6_null_entry; 1016 1016 } 1017 1017 #endif 1018 1018 atomic_inc(&fn->leaf->rt6i_ref); ··· 1154 1154 return -ENOENT; 1155 1155 } 1156 1156 #endif 1157 - if (fn == NULL || rt == &ip6_null_entry) 1157 + if (fn == NULL || rt == ip6_null_entry) 1158 1158 return -ENOENT; 1159 1159 1160 1160 BUG_TRAP(fn->fn_flags&RTN_RTINFO); ··· 1501 1501 goto out_fib_table_hash; 1502 1502 1503 1503 net->ipv6.fib6_main_tbl->tb6_id = RT6_TABLE_MAIN; 1504 - net->ipv6.fib6_main_tbl->tb6_root.leaf = &ip6_null_entry; 1504 + net->ipv6.fib6_main_tbl->tb6_root.leaf = ip6_null_entry; 1505 1505 net->ipv6.fib6_main_tbl->tb6_root.fn_flags = 1506 1506 RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO; 1507 1507 ··· 1511 1511 if (!net->ipv6.fib6_local_tbl) 1512 1512 goto out_fib6_main_tbl; 1513 1513 net->ipv6.fib6_local_tbl->tb6_id = RT6_TABLE_LOCAL; 1514 - net->ipv6.fib6_local_tbl->tb6_root.leaf = &ip6_null_entry; 1514 + net->ipv6.fib6_local_tbl->tb6_root.leaf = ip6_null_entry; 1515 1515 net->ipv6.fib6_local_tbl->tb6_root.fn_flags = 1516 1516 RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO; 1517 1517 #endif
+54 -16
net/ipv6/route.c
··· 127 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 131 .u = { 132 132 .dst = { 133 133 .__refcnt = ATOMIC_INIT(1), ··· 138 138 .input = ip6_pkt_discard, 139 139 .output = ip6_pkt_discard_out, 140 140 .ops = &ip6_dst_ops, 141 - .path = (struct dst_entry*)&ip6_null_entry, 142 141 } 143 142 }, 144 143 .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), ··· 145 146 .rt6i_ref = ATOMIC_INIT(1), 146 147 }; 147 148 149 + struct rt6_info *ip6_null_entry; 150 + 148 151 #ifdef CONFIG_IPV6_MULTIPLE_TABLES 149 152 150 153 static int ip6_pkt_prohibit(struct sk_buff *skb); 151 154 static int ip6_pkt_prohibit_out(struct sk_buff *skb); 152 155 153 - struct rt6_info ip6_prohibit_entry = { 156 + struct rt6_info ip6_prohibit_entry_template = { 154 157 .u = { 155 158 .dst = { 156 159 .__refcnt = ATOMIC_INIT(1), ··· 163 162 .input = ip6_pkt_prohibit, 164 163 .output = ip6_pkt_prohibit_out, 165 164 .ops = &ip6_dst_ops, 166 - .path = (struct dst_entry*)&ip6_prohibit_entry, 167 165 } 168 166 }, 169 167 .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), ··· 170 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 176 .u = { 175 177 .dst = { 176 178 .__refcnt = ATOMIC_INIT(1), ··· 183 181 .input = dst_discard, 184 182 .output = dst_discard, 185 183 .ops = &ip6_dst_ops, 186 - .path = (struct dst_entry*)&ip6_blk_hole_entry, 187 184 } 188 185 }, 189 186 .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), 190 187 .rt6i_metric = ~(u32) 0, 191 188 .rt6i_ref = ATOMIC_INIT(1), 192 189 }; 190 + 191 + struct rt6_info *ip6_blk_hole_entry; 193 192 194 193 #endif 195 194 ··· 274 271 return local; 275 272 276 273 if (strict) 277 - return &ip6_null_entry; 274 + return ip6_null_entry; 278 275 } 279 276 return rt; 280 277 } ··· 440 437 RT6_TRACE("%s() => %p\n", 441 438 __FUNCTION__, match); 442 439 443 - return (match ? match : &ip6_null_entry); 440 + return (match ? match : ip6_null_entry); 444 441 } 445 442 446 443 #ifdef CONFIG_IPV6_ROUTE_INFO ··· 525 522 526 523 #define BACKTRACK(saddr) \ 527 524 do { \ 528 - if (rt == &ip6_null_entry) { \ 525 + if (rt == ip6_null_entry) { \ 529 526 struct fib6_node *pn; \ 530 527 while (1) { \ 531 528 if (fn->fn_flags & RTN_TL_ROOT) \ ··· 689 686 restart: 690 687 rt = rt6_select(fn, oif, strict | reachable); 691 688 BACKTRACK(&fl->fl6_src); 692 - if (rt == &ip6_null_entry || 689 + if (rt == ip6_null_entry || 693 690 rt->rt6i_flags & RTF_CACHE) 694 691 goto out; 695 692 ··· 707 704 } 708 705 709 706 dst_release(&rt->u.dst); 710 - rt = nrt ? : &ip6_null_entry; 707 + rt = nrt ? : ip6_null_entry; 711 708 712 709 dst_hold(&rt->u.dst); 713 710 if (nrt) { ··· 1260 1257 int err; 1261 1258 struct fib6_table *table; 1262 1259 1263 - if (rt == &ip6_null_entry) 1260 + if (rt == ip6_null_entry) 1264 1261 return -ENOENT; 1265 1262 1266 1263 table = rt->rt6i_table; ··· 1372 1369 } 1373 1370 1374 1371 if (!rt) 1375 - rt = &ip6_null_entry; 1372 + rt = ip6_null_entry; 1376 1373 BACKTRACK(&fl->fl6_src); 1377 1374 out: 1378 1375 dst_hold(&rt->u.dst); ··· 1418 1415 1419 1416 rt = ip6_route_redirect(dest, src, saddr, neigh->dev); 1420 1417 1421 - if (rt == &ip6_null_entry) { 1418 + if (rt == ip6_null_entry) { 1422 1419 if (net_ratelimit()) 1423 1420 printk(KERN_DEBUG "rt6_redirect: source isn't a valid nexthop " 1424 1421 "for redirect target\n"); ··· 1889 1886 static int fib6_ifdown(struct rt6_info *rt, void *arg) 1890 1887 { 1891 1888 if (((void*)rt->rt6i_dev == arg || arg == NULL) && 1892 - rt != &ip6_null_entry) { 1889 + rt != ip6_null_entry) { 1893 1890 RT6_TRACE("deleted by ifdown %p\n", rt); 1894 1891 return -1; 1895 1892 } ··· 2568 2565 2569 2566 ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops.kmem_cachep; 2570 2567 2568 + ret = -ENOMEM; 2569 + ip6_null_entry = kmemdup(&ip6_null_entry_template, 2570 + sizeof(*ip6_null_entry), GFP_KERNEL); 2571 + if (!ip6_null_entry) 2572 + goto out_kmem_cache; 2573 + ip6_null_entry->u.dst.path = (struct dst_entry *)ip6_null_entry; 2574 + 2575 + #ifdef CONFIG_IPV6_MULTIPLE_TABLES 2576 + ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template, 2577 + sizeof(*ip6_prohibit_entry), GFP_KERNEL); 2578 + if (!ip6_prohibit_entry) 2579 + goto out_ip6_null_entry; 2580 + ip6_prohibit_entry->u.dst.path = (struct dst_entry *)ip6_prohibit_entry; 2581 + 2582 + ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template, 2583 + sizeof(*ip6_blk_hole_entry), GFP_KERNEL); 2584 + if (!ip6_blk_hole_entry) 2585 + goto out_ip6_prohibit_entry; 2586 + ip6_blk_hole_entry->u.dst.path = (struct dst_entry *)ip6_blk_hole_entry; 2587 + #endif 2588 + 2571 2589 ret = fib6_init(); 2572 2590 if (ret) 2573 - goto out_kmem_cache; 2591 + goto out_ip6_blk_hole_entry; 2574 2592 2575 2593 ret = xfrm6_init(); 2576 2594 if (ret) ··· 2619 2595 xfrm6_fini(); 2620 2596 out_fib6_init: 2621 2597 fib6_gc_cleanup(); 2598 + out_ip6_blk_hole_entry: 2599 + #ifdef CONFIG_IPV6_MULTIPLE_TABLES 2600 + kfree(ip6_blk_hole_entry); 2601 + out_ip6_prohibit_entry: 2602 + kfree(ip6_prohibit_entry); 2603 + out_ip6_null_entry: 2604 + #endif 2605 + kfree(ip6_null_entry); 2622 2606 out_kmem_cache: 2623 2607 kmem_cache_destroy(ip6_dst_ops.kmem_cachep); 2624 2608 goto out; ··· 2639 2607 xfrm6_fini(); 2640 2608 fib6_gc_cleanup(); 2641 2609 kmem_cache_destroy(ip6_dst_ops.kmem_cachep); 2610 + 2611 + kfree(ip6_null_entry); 2612 + #ifdef CONFIG_IPV6_MULTIPLE_TABLES 2613 + kfree(ip6_prohibit_entry); 2614 + kfree(ip6_blk_hole_entry); 2615 + #endif 2642 2616 }