Commit 81a49f62 authored by David S. Miller's avatar David S. Miller Committed by David S. Miller

[NET]: Privatize {P,}NEIGH_HASHMASK.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4e181ca7
...@@ -140,9 +140,6 @@ struct pneigh_entry ...@@ -140,9 +140,6 @@ struct pneigh_entry
u8 key[0]; u8 key[0];
}; };
#define NEIGH_HASHMASK 0x1F
#define PNEIGH_HASHMASK 0xF
/* /*
* neighbour table manipulation * neighbour table manipulation
*/ */
...@@ -176,8 +173,8 @@ struct neigh_table ...@@ -176,8 +173,8 @@ struct neigh_table
struct neigh_parms *parms_list; struct neigh_parms *parms_list;
kmem_cache_t *kmem_cachep; kmem_cache_t *kmem_cachep;
struct neigh_statistics stats; struct neigh_statistics stats;
struct neighbour *hash_buckets[NEIGH_HASHMASK+1]; struct neighbour **hash_buckets;
struct pneigh_entry *phash_buckets[PNEIGH_HASHMASK+1]; struct pneigh_entry **phash_buckets;
}; };
/* flags for neigh_update() */ /* flags for neigh_update() */
......
...@@ -47,6 +47,9 @@ ...@@ -47,6 +47,9 @@
#define NEIGH_PRINTK2 NEIGH_PRINTK #define NEIGH_PRINTK2 NEIGH_PRINTK
#endif #endif
#define NEIGH_HASHMASK 0x1F
#define PNEIGH_HASHMASK 0xF
static void neigh_timer_handler(unsigned long arg); static void neigh_timer_handler(unsigned long arg);
#ifdef CONFIG_ARPD #ifdef CONFIG_ARPD
static void neigh_app_notify(struct neighbour *n); static void neigh_app_notify(struct neighbour *n);
...@@ -1205,6 +1208,7 @@ void neigh_parms_destroy(struct neigh_parms *parms) ...@@ -1205,6 +1208,7 @@ void neigh_parms_destroy(struct neigh_parms *parms)
void neigh_table_init(struct neigh_table *tbl) void neigh_table_init(struct neigh_table *tbl)
{ {
unsigned long now = jiffies; unsigned long now = jiffies;
unsigned long hsize, phsize;
atomic_set(&tbl->parms.refcnt, 1); atomic_set(&tbl->parms.refcnt, 1);
INIT_RCU_HEAD(&tbl->parms.rcu_head); INIT_RCU_HEAD(&tbl->parms.rcu_head);
...@@ -1220,6 +1224,18 @@ void neigh_table_init(struct neigh_table *tbl) ...@@ -1220,6 +1224,18 @@ void neigh_table_init(struct neigh_table *tbl)
if (!tbl->kmem_cachep) if (!tbl->kmem_cachep)
panic("cannot create neighbour cache"); panic("cannot create neighbour cache");
hsize = (NEIGH_HASHMASK + 1) * sizeof(struct neighbour *);
tbl->hash_buckets = kmalloc(hsize, GFP_KERNEL);
phsize = (PNEIGH_HASHMASK + 1) * sizeof(struct pneigh_entry *);
tbl->phash_buckets = kmalloc(phsize, GFP_KERNEL);
if (!tbl->hash_buckets || !tbl->phash_buckets)
panic("cannot allocate neighbour cache hashes");
memset(tbl->hash_buckets, 0, hsize);
memset(tbl->phash_buckets, 0, phsize);
tbl->lock = RW_LOCK_UNLOCKED; tbl->lock = RW_LOCK_UNLOCKED;
init_timer(&tbl->gc_timer); init_timer(&tbl->gc_timer);
tbl->gc_timer.data = (unsigned long)tbl; tbl->gc_timer.data = (unsigned long)tbl;
...@@ -1260,6 +1276,13 @@ int neigh_table_clear(struct neigh_table *tbl) ...@@ -1260,6 +1276,13 @@ int neigh_table_clear(struct neigh_table *tbl)
} }
} }
write_unlock(&neigh_tbl_lock); write_unlock(&neigh_tbl_lock);
kfree(tbl->hash_buckets);
tbl->hash_buckets = NULL;
kfree(tbl->phash_buckets);
tbl->phash_buckets = NULL;
return 0; return 0;
} }
......
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