aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/fib_trie.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index b56e88edf1b3..9038b914b4b1 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -358,11 +358,32 @@ static inline void free_leaf_info(struct leaf_info *li)
358 kfree(li); 358 kfree(li);
359} 359}
360 360
361static struct tnode *tnode_alloc(unsigned int size)
362{
363 if (size <= PAGE_SIZE) {
364 return kmalloc(size, GFP_KERNEL);
365 } else {
366 return (struct tnode *)
367 __get_free_pages(GFP_KERNEL, get_order(size));
368 }
369}
370
371static void __tnode_free(struct tnode *tn)
372{
373 unsigned int size = sizeof(struct tnode) +
374 (1<<tn->bits) * sizeof(struct node *);
375
376 if (size <= PAGE_SIZE)
377 kfree(tn);
378 else
379 free_pages((unsigned long)tn, get_order(size));
380}
381
361static struct tnode* tnode_new(t_key key, int pos, int bits) 382static struct tnode* tnode_new(t_key key, int pos, int bits)
362{ 383{
363 int nchildren = 1<<bits; 384 int nchildren = 1<<bits;
364 int sz = sizeof(struct tnode) + nchildren * sizeof(struct node *); 385 int sz = sizeof(struct tnode) + nchildren * sizeof(struct node *);
365 struct tnode *tn = kmalloc(sz, GFP_KERNEL); 386 struct tnode *tn = tnode_alloc(sz);
366 387
367 if(tn) { 388 if(tn) {
368 memset(tn, 0, sz); 389 memset(tn, 0, sz);
@@ -390,7 +411,7 @@ static void tnode_free(struct tnode *tn)
390 printk("FL %p \n", tn); 411 printk("FL %p \n", tn);
391 } 412 }
392 else if(IS_TNODE(tn)) { 413 else if(IS_TNODE(tn)) {
393 kfree(tn); 414 __tnode_free(tn);
394 if(trie_debug > 0 ) 415 if(trie_debug > 0 )
395 printk("FT %p \n", tn); 416 printk("FT %p \n", tn);
396 } 417 }