[DECNET]: Increase number of possible routing tables to 2^32
Increase the nubmer of possible routing tables to 2^32 by replacing the
fixed sized array of tables by a hash table.
Signed-off-by: Patrick McHardy [EMAIL PROTECTED]
---
commit 2bafd208cbec6b6291662bf39d94f1f9e3a54e31
tree 1b922ca700a00f4fcb97d7567d85bd9d49b5bc90
parent aab791510bc6fb2392ac361b0375f60a24b02659
author Patrick McHardy [EMAIL PROTECTED] Mon, 03 Jul 2006 09:21:50 +0200
committer Patrick McHardy [EMAIL PROTECTED] Mon, 03 Jul 2006 09:21:50 +0200
include/net/dn_fib.h |3 -
net/decnet/dn_fib.c | 49
net/decnet/dn_rules.c |2 -
net/decnet/dn_table.c | 122 +++--
4 files changed, 90 insertions(+), 86 deletions(-)
diff --git a/include/net/dn_fib.h b/include/net/dn_fib.h
index 9464f48..8098bdd 100644
--- a/include/net/dn_fib.h
+++ b/include/net/dn_fib.h
@@ -94,6 +94,7 @@ #define DN_FIB_INFO(f) ((f)-fn_info)
struct dn_fib_table {
+ struct hlist_node hlist;
u32 n;
int (*insert)(struct dn_fib_table *t, struct rtmsg *r,
@@ -179,8 +180,6 @@ static inline void dn_fib_res_put(struct
dn_fib_rule_put(res-r);
}
-extern struct dn_fib_table *dn_fib_tables[];
-
#else /* Endnode */
#define dn_fib_init() do { } while(0)
diff --git a/net/decnet/dn_fib.c b/net/decnet/dn_fib.c
index a43e59b..7127d36 100644
--- a/net/decnet/dn_fib.c
+++ b/net/decnet/dn_fib.c
@@ -532,39 +532,6 @@ int dn_fib_rtm_newroute(struct sk_buff *
return -ENOBUFS;
}
-
-int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb)
-{
- u32 t;
- u32 s_t;
- struct dn_fib_table *tb;
-
- if (NLMSG_PAYLOAD(cb-nlh, 0) = sizeof(struct rtmsg)
- ((struct rtmsg *)NLMSG_DATA(cb-nlh))-rtm_flagsRTM_F_CLONED)
- return dn_cache_dump(skb, cb);
-
- s_t = cb-args[0];
- if (s_t == 0)
- s_t = cb-args[0] = RT_MIN_TABLE;
-
- for(t = s_t; t = RT_TABLE_MAX; t++) {
- if (t s_t)
- continue;
- if (t s_t)
- memset(cb-args[1], 0,
- sizeof(cb-args) - sizeof(cb-args[0]));
- tb = dn_fib_get_table(t, 0);
- if (tb == NULL)
- continue;
- if (tb-dump(tb, skb, cb) 0)
- break;
- }
-
- cb-args[0] = t;
-
- return skb-len;
-}
-
static void fib_magic(int cmd, int type, __le16 dst, int dst_len, struct
dn_ifaddr *ifa)
{
struct dn_fib_table *tb;
@@ -762,22 +729,6 @@ int dn_fib_sync_up(struct net_device *de
return ret;
}
-void dn_fib_flush(void)
-{
-int flushed = 0;
-struct dn_fib_table *tb;
-u32 id;
-
-for(id = RT_TABLE_MAX; id 0; id--) {
-if ((tb = dn_fib_get_table(id, 0)) == NULL)
-continue;
-flushed += tb-flush(tb);
-}
-
-if (flushed)
-dn_rt_cache_flush(-1);
-}
-
static struct notifier_block dn_fib_dnaddr_notifier = {
.notifier_call = dn_fib_dnaddr_event,
};
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c
index d274d59..6d1752a 100644
--- a/net/decnet/dn_rules.c
+++ b/net/decnet/dn_rules.c
@@ -273,7 +273,7 @@ unsigned dnet_addr_type(__le16 addr)
struct flowi fl = { .nl_u = { .dn_u = { .daddr = addr } } };
struct dn_fib_res res;
unsigned ret = RTN_UNICAST;
- struct dn_fib_table *tb = dn_fib_tables[RT_TABLE_LOCAL];
+ struct dn_fib_table *tb = dn_fib_get_table(RT_TABLE_LOCAL, 0);
res.r = NULL;
diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c
index b165282..0c3417c 100644
--- a/net/decnet/dn_table.c
+++ b/net/decnet/dn_table.c
@@ -74,9 +74,9 @@ #define DN_FIB_SCAN_KEY(f, fp, key) \
for( ; ((f) = *(fp)) != NULL dn_key_eq((f)-fn_key, (key)); (fp) =
(f)-fn_next)
#define RT_TABLE_MIN 1
-
+#define DN_FIB_TABLE_HASHSZ 256
+static struct hlist_head dn_fib_table_hash[DN_FIB_TABLE_HASHSZ];
static DEFINE_RWLOCK(dn_fib_tables_lock);
-struct dn_fib_table *dn_fib_tables[RT_TABLE_MAX + 1];
static kmem_cache_t *dn_hash_kmem __read_mostly;
static int dn_fib_hash_zombies;
@@ -365,7 +365,7 @@ static __inline__ int dn_hash_dump_bucke
{
int i, s_i;
- s_i = cb-args[3];
+ s_i = cb-args[4];
for(i = 0; f; i++, f = f-fn_next) {
if (i s_i)
continue;
@@ -378,11 +378,11 @@ static __inline__ int dn_hash_dump_bucke
(f-fn_state DN_S_ZOMBIE) ? 0 : f-fn_type,
f-fn_scope, f-fn_key, dz-dz_order,
f-fn_info, NLM_F_MULTI) 0) {
- cb-args[3] = i;
+ cb-args[4] = i;
return -1;
}
}
- cb-args[3] = i;
+ cb-args[4] = i;