table = kzalloc(sizeof(*table), GFP_ATOMIC);
if (table != NULL) {
table->tb6_id = id;
- table->tb6_root.leaf = &ip6_null_entry;
+ table->tb6_root.leaf = ip6_null_entry;
table->tb6_root.fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO;
}
if (sfn == NULL)
goto st_failure;
- sfn->leaf = &ip6_null_entry;
- atomic_inc(&ip6_null_entry.rt6i_ref);
+ sfn->leaf = ip6_null_entry;
+ atomic_inc(&ip6_null_entry->rt6i_ref);
sfn->fn_flags = RTN_ROOT;
sfn->fn_sernum = fib6_new_sernum();
#if RT6_DEBUG >= 2
if (!pn->leaf) {
BUG_TRAP(pn->leaf != NULL);
- pn->leaf = &ip6_null_entry;
+ pn->leaf = ip6_null_entry;
}
#endif
atomic_inc(&pn->leaf->rt6i_ref);
static struct rt6_info * fib6_find_prefix(struct fib6_node *fn)
{
if (fn->fn_flags&RTN_ROOT)
- return &ip6_null_entry;
+ return ip6_null_entry;
while(fn) {
if(fn->left)
#if RT6_DEBUG >= 2
if (fn->leaf==NULL) {
BUG_TRAP(fn->leaf);
- fn->leaf = &ip6_null_entry;
+ fn->leaf = ip6_null_entry;
}
#endif
atomic_inc(&fn->leaf->rt6i_ref);
return -ENOENT;
}
#endif
- if (fn == NULL || rt == &ip6_null_entry)
+ if (fn == NULL || rt == ip6_null_entry)
return -ENOENT;
BUG_TRAP(fn->fn_flags&RTN_RTINFO);
goto out_fib_table_hash;
net->ipv6.fib6_main_tbl->tb6_id = RT6_TABLE_MAIN;
- net->ipv6.fib6_main_tbl->tb6_root.leaf = &ip6_null_entry;
+ net->ipv6.fib6_main_tbl->tb6_root.leaf = ip6_null_entry;
net->ipv6.fib6_main_tbl->tb6_root.fn_flags =
RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO;
if (!net->ipv6.fib6_local_tbl)
goto out_fib6_main_tbl;
net->ipv6.fib6_local_tbl->tb6_id = RT6_TABLE_LOCAL;
- net->ipv6.fib6_local_tbl->tb6_root.leaf = &ip6_null_entry;
+ net->ipv6.fib6_local_tbl->tb6_root.leaf = ip6_null_entry;
net->ipv6.fib6_local_tbl->tb6_root.fn_flags =
RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO;
#endif
.entries = ATOMIC_INIT(0),
};
-struct rt6_info ip6_null_entry = {
+static struct rt6_info ip6_null_entry_template = {
.u = {
.dst = {
.__refcnt = ATOMIC_INIT(1),
.input = ip6_pkt_discard,
.output = ip6_pkt_discard_out,
.ops = &ip6_dst_ops,
- .path = (struct dst_entry*)&ip6_null_entry,
}
},
.rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP),
.rt6i_ref = ATOMIC_INIT(1),
};
+struct rt6_info *ip6_null_entry;
+
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
static int ip6_pkt_prohibit(struct sk_buff *skb);
static int ip6_pkt_prohibit_out(struct sk_buff *skb);
-struct rt6_info ip6_prohibit_entry = {
+struct rt6_info ip6_prohibit_entry_template = {
.u = {
.dst = {
.__refcnt = ATOMIC_INIT(1),
.input = ip6_pkt_prohibit,
.output = ip6_pkt_prohibit_out,
.ops = &ip6_dst_ops,
- .path = (struct dst_entry*)&ip6_prohibit_entry,
}
},
.rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP),
.rt6i_ref = ATOMIC_INIT(1),
};
-struct rt6_info ip6_blk_hole_entry = {
+struct rt6_info *ip6_prohibit_entry;
+
+static struct rt6_info ip6_blk_hole_entry_template = {
.u = {
.dst = {
.__refcnt = ATOMIC_INIT(1),
.input = dst_discard,
.output = dst_discard,
.ops = &ip6_dst_ops,
- .path = (struct dst_entry*)&ip6_blk_hole_entry,
}
},
.rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP),
.rt6i_ref = ATOMIC_INIT(1),
};
+struct rt6_info *ip6_blk_hole_entry;
+
#endif
/* allocate dst with ip6_dst_ops */
return local;
if (strict)
- return &ip6_null_entry;
+ return ip6_null_entry;
}
return rt;
}
RT6_TRACE("%s() => %p\n",
__FUNCTION__, match);
- return (match ? match : &ip6_null_entry);
+ return (match ? match : ip6_null_entry);
}
#ifdef CONFIG_IPV6_ROUTE_INFO
#define BACKTRACK(saddr) \
do { \
- if (rt == &ip6_null_entry) { \
+ if (rt == ip6_null_entry) { \
struct fib6_node *pn; \
while (1) { \
if (fn->fn_flags & RTN_TL_ROOT) \
restart:
rt = rt6_select(fn, oif, strict | reachable);
BACKTRACK(&fl->fl6_src);
- if (rt == &ip6_null_entry ||
+ if (rt == ip6_null_entry ||
rt->rt6i_flags & RTF_CACHE)
goto out;
}
dst_release(&rt->u.dst);
- rt = nrt ? : &ip6_null_entry;
+ rt = nrt ? : ip6_null_entry;
dst_hold(&rt->u.dst);
if (nrt) {
int err;
struct fib6_table *table;
- if (rt == &ip6_null_entry)
+ if (rt == ip6_null_entry)
return -ENOENT;
table = rt->rt6i_table;
}
if (!rt)
- rt = &ip6_null_entry;
+ rt = ip6_null_entry;
BACKTRACK(&fl->fl6_src);
out:
dst_hold(&rt->u.dst);
rt = ip6_route_redirect(dest, src, saddr, neigh->dev);
- if (rt == &ip6_null_entry) {
+ if (rt == ip6_null_entry) {
if (net_ratelimit())
printk(KERN_DEBUG "rt6_redirect: source isn't a valid nexthop "
"for redirect target\n");
static int fib6_ifdown(struct rt6_info *rt, void *arg)
{
if (((void*)rt->rt6i_dev == arg || arg == NULL) &&
- rt != &ip6_null_entry) {
+ rt != ip6_null_entry) {
RT6_TRACE("deleted by ifdown %p\n", rt);
return -1;
}
ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops.kmem_cachep;
+ ret = -ENOMEM;
+ ip6_null_entry = kmemdup(&ip6_null_entry_template,
+ sizeof(*ip6_null_entry), GFP_KERNEL);
+ if (!ip6_null_entry)
+ goto out_kmem_cache;
+ ip6_null_entry->u.dst.path = (struct dst_entry *)ip6_null_entry;
+
+#ifdef CONFIG_IPV6_MULTIPLE_TABLES
+ ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template,
+ sizeof(*ip6_prohibit_entry), GFP_KERNEL);
+ if (!ip6_prohibit_entry)
+ goto out_ip6_null_entry;
+ ip6_prohibit_entry->u.dst.path = (struct dst_entry *)ip6_prohibit_entry;
+
+ ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template,
+ sizeof(*ip6_blk_hole_entry), GFP_KERNEL);
+ if (!ip6_blk_hole_entry)
+ goto out_ip6_prohibit_entry;
+ ip6_blk_hole_entry->u.dst.path = (struct dst_entry *)ip6_blk_hole_entry;
+#endif
+
ret = fib6_init();
if (ret)
- goto out_kmem_cache;
+ goto out_ip6_blk_hole_entry;
ret = xfrm6_init();
if (ret)
xfrm6_fini();
out_fib6_init:
fib6_gc_cleanup();
+out_ip6_blk_hole_entry:
+#ifdef CONFIG_IPV6_MULTIPLE_TABLES
+ kfree(ip6_blk_hole_entry);
+out_ip6_prohibit_entry:
+ kfree(ip6_prohibit_entry);
+out_ip6_null_entry:
+#endif
+ kfree(ip6_null_entry);
out_kmem_cache:
kmem_cache_destroy(ip6_dst_ops.kmem_cachep);
goto out;
xfrm6_fini();
fib6_gc_cleanup();
kmem_cache_destroy(ip6_dst_ops.kmem_cachep);
+
+ kfree(ip6_null_entry);
+#ifdef CONFIG_IPV6_MULTIPLE_TABLES
+ kfree(ip6_prohibit_entry);
+ kfree(ip6_blk_hole_entry);
+#endif
}