aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/ipv4/fib_semantics.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index b15857d2b77e..146bd82ef60d 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -49,7 +49,7 @@
49static DEFINE_SPINLOCK(fib_info_lock); 49static DEFINE_SPINLOCK(fib_info_lock);
50static struct hlist_head *fib_info_hash; 50static struct hlist_head *fib_info_hash;
51static struct hlist_head *fib_info_laddrhash; 51static struct hlist_head *fib_info_laddrhash;
52static unsigned int fib_hash_size; 52static unsigned int fib_info_hash_size;
53static unsigned int fib_info_cnt; 53static unsigned int fib_info_cnt;
54 54
55#define DEVINDEX_HASHBITS 8 55#define DEVINDEX_HASHBITS 8
@@ -223,7 +223,7 @@ static inline unsigned int fib_devindex_hashfn(unsigned int val)
223 223
224static inline unsigned int fib_info_hashfn(const struct fib_info *fi) 224static inline unsigned int fib_info_hashfn(const struct fib_info *fi)
225{ 225{
226 unsigned int mask = (fib_hash_size - 1); 226 unsigned int mask = (fib_info_hash_size - 1);
227 unsigned int val = fi->fib_nhs; 227 unsigned int val = fi->fib_nhs;
228 228
229 val ^= fi->fib_protocol; 229 val ^= fi->fib_protocol;
@@ -615,14 +615,14 @@ out:
615 615
616static inline unsigned int fib_laddr_hashfn(__be32 val) 616static inline unsigned int fib_laddr_hashfn(__be32 val)
617{ 617{
618 unsigned int mask = (fib_hash_size - 1); 618 unsigned int mask = (fib_info_hash_size - 1);
619 619
620 return ((__force u32)val ^ 620 return ((__force u32)val ^
621 ((__force u32)val >> 7) ^ 621 ((__force u32)val >> 7) ^
622 ((__force u32)val >> 14)) & mask; 622 ((__force u32)val >> 14)) & mask;
623} 623}
624 624
625static struct hlist_head *fib_hash_alloc(int bytes) 625static struct hlist_head *fib_info_hash_alloc(int bytes)
626{ 626{
627 if (bytes <= PAGE_SIZE) 627 if (bytes <= PAGE_SIZE)
628 return kzalloc(bytes, GFP_KERNEL); 628 return kzalloc(bytes, GFP_KERNEL);
@@ -632,7 +632,7 @@ static struct hlist_head *fib_hash_alloc(int bytes)
632 get_order(bytes)); 632 get_order(bytes));
633} 633}
634 634
635static void fib_hash_free(struct hlist_head *hash, int bytes) 635static void fib_info_hash_free(struct hlist_head *hash, int bytes)
636{ 636{
637 if (!hash) 637 if (!hash)
638 return; 638 return;
@@ -643,18 +643,18 @@ static void fib_hash_free(struct hlist_head *hash, int bytes)
643 free_pages((unsigned long) hash, get_order(bytes)); 643 free_pages((unsigned long) hash, get_order(bytes));
644} 644}
645 645
646static void fib_hash_move(struct hlist_head *new_info_hash, 646static void fib_info_hash_move(struct hlist_head *new_info_hash,
647 struct hlist_head *new_laddrhash, 647 struct hlist_head *new_laddrhash,
648 unsigned int new_size) 648 unsigned int new_size)
649{ 649{
650 struct hlist_head *old_info_hash, *old_laddrhash; 650 struct hlist_head *old_info_hash, *old_laddrhash;
651 unsigned int old_size = fib_hash_size; 651 unsigned int old_size = fib_info_hash_size;
652 unsigned int i, bytes; 652 unsigned int i, bytes;
653 653
654 spin_lock_bh(&fib_info_lock); 654 spin_lock_bh(&fib_info_lock);
655 old_info_hash = fib_info_hash; 655 old_info_hash = fib_info_hash;
656 old_laddrhash = fib_info_laddrhash; 656 old_laddrhash = fib_info_laddrhash;
657 fib_hash_size = new_size; 657 fib_info_hash_size = new_size;
658 658
659 for (i = 0; i < old_size; i++) { 659 for (i = 0; i < old_size; i++) {
660 struct hlist_head *head = &fib_info_hash[i]; 660 struct hlist_head *head = &fib_info_hash[i];
@@ -695,8 +695,8 @@ static void fib_hash_move(struct hlist_head *new_info_hash,
695 spin_unlock_bh(&fib_info_lock); 695 spin_unlock_bh(&fib_info_lock);
696 696
697 bytes = old_size * sizeof(struct hlist_head *); 697 bytes = old_size * sizeof(struct hlist_head *);
698 fib_hash_free(old_info_hash, bytes); 698 fib_info_hash_free(old_info_hash, bytes);
699 fib_hash_free(old_laddrhash, bytes); 699 fib_info_hash_free(old_laddrhash, bytes);
700} 700}
701 701
702struct fib_info *fib_create_info(struct fib_config *cfg) 702struct fib_info *fib_create_info(struct fib_config *cfg)
@@ -720,8 +720,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
720#endif 720#endif
721 721
722 err = -ENOBUFS; 722 err = -ENOBUFS;
723 if (fib_info_cnt >= fib_hash_size) { 723 if (fib_info_cnt >= fib_info_hash_size) {
724 unsigned int new_size = fib_hash_size << 1; 724 unsigned int new_size = fib_info_hash_size << 1;
725 struct hlist_head *new_info_hash; 725 struct hlist_head *new_info_hash;
726 struct hlist_head *new_laddrhash; 726 struct hlist_head *new_laddrhash;
727 unsigned int bytes; 727 unsigned int bytes;
@@ -729,15 +729,15 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
729 if (!new_size) 729 if (!new_size)
730 new_size = 1; 730 new_size = 1;
731 bytes = new_size * sizeof(struct hlist_head *); 731 bytes = new_size * sizeof(struct hlist_head *);
732 new_info_hash = fib_hash_alloc(bytes); 732 new_info_hash = fib_info_hash_alloc(bytes);
733 new_laddrhash = fib_hash_alloc(bytes); 733 new_laddrhash = fib_info_hash_alloc(bytes);
734 if (!new_info_hash || !new_laddrhash) { 734 if (!new_info_hash || !new_laddrhash) {
735 fib_hash_free(new_info_hash, bytes); 735 fib_info_hash_free(new_info_hash, bytes);
736 fib_hash_free(new_laddrhash, bytes); 736 fib_info_hash_free(new_laddrhash, bytes);
737 } else 737 } else
738 fib_hash_move(new_info_hash, new_laddrhash, new_size); 738 fib_info_hash_move(new_info_hash, new_laddrhash, new_size);
739 739
740 if (!fib_hash_size) 740 if (!fib_info_hash_size)
741 goto failure; 741 goto failure;
742 } 742 }
743 743