[IPV4]: fib hash|trie initialization
Initialization of the slab cache's should be done when IP is initialized to make sure of available memory, and that code can be marked __init. Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d717a9a620
commit
7f9b80529b
@ -231,8 +231,9 @@ extern int fib_sync_down(__be32 local, struct net_device *dev, int force);
|
|||||||
extern int fib_sync_up(struct net_device *dev);
|
extern int fib_sync_up(struct net_device *dev);
|
||||||
extern __be32 __fib_res_prefsrc(struct fib_result *res);
|
extern __be32 __fib_res_prefsrc(struct fib_result *res);
|
||||||
|
|
||||||
/* Exported by fib_hash.c */
|
/* Exported by fib_{hash|trie}.c */
|
||||||
extern struct fib_table *fib_hash_init(u32 id);
|
extern void fib_hash_init(void);
|
||||||
|
extern struct fib_table *fib_hash_table(u32 id);
|
||||||
|
|
||||||
static inline void fib_combine_itag(u32 *itag, struct fib_result *res)
|
static inline void fib_combine_itag(u32 *itag, struct fib_result *res)
|
||||||
{
|
{
|
||||||
|
@ -53,11 +53,11 @@ static int __net_init fib4_rules_init(struct net *net)
|
|||||||
{
|
{
|
||||||
struct fib_table *local_table, *main_table;
|
struct fib_table *local_table, *main_table;
|
||||||
|
|
||||||
local_table = fib_hash_init(RT_TABLE_LOCAL);
|
local_table = fib_hash_table(RT_TABLE_LOCAL);
|
||||||
if (local_table == NULL)
|
if (local_table == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
main_table = fib_hash_init(RT_TABLE_MAIN);
|
main_table = fib_hash_table(RT_TABLE_MAIN);
|
||||||
if (main_table == NULL)
|
if (main_table == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -83,7 +83,8 @@ struct fib_table *fib_new_table(struct net *net, u32 id)
|
|||||||
tb = fib_get_table(net, id);
|
tb = fib_get_table(net, id);
|
||||||
if (tb)
|
if (tb)
|
||||||
return tb;
|
return tb;
|
||||||
tb = fib_hash_init(id);
|
|
||||||
|
tb = fib_hash_table(id);
|
||||||
if (!tb)
|
if (!tb)
|
||||||
return NULL;
|
return NULL;
|
||||||
h = id & (FIB_TABLE_HASHSZ - 1);
|
h = id & (FIB_TABLE_HASHSZ - 1);
|
||||||
@ -1042,6 +1043,8 @@ void __init ip_fib_init(void)
|
|||||||
register_pernet_subsys(&fib_net_ops);
|
register_pernet_subsys(&fib_net_ops);
|
||||||
register_netdevice_notifier(&fib_netdev_notifier);
|
register_netdevice_notifier(&fib_netdev_notifier);
|
||||||
register_inetaddr_notifier(&fib_inetaddr_notifier);
|
register_inetaddr_notifier(&fib_inetaddr_notifier);
|
||||||
|
|
||||||
|
fib_hash_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(inet_addr_type);
|
EXPORT_SYMBOL(inet_addr_type);
|
||||||
|
@ -747,22 +747,20 @@ static int fn_hash_dump(struct fib_table *tb, struct sk_buff *skb, struct netlin
|
|||||||
return skb->len;
|
return skb->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct fib_table *fib_hash_init(u32 id)
|
void __init fib_hash_init(void)
|
||||||
|
{
|
||||||
|
fn_hash_kmem = kmem_cache_create("ip_fib_hash", sizeof(struct fib_node),
|
||||||
|
0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
|
||||||
|
|
||||||
|
fn_alias_kmem = kmem_cache_create("ip_fib_alias", sizeof(struct fib_alias),
|
||||||
|
0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
struct fib_table *fib_hash_table(u32 id)
|
||||||
{
|
{
|
||||||
struct fib_table *tb;
|
struct fib_table *tb;
|
||||||
|
|
||||||
if (fn_hash_kmem == NULL)
|
|
||||||
fn_hash_kmem = kmem_cache_create("ip_fib_hash",
|
|
||||||
sizeof(struct fib_node),
|
|
||||||
0, SLAB_HWCACHE_ALIGN,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (fn_alias_kmem == NULL)
|
|
||||||
fn_alias_kmem = kmem_cache_create("ip_fib_alias",
|
|
||||||
sizeof(struct fib_alias),
|
|
||||||
0, SLAB_HWCACHE_ALIGN,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
tb = kmalloc(sizeof(struct fib_table) + sizeof(struct fn_hash),
|
tb = kmalloc(sizeof(struct fib_table) + sizeof(struct fn_hash),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (tb == NULL)
|
if (tb == NULL)
|
||||||
|
@ -1926,19 +1926,19 @@ out:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fix more generic FIB names for init later */
|
void __init fib_hash_init(void)
|
||||||
|
{
|
||||||
|
fn_alias_kmem = kmem_cache_create("ip_fib_alias", sizeof(struct fib_alias),
|
||||||
|
0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
struct fib_table *fib_hash_init(u32 id)
|
|
||||||
|
/* Fix more generic FIB names for init later */
|
||||||
|
struct fib_table *fib_hash_table(u32 id)
|
||||||
{
|
{
|
||||||
struct fib_table *tb;
|
struct fib_table *tb;
|
||||||
struct trie *t;
|
struct trie *t;
|
||||||
|
|
||||||
if (fn_alias_kmem == NULL)
|
|
||||||
fn_alias_kmem = kmem_cache_create("ip_fib_alias",
|
|
||||||
sizeof(struct fib_alias),
|
|
||||||
0, SLAB_HWCACHE_ALIGN,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
tb = kmalloc(sizeof(struct fib_table) + sizeof(struct trie),
|
tb = kmalloc(sizeof(struct fib_table) + sizeof(struct trie),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (tb == NULL)
|
if (tb == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user