aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2005-07-05 17:44:55 -0400
committerDavid S. Miller <davem@davemloft.net>2005-07-05 17:44:55 -0400
commitf0e36f8cee8101604378085171c980d9cc71d779 (patch)
tree6d22dd7c129beef6616dc5a0301249ed4cbc4e3b
parent93e266f600f4048fe7a2e8803abb9f8baff84aa7 (diff)
[IPV4]: Handle large allocations in fib_trie
Inflating a node a couple of times makes it exceed the 128k kmalloc limit. Use __get_free_pages for allocations > PAGE_SIZE, as in fib_hash. Signed-off-by: Patrick McHardy <kaber@trash.net> Acked-by: Robert Olsson <Robert.Olsson@data.slu.se> Signed-off-by: David S. Miller <davem@davemloft.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 }