netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "David S. Miller" <davem@davemloft.net>
To: laforge@gnumonks.org
Cc: netdev@oss.sgi.com
Subject: [3/6]: Move neigh hash masks
Date: Thu, 23 Sep 2004 22:49:57 -0700	[thread overview]
Message-ID: <20040923224957.624361a6.davem@davemloft.net> (raw)


This actually moves the mask macros into
net/core/neighbour.c

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/09/23 16:47:26-07:00 davem@nuts.davemloft.net 
#   [NET]: Privatize {P,}NEIGH_HASHMASK.
#   
#   Signed-off-by: David S. Miller <davem@davemloft.net>
# 
# net/core/neighbour.c
#   2004/09/23 16:46:50-07:00 davem@nuts.davemloft.net +23 -0
#   [NET]: Privatize {P,}NEIGH_HASHMASK.
# 
# include/net/neighbour.h
#   2004/09/23 16:46:50-07:00 davem@nuts.davemloft.net +2 -5
#   [NET]: Privatize {P,}NEIGH_HASHMASK.
# 
diff -Nru a/include/net/neighbour.h b/include/net/neighbour.h
--- a/include/net/neighbour.h	2004-09-23 22:26:24 -07:00
+++ b/include/net/neighbour.h	2004-09-23 22:26:24 -07:00
@@ -140,9 +140,6 @@
 	u8			key[0];
 };
 
-#define NEIGH_HASHMASK		0x1F
-#define PNEIGH_HASHMASK		0xF
-
 /*
  *	neighbour table manipulation
  */
@@ -176,8 +173,8 @@
 	struct neigh_parms	*parms_list;
 	kmem_cache_t		*kmem_cachep;
 	struct neigh_statistics	stats;
-	struct neighbour	*hash_buckets[NEIGH_HASHMASK+1];
-	struct pneigh_entry	*phash_buckets[PNEIGH_HASHMASK+1];
+	struct neighbour	**hash_buckets;
+	struct pneigh_entry	**phash_buckets;
 };
 
 /* flags for neigh_update() */
diff -Nru a/net/core/neighbour.c b/net/core/neighbour.c
--- a/net/core/neighbour.c	2004-09-23 22:26:24 -07:00
+++ b/net/core/neighbour.c	2004-09-23 22:26:24 -07:00
@@ -47,6 +47,9 @@
 #define NEIGH_PRINTK2 NEIGH_PRINTK
 #endif
 
+#define NEIGH_HASHMASK		0x1F
+#define PNEIGH_HASHMASK		0xF
+
 static void neigh_timer_handler(unsigned long arg);
 #ifdef CONFIG_ARPD
 static void neigh_app_notify(struct neighbour *n);
@@ -1205,6 +1208,7 @@
 void neigh_table_init(struct neigh_table *tbl)
 {
 	unsigned long now = jiffies;
+	unsigned long hsize, phsize;
 
 	atomic_set(&tbl->parms.refcnt, 1);
 	INIT_RCU_HEAD(&tbl->parms.rcu_head);
@@ -1220,6 +1224,18 @@
 	if (!tbl->kmem_cachep)
 		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;
 	init_timer(&tbl->gc_timer);
 	tbl->gc_timer.data     = (unsigned long)tbl;
@@ -1260,6 +1276,13 @@
 		}
 	}
 	write_unlock(&neigh_tbl_lock);
+
+	kfree(tbl->hash_buckets);
+	tbl->hash_buckets = NULL;
+
+	kfree(tbl->phash_buckets);
+	tbl->phash_buckets = NULL;
+
 	return 0;
 }
 

                 reply	other threads:[~2004-09-24  5:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040923224957.624361a6.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=laforge@gnumonks.org \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).