From fa13a7b8fd68f4c00fc8c6905261b50a4733d8c3 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 5 Feb 2004 21:39:01 -0800 Subject: [PATCH] [NET]: Hash netdevices by name for faster lookup. --- include/linux/netdevice.h | 2 ++ net/core/dev.c | 55 ++++++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 84b6fd41e2d29..11723ab7e2c57 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -375,6 +375,8 @@ struct net_device atomic_t refcnt; /* delayed register/unregister */ struct list_head todo_list; + /* device name hash chain */ + struct hlist_node name_hlist; /* register/unregister state machine */ enum { NETREG_UNINITIALIZED=0, diff --git a/net/core/dev.c b/net/core/dev.c index e298f2b7f9c99..d5ba80179da6d 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -180,11 +180,21 @@ static struct timer_list samp_timer = TIMER_INITIALIZER(sample_queue, 0, 0); * semaphore held. */ struct net_device *dev_base; +struct net_device **dev_tail = &dev_base; rwlock_t dev_base_lock = RW_LOCK_UNLOCKED; EXPORT_SYMBOL(dev_base); EXPORT_SYMBOL(dev_base_lock); +#define NETDEV_HASHBITS 8 +static struct hlist_head dev_name_head[1<