The rt6_info structures are moved inside the network namespace
structure. All references to these structures are now relative
to the initial network namespace.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
---
include/net/net_namespace.h | 3 +
net/ipv6/addrconf.c | 12 ++--
net/ipv6/fib6_rules.c | 13 ++--
net/ipv6/ip6_fib.c | 47 ++++++++-------
net/ipv6/route.c | 132 +++++++++++++++++++++++++-------------------
5 files changed, 117 insertions(+), 90 deletions(-)
Index: linux-2.6-netns/include/net/net_namespace.h
===================================================================
--- linux-2.6-netns.orig/include/net/net_namespace.h
+++ linux-2.6-netns/include/net/net_namespace.h
@@ -47,9 +47,12 @@ struct net {
/* ipv6 routing table */
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
struct rt6_statistics *rt6_stats;
+ struct rt6_info *ip6_null_entry;
struct hlist_head *fib_table_hash;
struct fib6_table *fib6_main_tbl;
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
+ struct rt6_info *ip6_prohibit_entry;
+ struct rt6_info *ip6_blk_hole_entry;
struct fib6_table *fib6_local_tbl;
#endif /* CONFIG_IPV6_MULTIPLE_TABLES */
Index: linux-2.6-netns/net/ipv6/addrconf.c
===================================================================
--- linux-2.6-netns.orig/net/ipv6/addrconf.c
+++ linux-2.6-netns/net/ipv6/addrconf.c
@@ -4265,13 +4265,13 @@ int __init addrconf_init(void)
if (err)
return err;
- ip6_null_entry->u.dst.dev = init_net.loopback_dev;
- ip6_null_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);
+ init_net.ip6_null_entry->u.dst.dev = init_net.loopback_dev;
+ init_net.ip6_null_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
- ip6_prohibit_entry->u.dst.dev = init_net.loopback_dev;
- ip6_prohibit_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);
- ip6_blk_hole_entry->u.dst.dev = init_net.loopback_dev;
- ip6_blk_hole_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);
+ init_net.ip6_prohibit_entry->u.dst.dev = init_net.loopback_dev;
+ init_net.ip6_prohibit_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);
+ init_net.ip6_blk_hole_entry->u.dst.dev = init_net.loopback_dev;
+ init_net.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev);
#endif
register_netdevice_notifier(&ipv6_dev_notf);
Index: linux-2.6-netns/net/ipv6/fib6_rules.c
===================================================================
--- linux-2.6-netns.orig/net/ipv6/fib6_rules.c
+++ linux-2.6-netns/net/ipv6/fib6_rules.c
@@ -34,6 +34,7 @@ static struct fib_rules_ops fib6_rules_o
struct dst_entry *fib6_rule_lookup(struct flowi *fl, int flags,
pol_lookup_t lookup)
{
+ struct net *net = fl->fl_net;
struct fib_lookup_arg arg = {
.lookup_ptr = lookup,
};
@@ -45,8 +46,8 @@ struct dst_entry *fib6_rule_lookup(struc
if (arg.result)
return arg.result;
- dst_hold(&ip6_null_entry->u.dst);
- return &ip6_null_entry->u.dst;
+ dst_hold(&net->ip6_null_entry->u.dst);
+ return &net->ip6_null_entry->u.dst;
}
static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
@@ -61,14 +62,14 @@ static int fib6_rule_action(struct fib_r
case FR_ACT_TO_TBL:
break;
case FR_ACT_UNREACHABLE:
- rt = ip6_null_entry;
+ rt = net->ip6_null_entry;
goto discard_pkt;
default:
case FR_ACT_BLACKHOLE:
- rt = ip6_blk_hole_entry;
+ rt = net->ip6_blk_hole_entry;
goto discard_pkt;
case FR_ACT_PROHIBIT:
- rt = ip6_prohibit_entry;
+ rt = net->ip6_prohibit_entry;
goto discard_pkt;
}
@@ -76,7 +77,7 @@ static int fib6_rule_action(struct fib_r
if (table)
rt = lookup(table, flp, flags);
- if (rt != ip6_null_entry) {
+ if (rt != net->ip6_null_entry) {
struct fib6_rule *r = (struct fib6_rule *)rule;
/*
Index: linux-2.6-netns/net/ipv6/ip6_fib.c
===================================================================
--- linux-2.6-netns.orig/net/ipv6/ip6_fib.c
+++ linux-2.6-netns/net/ipv6/ip6_fib.c
@@ -77,8 +77,8 @@ static DEFINE_RWLOCK(fib6_walker_lock);
#endif
static void fib6_prune_clones(struct fib6_node *fn, struct rt6_info *rt);
-static struct rt6_info * fib6_find_prefix(struct fib6_node *fn);
-static struct fib6_node * fib6_repair_tree(struct fib6_node *fn);
+static struct rt6_info * fib6_find_prefix(struct net *net, struct fib6_node *fn);
+static struct fib6_node * fib6_repair_tree(struct net *net, struct fib6_node *fn);
static int fib6_walk(struct fib6_walker_t *w);
static int fib6_walk_continue(struct fib6_walker_t *w);
@@ -189,14 +189,14 @@ static void fib6_link_table(struct net *
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
-static struct fib6_table *fib6_alloc_table(u32 id)
+static struct fib6_table *fib6_alloc_table(struct net *net, u32 id)
{
struct fib6_table *table;
table = kzalloc(sizeof(*table), GFP_ATOMIC);
if (table != NULL) {
table->tb6_id = id;
- table->tb6_root.leaf = ip6_null_entry;
+ table->tb6_root.leaf = net->ip6_null_entry;
table->tb6_root.fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO;
}
@@ -213,7 +213,7 @@ struct fib6_table *fib6_new_table(struct
if (tb)
return tb;
- tb = fib6_alloc_table(id);
+ tb = fib6_alloc_table(net, id);
if (tb != NULL)
fib6_link_table(net, tb);
@@ -681,6 +681,7 @@ void fib6_force_start_gc(void)
int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info)
{
struct fib6_node *fn, *pn = NULL;
+ struct net *net = info->net;
int err = -ENOMEM;
fn = fib6_add_1(root, &rt->rt6i_dst.addr, sizeof(struct in6_addr),
@@ -713,8 +714,8 @@ int fib6_add(struct fib6_node *root, str
if (sfn == NULL)
goto st_failure;
- sfn->leaf = ip6_null_entry;
- atomic_inc(&ip6_null_entry->rt6i_ref);
+ sfn->leaf = net->ip6_null_entry;
+ atomic_inc(&net->ip6_null_entry->rt6i_ref);
sfn->fn_flags = RTN_ROOT;
sfn->fn_sernum = fib6_new_sernum();
@@ -769,11 +770,11 @@ out:
* super-tree leaf node we have to find a new one for it.
*/
if (pn != fn && !pn->leaf && !(pn->fn_flags & RTN_RTINFO)) {
- pn->leaf = fib6_find_prefix(pn);
+ pn->leaf = fib6_find_prefix(net, pn);
#if RT6_DEBUG >= 2
if (!pn->leaf) {
BUG_TRAP(pn->leaf != NULL);
- pn->leaf = ip6_null_entry;
+ pn->leaf = net->ip6_null_entry;
}
#endif
atomic_inc(&pn->leaf->rt6i_ref);
@@ -789,7 +790,7 @@ out:
*/
st_failure:
if (fn && !(fn->fn_flags & (RTN_RTINFO|RTN_ROOT)))
- fib6_repair_tree(fn);
+ fib6_repair_tree(net, fn);
dst_free(&rt->u.dst);
return err;
#endif
@@ -854,7 +855,6 @@ static struct fib6_node * fib6_lookup_1(
if (fn->fn_flags & RTN_ROOT)
break;
-
fn = fn->parent;
}
@@ -955,10 +955,10 @@ struct fib6_node * fib6_locate(struct fi
*
*/
-static struct rt6_info * fib6_find_prefix(struct fib6_node *fn)
+static struct rt6_info * fib6_find_prefix(struct net *net, struct fib6_node *fn)
{
if (fn->fn_flags&RTN_ROOT)
- return ip6_null_entry;
+ return net->ip6_null_entry;
while(fn) {
if(fn->left)
@@ -977,7 +977,7 @@ static struct rt6_info * fib6_find_prefi
* is the node we want to try and remove.
*/
-static struct fib6_node * fib6_repair_tree(struct fib6_node *fn)
+static struct fib6_node * fib6_repair_tree(struct net *net, struct fib6_node *fn)
{
int children;
int nstate;
@@ -1004,11 +1004,11 @@ static struct fib6_node * fib6_repair_tr
|| (children && fn->fn_flags&RTN_ROOT)
#endif
) {
- fn->leaf = fib6_find_prefix(fn);
+ fn->leaf = fib6_find_prefix(net, fn);
#if RT6_DEBUG >= 2
if (fn->leaf==NULL) {
BUG_TRAP(fn->leaf);
- fn->leaf = ip6_null_entry;
+ fn->leaf = net->ip6_null_entry;
}
#endif
atomic_inc(&fn->leaf->rt6i_ref);
@@ -1079,9 +1079,9 @@ static struct fib6_node * fib6_repair_tr
static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
struct nl_info *info)
{
+ struct net *net = info->net;
struct fib6_walker_t *w;
struct rt6_info *rt = *rtp;
- struct net *net = &init_net;
RT6_TRACE("fib6_del_route\n");
@@ -1110,13 +1110,13 @@ static void fib6_del_route(struct fib6_n
rt->u.dst.rt6_next = NULL;
if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT)
- fn->leaf = ip6_null_entry;
+ fn->leaf = net->ip6_null_entry;
/* If it was last route, expunge its radix tree node */
if (fn->leaf == NULL) {
fn->fn_flags &= ~RTN_RTINFO;
net->rt6_stats->fib_route_nodes--;
- fn = fib6_repair_tree(fn);
+ fn = fib6_repair_tree(net, fn);
}
if (atomic_read(&rt->rt6i_ref) != 1) {
@@ -1128,7 +1128,7 @@ static void fib6_del_route(struct fib6_n
*/
while (fn) {
if (!(fn->fn_flags&RTN_RTINFO) && fn->leaf == rt) {
- fn->leaf = fib6_find_prefix(fn);
+ fn->leaf = fib6_find_prefix(net, fn);
atomic_inc(&fn->leaf->rt6i_ref);
rt6_release(rt);
}
@@ -1144,6 +1144,7 @@ static void fib6_del_route(struct fib6_n
int fib6_del(struct rt6_info *rt, struct nl_info *info)
{
+ struct net *net = info->net;
struct fib6_node *fn = rt->rt6i_node;
struct rt6_info **rtp;
@@ -1153,7 +1154,7 @@ int fib6_del(struct rt6_info *rt, struct
return -ENOENT;
}
#endif
- if (fn == NULL || rt == ip6_null_entry)
+ if (fn == NULL || rt == net->ip6_null_entry)
return -ENOENT;
BUG_TRAP(fn->fn_flags&RTN_RTINFO);
@@ -1498,7 +1499,7 @@ static int fib6_net_init(struct net *net
goto out_fib6_main_tbl;
net->fib6_main_tbl->tb6_id = RT6_TABLE_MAIN;
- net->fib6_main_tbl->tb6_root.leaf = ip6_null_entry;
+ net->fib6_main_tbl-&g
...