Commit 8ed67789 authored by Daniel Lezcano's avatar Daniel Lezcano Committed by David S. Miller

[NETNS][IPV6] rt6_info - move rt6_info structure inside the namespace

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: default avatarDaniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: default avatarBenjamin Thery <benjamin.thery@bull.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bdb3289f
...@@ -174,7 +174,8 @@ struct fib6_table { ...@@ -174,7 +174,8 @@ struct fib6_table {
#define RT6_TABLE_LOCAL RT6_TABLE_MAIN #define RT6_TABLE_LOCAL RT6_TABLE_MAIN
#endif #endif
typedef struct rt6_info *(*pol_lookup_t)(struct fib6_table *, typedef struct rt6_info *(*pol_lookup_t)(struct net *,
struct fib6_table *,
struct flowi *, int); struct flowi *, int);
/* /*
......
...@@ -36,11 +36,14 @@ struct netns_ipv6 { ...@@ -36,11 +36,14 @@ struct netns_ipv6 {
struct xt_table *ip6table_mangle; struct xt_table *ip6table_mangle;
struct xt_table *ip6table_raw; struct xt_table *ip6table_raw;
#endif #endif
struct rt6_info *ip6_null_entry;
struct rt6_statistics *rt6_stats; struct rt6_statistics *rt6_stats;
struct timer_list *ip6_fib_timer; struct timer_list *ip6_fib_timer;
struct hlist_head *fib_table_hash; struct hlist_head *fib_table_hash;
struct fib6_table *fib6_main_tbl; struct fib6_table *fib6_main_tbl;
#ifdef CONFIG_IPV6_MULTIPLE_TABLES #ifdef CONFIG_IPV6_MULTIPLE_TABLES
struct rt6_info *ip6_prohibit_entry;
struct rt6_info *ip6_blk_hole_entry;
struct fib6_table *fib6_local_tbl; struct fib6_table *fib6_local_tbl;
struct fib_rules_ops *fib6_rules_ops; struct fib_rules_ops *fib6_rules_ops;
#endif #endif
......
...@@ -4301,15 +4301,6 @@ int __init addrconf_init(void) ...@@ -4301,15 +4301,6 @@ int __init addrconf_init(void)
if (err) if (err)
goto errlo; goto errlo;
ip6_null_entry->u.dst.dev = init_net.loopback_dev;
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);
#endif
register_netdevice_notifier(&ipv6_dev_notf); register_netdevice_notifier(&ipv6_dev_notf);
addrconf_verify(0); addrconf_verify(0);
......
...@@ -43,8 +43,8 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi *fl, ...@@ -43,8 +43,8 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi *fl,
if (arg.result) if (arg.result)
return arg.result; return arg.result;
dst_hold(&ip6_null_entry->u.dst); dst_hold(&net->ipv6.ip6_null_entry->u.dst);
return &ip6_null_entry->u.dst; return &net->ipv6.ip6_null_entry->u.dst;
} }
static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp, static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
...@@ -52,28 +52,29 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp, ...@@ -52,28 +52,29 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
{ {
struct rt6_info *rt = NULL; struct rt6_info *rt = NULL;
struct fib6_table *table; struct fib6_table *table;
struct net *net = rule->fr_net;
pol_lookup_t lookup = arg->lookup_ptr; pol_lookup_t lookup = arg->lookup_ptr;
switch (rule->action) { switch (rule->action) {
case FR_ACT_TO_TBL: case FR_ACT_TO_TBL:
break; break;
case FR_ACT_UNREACHABLE: case FR_ACT_UNREACHABLE:
rt = ip6_null_entry; rt = net->ipv6.ip6_null_entry;
goto discard_pkt; goto discard_pkt;
default: default:
case FR_ACT_BLACKHOLE: case FR_ACT_BLACKHOLE:
rt = ip6_blk_hole_entry; rt = net->ipv6.ip6_blk_hole_entry;
goto discard_pkt; goto discard_pkt;
case FR_ACT_PROHIBIT: case FR_ACT_PROHIBIT:
rt = ip6_prohibit_entry; rt = net->ipv6.ip6_prohibit_entry;
goto discard_pkt; goto discard_pkt;
} }
table = fib6_get_table(rule->fr_net, rule->table); table = fib6_get_table(net, rule->table);
if (table) if (table)
rt = lookup(table, flp, flags); rt = lookup(net, table, flp, flags);
if (rt != ip6_null_entry) { if (rt != net->ipv6.ip6_null_entry) {
struct fib6_rule *r = (struct fib6_rule *)rule; struct fib6_rule *r = (struct fib6_rule *)rule;
/* /*
......
...@@ -79,8 +79,8 @@ static DEFINE_RWLOCK(fib6_walker_lock); ...@@ -79,8 +79,8 @@ static DEFINE_RWLOCK(fib6_walker_lock);
static void fib6_prune_clones(struct net *net, struct fib6_node *fn, static void fib6_prune_clones(struct net *net, struct fib6_node *fn,
struct rt6_info *rt); struct rt6_info *rt);
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);
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);
static int fib6_walk(struct fib6_walker_t *w); static int fib6_walk(struct fib6_walker_t *w);
static int fib6_walk_continue(struct fib6_walker_t *w); static int fib6_walk_continue(struct fib6_walker_t *w);
...@@ -193,14 +193,14 @@ static void fib6_link_table(struct net *net, struct fib6_table *tb) ...@@ -193,14 +193,14 @@ static void fib6_link_table(struct net *net, struct fib6_table *tb)
#ifdef CONFIG_IPV6_MULTIPLE_TABLES #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; struct fib6_table *table;
table = kzalloc(sizeof(*table), GFP_ATOMIC); table = kzalloc(sizeof(*table), GFP_ATOMIC);
if (table != NULL) { if (table != NULL) {
table->tb6_id = id; table->tb6_id = id;
table->tb6_root.leaf = ip6_null_entry; table->tb6_root.leaf = net->ipv6.ip6_null_entry;
table->tb6_root.fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO; table->tb6_root.fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO;
} }
...@@ -217,7 +217,7 @@ struct fib6_table *fib6_new_table(struct net *net, u32 id) ...@@ -217,7 +217,7 @@ struct fib6_table *fib6_new_table(struct net *net, u32 id)
if (tb) if (tb)
return tb; return tb;
tb = fib6_alloc_table(id); tb = fib6_alloc_table(net, id);
if (tb != NULL) if (tb != NULL)
fib6_link_table(net, tb); fib6_link_table(net, tb);
...@@ -267,7 +267,7 @@ struct fib6_table *fib6_get_table(struct net *net, u32 id) ...@@ -267,7 +267,7 @@ struct fib6_table *fib6_get_table(struct net *net, u32 id)
struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi *fl, struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi *fl,
int flags, pol_lookup_t lookup) int flags, pol_lookup_t lookup)
{ {
return (struct dst_entry *) lookup(net->ipv6.fib6_main_tbl, fl, flags); return (struct dst_entry *) lookup(net, net->ipv6.fib6_main_tbl, fl, flags);
} }
static void fib6_tables_init(struct net *net) static void fib6_tables_init(struct net *net)
...@@ -717,8 +717,8 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) ...@@ -717,8 +717,8 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info)
if (sfn == NULL) if (sfn == NULL)
goto st_failure; goto st_failure;
sfn->leaf = ip6_null_entry; sfn->leaf = info->nl_net->ipv6.ip6_null_entry;
atomic_inc(&ip6_null_entry->rt6i_ref); atomic_inc(&info->nl_net->ipv6.ip6_null_entry->rt6i_ref);
sfn->fn_flags = RTN_ROOT; sfn->fn_flags = RTN_ROOT;
sfn->fn_sernum = fib6_new_sernum(); sfn->fn_sernum = fib6_new_sernum();
...@@ -773,11 +773,11 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) ...@@ -773,11 +773,11 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info)
* super-tree leaf node we have to find a new one for it. * super-tree leaf node we have to find a new one for it.
*/ */
if (pn != fn && !pn->leaf && !(pn->fn_flags & RTN_RTINFO)) { if (pn != fn && !pn->leaf && !(pn->fn_flags & RTN_RTINFO)) {
pn->leaf = fib6_find_prefix(pn); pn->leaf = fib6_find_prefix(info->nl_net, pn);
#if RT6_DEBUG >= 2 #if RT6_DEBUG >= 2
if (!pn->leaf) { if (!pn->leaf) {
BUG_TRAP(pn->leaf != NULL); BUG_TRAP(pn->leaf != NULL);
pn->leaf = ip6_null_entry; pn->leaf = info->nl_net->ipv6.ip6_null_entry;
} }
#endif #endif
atomic_inc(&pn->leaf->rt6i_ref); atomic_inc(&pn->leaf->rt6i_ref);
...@@ -793,7 +793,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) ...@@ -793,7 +793,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info)
*/ */
st_failure: st_failure:
if (fn && !(fn->fn_flags & (RTN_RTINFO|RTN_ROOT))) if (fn && !(fn->fn_flags & (RTN_RTINFO|RTN_ROOT)))
fib6_repair_tree(fn); fib6_repair_tree(info->nl_net, fn);
dst_free(&rt->u.dst); dst_free(&rt->u.dst);
return err; return err;
#endif #endif
...@@ -959,10 +959,10 @@ struct fib6_node * fib6_locate(struct fib6_node *root, ...@@ -959,10 +959,10 @@ struct fib6_node * fib6_locate(struct fib6_node *root,
* *
*/ */
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) if (fn->fn_flags&RTN_ROOT)
return ip6_null_entry; return net->ipv6.ip6_null_entry;
while(fn) { while(fn) {
if(fn->left) if(fn->left)
...@@ -981,7 +981,8 @@ static struct rt6_info * fib6_find_prefix(struct fib6_node *fn) ...@@ -981,7 +981,8 @@ static struct rt6_info * fib6_find_prefix(struct fib6_node *fn)
* is the node we want to try and remove. * 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 children;
int nstate; int nstate;
...@@ -1008,11 +1009,11 @@ static struct fib6_node * fib6_repair_tree(struct fib6_node *fn) ...@@ -1008,11 +1009,11 @@ static struct fib6_node * fib6_repair_tree(struct fib6_node *fn)
|| (children && fn->fn_flags&RTN_ROOT) || (children && fn->fn_flags&RTN_ROOT)
#endif #endif
) { ) {
fn->leaf = fib6_find_prefix(fn); fn->leaf = fib6_find_prefix(net, fn);
#if RT6_DEBUG >= 2 #if RT6_DEBUG >= 2
if (fn->leaf==NULL) { if (fn->leaf==NULL) {
BUG_TRAP(fn->leaf); BUG_TRAP(fn->leaf);
fn->leaf = ip6_null_entry; fn->leaf = net->ipv6.ip6_null_entry;
} }
#endif #endif
atomic_inc(&fn->leaf->rt6i_ref); atomic_inc(&fn->leaf->rt6i_ref);
...@@ -1117,7 +1118,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp, ...@@ -1117,7 +1118,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
if (fn->leaf == NULL) { if (fn->leaf == NULL) {
fn->fn_flags &= ~RTN_RTINFO; fn->fn_flags &= ~RTN_RTINFO;
net->ipv6.rt6_stats->fib_route_nodes--; net->ipv6.rt6_stats->fib_route_nodes--;
fn = fib6_repair_tree(fn); fn = fib6_repair_tree(net, fn);
} }
if (atomic_read(&rt->rt6i_ref) != 1) { if (atomic_read(&rt->rt6i_ref) != 1) {
...@@ -1129,7 +1130,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp, ...@@ -1129,7 +1130,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
*/ */
while (fn) { while (fn) {
if (!(fn->fn_flags&RTN_RTINFO) && fn->leaf == rt) { 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); atomic_inc(&fn->leaf->rt6i_ref);
rt6_release(rt); rt6_release(rt);
} }
...@@ -1145,6 +1146,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp, ...@@ -1145,6 +1146,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
int fib6_del(struct rt6_info *rt, struct nl_info *info) int fib6_del(struct rt6_info *rt, struct nl_info *info)
{ {
struct net *net = info->nl_net;
struct fib6_node *fn = rt->rt6i_node; struct fib6_node *fn = rt->rt6i_node;
struct rt6_info **rtp; struct rt6_info **rtp;
...@@ -1154,7 +1156,7 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info) ...@@ -1154,7 +1156,7 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info)
return -ENOENT; return -ENOENT;
} }
#endif #endif
if (fn == NULL || rt == ip6_null_entry) if (fn == NULL || rt == net->ipv6.ip6_null_entry)
return -ENOENT; return -ENOENT;
BUG_TRAP(fn->fn_flags&RTN_RTINFO); BUG_TRAP(fn->fn_flags&RTN_RTINFO);
...@@ -1501,7 +1503,7 @@ static int fib6_net_init(struct net *net) ...@@ -1501,7 +1503,7 @@ static int fib6_net_init(struct net *net)
goto out_fib_table_hash; goto out_fib_table_hash;
net->ipv6.fib6_main_tbl->tb6_id = RT6_TABLE_MAIN; 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 = net->ipv6.ip6_null_entry;
net->ipv6.fib6_main_tbl->tb6_root.fn_flags = net->ipv6.fib6_main_tbl->tb6_root.fn_flags =
RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO; RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO;
...@@ -1511,7 +1513,7 @@ static int fib6_net_init(struct net *net) ...@@ -1511,7 +1513,7 @@ static int fib6_net_init(struct net *net)
if (!net->ipv6.fib6_local_tbl) if (!net->ipv6.fib6_local_tbl)
goto out_fib6_main_tbl; goto out_fib6_main_tbl;
net->ipv6.fib6_local_tbl->tb6_id = RT6_TABLE_LOCAL; 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 = net->ipv6.ip6_null_entry;
net->ipv6.fib6_local_tbl->tb6_root.fn_flags = net->ipv6.fib6_local_tbl->tb6_root.fn_flags =
RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO; RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO;
#endif #endif
...@@ -1536,6 +1538,7 @@ static int fib6_net_init(struct net *net) ...@@ -1536,6 +1538,7 @@ static int fib6_net_init(struct net *net)
static void fib6_net_exit(struct net *net) static void fib6_net_exit(struct net *net)
{ {
rt6_ifdown(net, NULL);
del_timer(net->ipv6.ip6_fib_timer); del_timer(net->ipv6.ip6_fib_timer);
kfree(net->ipv6.ip6_fib_timer); kfree(net->ipv6.ip6_fib_timer);
#ifdef CONFIG_IPV6_MULTIPLE_TABLES #ifdef CONFIG_IPV6_MULTIPLE_TABLES
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment