[IPV4]: fib_trie stats fix
fib_triestats has been buggy and caused oopses some platforms as openwrt. The patch below should cure those problems. Signed-off-by: Robert Olsson <robert.olsson@its.uu.se> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
5ddf0eb2bf
commit
06ef921d60
@@ -50,7 +50,7 @@
|
|||||||
* Patrick McHardy <kaber@trash.net>
|
* Patrick McHardy <kaber@trash.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define VERSION "0.405"
|
#define VERSION "0.406"
|
||||||
|
|
||||||
#include <linux/config.h>
|
#include <linux/config.h>
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
#include "fib_lookup.h"
|
#include "fib_lookup.h"
|
||||||
|
|
||||||
#undef CONFIG_IP_FIB_TRIE_STATS
|
#undef CONFIG_IP_FIB_TRIE_STATS
|
||||||
#define MAX_CHILDS 16384
|
#define MAX_STAT_DEPTH 32
|
||||||
|
|
||||||
#define KEYLENGTH (8*sizeof(t_key))
|
#define KEYLENGTH (8*sizeof(t_key))
|
||||||
#define MASK_PFX(k, l) (((l)==0)?0:(k >> (KEYLENGTH-l)) << (KEYLENGTH-l))
|
#define MASK_PFX(k, l) (((l)==0)?0:(k >> (KEYLENGTH-l)) << (KEYLENGTH-l))
|
||||||
@@ -154,7 +154,7 @@ struct trie_stat {
|
|||||||
unsigned int tnodes;
|
unsigned int tnodes;
|
||||||
unsigned int leaves;
|
unsigned int leaves;
|
||||||
unsigned int nullpointers;
|
unsigned int nullpointers;
|
||||||
unsigned int nodesizes[MAX_CHILDS];
|
unsigned int nodesizes[MAX_STAT_DEPTH];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct trie {
|
struct trie {
|
||||||
@@ -2080,7 +2080,9 @@ static void trie_collect_stats(struct trie *t, struct trie_stat *s)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
s->tnodes++;
|
s->tnodes++;
|
||||||
s->nodesizes[tn->bits]++;
|
if(tn->bits < MAX_STAT_DEPTH)
|
||||||
|
s->nodesizes[tn->bits]++;
|
||||||
|
|
||||||
for (i = 0; i < (1<<tn->bits); i++)
|
for (i = 0; i < (1<<tn->bits); i++)
|
||||||
if (!tn->child[i])
|
if (!tn->child[i])
|
||||||
s->nullpointers++;
|
s->nullpointers++;
|
||||||
@@ -2110,8 +2112,8 @@ static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat)
|
|||||||
seq_printf(seq, "\tInternal nodes: %d\n\t", stat->tnodes);
|
seq_printf(seq, "\tInternal nodes: %d\n\t", stat->tnodes);
|
||||||
bytes += sizeof(struct tnode) * stat->tnodes;
|
bytes += sizeof(struct tnode) * stat->tnodes;
|
||||||
|
|
||||||
max = MAX_CHILDS-1;
|
max = MAX_STAT_DEPTH;
|
||||||
while (max >= 0 && stat->nodesizes[max] == 0)
|
while (max > 0 && stat->nodesizes[max-1] == 0)
|
||||||
max--;
|
max--;
|
||||||
|
|
||||||
pointers = 0;
|
pointers = 0;
|
||||||
|
Reference in New Issue
Block a user