Commit 91b9a277 authored by Olof Johansson's avatar Olof Johansson Committed by David S. Miller

[IPV4]: FIB Trie cleanups.

Below is a patch that cleans up some of this, supposedly without
changing any behaviour:

* Whitespace cleanups
* Introduce DBG()
* BUG_ON() instead of if () { BUG(); }
* Remove some of the deep nesting to make the code flow more
  comprehensible
* Some mask operations were simplified
Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
Signed-off-by: default avatarRobert Olsson <robert.olsson@its.uu.se>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7663f188
...@@ -89,27 +89,27 @@ typedef unsigned int t_key; ...@@ -89,27 +89,27 @@ typedef unsigned int t_key;
#define T_TNODE 0 #define T_TNODE 0
#define T_LEAF 1 #define T_LEAF 1
#define NODE_TYPE_MASK 0x1UL #define NODE_TYPE_MASK 0x1UL
#define NODE_PARENT(_node) \ #define NODE_PARENT(node) \
((struct tnode *)((_node)->_parent & ~NODE_TYPE_MASK)) ((struct tnode *)((node)->parent & ~NODE_TYPE_MASK))
#define NODE_SET_PARENT(_node, _ptr) \ #define NODE_SET_PARENT(node, ptr) \
((_node)->_parent = (((unsigned long)(_ptr)) | \ ((node)->parent = (((unsigned long)(ptr)) | \
((_node)->_parent & NODE_TYPE_MASK))) ((node)->parent & NODE_TYPE_MASK)))
#define NODE_INIT_PARENT(_node, _type) \ #define NODE_INIT_PARENT(node, type) \
((_node)->_parent = (_type)) ((node)->parent = (type))
#define NODE_TYPE(_node) \ #define NODE_TYPE(node) \
((_node)->_parent & NODE_TYPE_MASK) ((node)->parent & NODE_TYPE_MASK)
#define IS_TNODE(n) (!(n->_parent & T_LEAF)) #define IS_TNODE(n) (!(n->parent & T_LEAF))
#define IS_LEAF(n) (n->_parent & T_LEAF) #define IS_LEAF(n) (n->parent & T_LEAF)
struct node { struct node {
t_key key; t_key key;
unsigned long _parent; unsigned long parent;
}; };
struct leaf { struct leaf {
t_key key; t_key key;
unsigned long _parent; unsigned long parent;
struct hlist_head list; struct hlist_head list;
}; };
...@@ -121,7 +121,7 @@ struct leaf_info { ...@@ -121,7 +121,7 @@ struct leaf_info {
struct tnode { struct tnode {
t_key key; t_key key;
unsigned long _parent; unsigned long parent;
unsigned short pos:5; /* 2log(KEYLENGTH) bits needed */ unsigned short pos:5; /* 2log(KEYLENGTH) bits needed */
unsigned short bits:5; /* 2log(KEYLENGTH) bits needed */ unsigned short bits:5; /* 2log(KEYLENGTH) bits needed */
unsigned short full_children; /* KEYLENGTH bits needed */ unsigned short full_children; /* KEYLENGTH bits needed */
...@@ -160,6 +160,8 @@ struct trie { ...@@ -160,6 +160,8 @@ struct trie {
static int trie_debug = 0; static int trie_debug = 0;
#define DBG(x...) do { if (trie_debug) printk(x); } while (0)
static int tnode_full(struct tnode *tn, struct node *n); static int tnode_full(struct tnode *tn, struct node *n);
static void put_child(struct trie *t, struct tnode *tn, int i, struct node *n); static void put_child(struct trie *t, struct tnode *tn, int i, struct node *n);
static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n, int wasfull); static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n, int wasfull);
...@@ -179,43 +181,18 @@ extern void rtmsg_fib(int event, u32 key, struct fib_alias *fa, int z, int tb_id ...@@ -179,43 +181,18 @@ extern void rtmsg_fib(int event, u32 key, struct fib_alias *fa, int z, int tb_id
static kmem_cache_t *fn_alias_kmem; static kmem_cache_t *fn_alias_kmem;
static struct trie *trie_local = NULL, *trie_main = NULL; static struct trie *trie_local = NULL, *trie_main = NULL;
static void trie_bug(char *err)
{
printk("Trie Bug: %s\n", err);
BUG();
}
static inline struct node *tnode_get_child(struct tnode *tn, int i) static inline struct node *tnode_get_child(struct tnode *tn, int i)
{ {
if (i >= 1<<tn->bits) BUG_ON(i >= 1 << tn->bits);
trie_bug("tnode_get_child");
return tn->child[i]; return tn->child[i];
} }
static inline int tnode_child_length(struct tnode *tn) static inline int tnode_child_length(struct tnode *tn)
{ {
return 1<<tn->bits; return 1 << tn->bits;
} }
/*
_________________________________________________________________
| i | i | i | i | i | i | i | N | N | N | S | S | S | S | S | C |
----------------------------------------------------------------
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
_________________________________________________________________
| C | C | C | u | u | u | u | u | u | u | u | u | u | u | u | u |
-----------------------------------------------------------------
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
tp->pos = 7
tp->bits = 3
n->pos = 15
n->bits=4
KEYLENGTH=32
*/
static inline t_key tkey_extract_bits(t_key a, int offset, int bits) static inline t_key tkey_extract_bits(t_key a, int offset, int bits)
{ {
if (offset < KEYLENGTH) if (offset < KEYLENGTH)
...@@ -249,7 +226,7 @@ static inline int tkey_mismatch(t_key a, int offset, t_key b) ...@@ -249,7 +226,7 @@ static inline int tkey_mismatch(t_key a, int offset, t_key b)
return i; return i;
} }
/* Candiate for fib_semantics */ /* Candidate for fib_semantics */
static void fn_free_alias(struct fib_alias *fa) static void fn_free_alias(struct fib_alias *fa)
{ {
...@@ -295,7 +272,7 @@ static void fn_free_alias(struct fib_alias *fa) ...@@ -295,7 +272,7 @@ static void fn_free_alias(struct fib_alias *fa)
tp->pos = 7 tp->pos = 7
tp->bits = 3 tp->bits = 3
n->pos = 15 n->pos = 15
n->bits=4 n->bits = 4
First, let's just ignore the bits that come before the parent tp, that is First, let's just ignore the bits that come before the parent tp, that is
the bits from 0 to (tp->pos-1). They are *known* but at this point we do the bits from 0 to (tp->pos-1). They are *known* but at this point we do
...@@ -343,10 +320,13 @@ static struct leaf *leaf_new(void) ...@@ -343,10 +320,13 @@ static struct leaf *leaf_new(void)
static struct leaf_info *leaf_info_new(int plen) static struct leaf_info *leaf_info_new(int plen)
{ {
struct leaf_info *li = kmalloc(sizeof(struct leaf_info), GFP_KERNEL); struct leaf_info *li = kmalloc(sizeof(struct leaf_info), GFP_KERNEL);
if (li) {
if (!li)
return NULL;
li->plen = plen; li->plen = plen;
INIT_LIST_HEAD(&li->falh); INIT_LIST_HEAD(&li->falh);
}
return li; return li;
} }
...@@ -373,7 +353,7 @@ static struct tnode *tnode_alloc(unsigned int size) ...@@ -373,7 +353,7 @@ static struct tnode *tnode_alloc(unsigned int size)
static void __tnode_free(struct tnode *tn) static void __tnode_free(struct tnode *tn)
{ {
unsigned int size = sizeof(struct tnode) + unsigned int size = sizeof(struct tnode) +
(1<<tn->bits) * sizeof(struct node *); (1 << tn->bits) * sizeof(struct node *);
if (size <= PAGE_SIZE) if (size <= PAGE_SIZE)
kfree(tn); kfree(tn);
...@@ -397,29 +377,21 @@ static struct tnode* tnode_new(t_key key, int pos, int bits) ...@@ -397,29 +377,21 @@ static struct tnode* tnode_new(t_key key, int pos, int bits)
tn->empty_children = 1<<bits; tn->empty_children = 1<<bits;
} }
if (trie_debug > 0) DBG("AT %p s=%u %u\n", tn, (unsigned int) sizeof(struct tnode),
printk("AT %p s=%u %u\n", tn, (unsigned int) sizeof(struct tnode),
(unsigned int) (sizeof(struct node) * 1<<bits)); (unsigned int) (sizeof(struct node) * 1<<bits));
return tn; return tn;
} }
static void tnode_free(struct tnode *tn) static void tnode_free(struct tnode *tn)
{ {
if (!tn) { BUG_ON(!tn);
trie_bug("tnode_free\n");
}
if (IS_LEAF(tn)) { if (IS_LEAF(tn)) {
free_leaf((struct leaf *)tn); free_leaf((struct leaf *)tn);
if (trie_debug > 0 ) DBG("FL %p \n", tn);
printk("FL %p \n", tn); } else {
}
else if (IS_TNODE(tn)) {
__tnode_free(tn); __tnode_free(tn);
if (trie_debug > 0 ) DBG("FT %p \n", tn);
printk("FT %p \n", tn);
}
else {
trie_bug("tnode_free\n");
} }
} }
...@@ -453,7 +425,7 @@ static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n, int w ...@@ -453,7 +425,7 @@ static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n, int w
if (i >= 1<<tn->bits) { if (i >= 1<<tn->bits) {
printk("bits=%d, i=%d\n", tn->bits, i); printk("bits=%d, i=%d\n", tn->bits, i);
trie_bug("tnode_put_child_reorg bits"); BUG();
} }
write_lock_bh(&fib_lock); write_lock_bh(&fib_lock);
chi = tn->child[i]; chi = tn->child[i];
...@@ -471,9 +443,9 @@ static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n, int w ...@@ -471,9 +443,9 @@ static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n, int w
isfull = tnode_full(tn, n); isfull = tnode_full(tn, n);
if (wasfull && !isfull) if (wasfull && !isfull)
tn->full_children--; tn->full_children--;
else if (!wasfull && isfull) else if (!wasfull && isfull)
tn->full_children++; tn->full_children++;
if (n) if (n)
NODE_SET_PARENT(n, tn); NODE_SET_PARENT(n, tn);
...@@ -489,8 +461,7 @@ static struct node *resize(struct trie *t, struct tnode *tn) ...@@ -489,8 +461,7 @@ static struct node *resize(struct trie *t, struct tnode *tn)
if (!tn) if (!tn)
return NULL; return NULL;
if (trie_debug) DBG("In tnode_resize %p inflate_threshold=%d threshold=%d\n",
printk("In tnode_resize %p inflate_threshold=%d threshold=%d\n",
tn, inflate_threshold, halve_threshold); tn, inflate_threshold, halve_threshold);
/* No children */ /* No children */
...@@ -501,21 +472,22 @@ static struct node *resize(struct trie *t, struct tnode *tn) ...@@ -501,21 +472,22 @@ static struct node *resize(struct trie *t, struct tnode *tn)
/* One child */ /* One child */
if (tn->empty_children == tnode_child_length(tn) - 1) if (tn->empty_children == tnode_child_length(tn) - 1)
for (i = 0; i < tnode_child_length(tn); i++) { for (i = 0; i < tnode_child_length(tn); i++) {
struct node *n;
write_lock_bh(&fib_lock); write_lock_bh(&fib_lock);
if (tn->child[i] != NULL) { n = tn->child[i];
if (!n) {
write_unlock_bh(&fib_lock);
continue;
}
/* compress one level */ /* compress one level */
struct node *n = tn->child[i];
if (n)
NODE_INIT_PARENT(n, NODE_TYPE(n)); NODE_INIT_PARENT(n, NODE_TYPE(n));
write_unlock_bh(&fib_lock); write_unlock_bh(&fib_lock);
tnode_free(tn); tnode_free(tn);
return n; return n;
} }
write_unlock_bh(&fib_lock);
}
/* /*
* Double as long as the resulting node has a number of * Double as long as the resulting node has a number of
* nonempty nodes that are above the threshold. * nonempty nodes that are above the threshold.
...@@ -566,16 +538,16 @@ static struct node *resize(struct trie *t, struct tnode *tn) ...@@ -566,16 +538,16 @@ static struct node *resize(struct trie *t, struct tnode *tn)
* *
* expand not_to_be_doubled and to_be_doubled, and shorten: * expand not_to_be_doubled and to_be_doubled, and shorten:
* 100 * (tnode_child_length(tn) - tn->empty_children + * 100 * (tnode_child_length(tn) - tn->empty_children +
* tn->full_children ) >= inflate_threshold * new_child_length * tn->full_children) >= inflate_threshold * new_child_length
* *
* expand new_child_length: * expand new_child_length:
* 100 * (tnode_child_length(tn) - tn->empty_children + * 100 * (tnode_child_length(tn) - tn->empty_children +
* tn->full_children ) >= * tn->full_children) >=
* inflate_threshold * tnode_child_length(tn) * 2 * inflate_threshold * tnode_child_length(tn) * 2
* *
* shorten again: * shorten again:
* 50 * (tn->full_children + tnode_child_length(tn) - * 50 * (tn->full_children + tnode_child_length(tn) -
* tn->empty_children ) >= inflate_threshold * * tn->empty_children) >= inflate_threshold *
* tnode_child_length(tn) * tnode_child_length(tn)
* *
*/ */
...@@ -624,21 +596,24 @@ static struct node *resize(struct trie *t, struct tnode *tn) ...@@ -624,21 +596,24 @@ static struct node *resize(struct trie *t, struct tnode *tn)
if (tn->empty_children == tnode_child_length(tn) - 1) if (tn->empty_children == tnode_child_length(tn) - 1)
for (i = 0; i < tnode_child_length(tn); i++) { for (i = 0; i < tnode_child_length(tn); i++) {
struct node *n;
write_lock_bh(&fib_lock); write_lock_bh(&fib_lock);
if (tn->child[i] != NULL) {
n = tn->child[i];
if (!n) {
write_unlock_bh(&fib_lock);
continue;
}
/* compress one level */ /* compress one level */
struct node *n = tn->child[i];
if (n)
NODE_INIT_PARENT(n, NODE_TYPE(n)); NODE_INIT_PARENT(n, NODE_TYPE(n));
write_unlock_bh(&fib_lock); write_unlock_bh(&fib_lock);
tnode_free(tn); tnode_free(tn);
return n; return n;
} }
write_unlock_bh(&fib_lock);
}
return (struct node *) tn; return (struct node *) tn;
} }
...@@ -650,8 +625,7 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err) ...@@ -650,8 +625,7 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
int olen = tnode_child_length(tn); int olen = tnode_child_length(tn);
int i; int i;
if (trie_debug) DBG("In inflate\n");
printk("In inflate\n");
tn = tnode_new(oldtnode->key, oldtnode->pos, oldtnode->bits + 1); tn = tnode_new(oldtnode->key, oldtnode->pos, oldtnode->bits + 1);
...@@ -667,7 +641,7 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err) ...@@ -667,7 +641,7 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
* of tnode is ignored. * of tnode is ignored.
*/ */
for(i = 0; i < olen; i++) { for (i = 0; i < olen; i++) {
struct tnode *inode = (struct tnode *) tnode_get_child(oldtnode, i); struct tnode *inode = (struct tnode *) tnode_get_child(oldtnode, i);
if (inode && if (inode &&
...@@ -675,7 +649,6 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err) ...@@ -675,7 +649,6 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
inode->pos == oldtnode->pos + oldtnode->bits && inode->pos == oldtnode->pos + oldtnode->bits &&
inode->bits > 1) { inode->bits > 1) {
struct tnode *left, *right; struct tnode *left, *right;
t_key m = TKEY_GET_MASK(inode->pos, 1); t_key m = TKEY_GET_MASK(inode->pos, 1);
left = tnode_new(inode->key&(~m), inode->pos + 1, left = tnode_new(inode->key&(~m), inode->pos + 1,
...@@ -703,7 +676,7 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err) ...@@ -703,7 +676,7 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
int size = tnode_child_length(tn); int size = tnode_child_length(tn);
int j; int j;
for(j = 0; j < size; j++) for (j = 0; j < size; j++)
if (tn->child[j]) if (tn->child[j])
tnode_free((struct tnode *)tn->child[j]); tnode_free((struct tnode *)tn->child[j]);
...@@ -713,8 +686,10 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err) ...@@ -713,8 +686,10 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
return oldtnode; return oldtnode;
} }
for(i = 0; i < olen; i++) { for (i = 0; i < olen; i++) {
struct node *node = tnode_get_child(oldtnode, i); struct node *node = tnode_get_child(oldtnode, i);
struct tnode *left, *right;
int size, j;
/* An empty child */ /* An empty child */
if (node == NULL) if (node == NULL)
...@@ -740,12 +715,10 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err) ...@@ -740,12 +715,10 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
put_child(t, tn, 2*i+1, inode->child[1]); put_child(t, tn, 2*i+1, inode->child[1]);
tnode_free(inode); tnode_free(inode);
continue;
} }
/* An internal node with more than two children */ /* An internal node with more than two children */
else {
struct tnode *left, *right;
int size, j;
/* We will replace this node 'inode' with two new /* We will replace this node 'inode' with two new
* ones, 'left' and 'right', each with half of the * ones, 'left' and 'right', each with half of the
...@@ -771,17 +744,15 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err) ...@@ -771,17 +744,15 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
left = (struct tnode *) tnode_get_child(tn, 2*i); left = (struct tnode *) tnode_get_child(tn, 2*i);
put_child(t, tn, 2*i, NULL); put_child(t, tn, 2*i, NULL);
if (!left) BUG_ON(!left);
BUG();
right = (struct tnode *) tnode_get_child(tn, 2*i+1); right = (struct tnode *) tnode_get_child(tn, 2*i+1);
put_child(t, tn, 2*i+1, NULL); put_child(t, tn, 2*i+1, NULL);
if (!right) BUG_ON(!right);
BUG();
size = tnode_child_length(left); size = tnode_child_length(left);
for(j = 0; j < size; j++) { for (j = 0; j < size; j++) {
put_child(t, left, j, inode->child[j]); put_child(t, left, j, inode->child[j]);
put_child(t, right, j, inode->child[j + size]); put_child(t, right, j, inode->child[j + size]);
} }
...@@ -790,7 +761,6 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err) ...@@ -790,7 +761,6 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn, int *err)
tnode_free(inode); tnode_free(inode);
} }
}
tnode_free(oldtnode); tnode_free(oldtnode);
return tn; return tn;
} }
...@@ -802,7 +772,7 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err) ...@@ -802,7 +772,7 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err)
int i; int i;
int olen = tnode_child_length(tn); int olen = tnode_child_length(tn);
if (trie_debug) printk("In halve\n"); DBG("In halve\n");
tn = tnode_new(oldtnode->key, oldtnode->pos, oldtnode->bits - 1); tn = tnode_new(oldtnode->key, oldtnode->pos, oldtnode->bits - 1);
...@@ -818,7 +788,7 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err) ...@@ -818,7 +788,7 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err)
* of tnode is ignored. * of tnode is ignored.
*/ */
for(i = 0; i < olen; i += 2) { for (i = 0; i < olen; i += 2) {
left = tnode_get_child(oldtnode, i); left = tnode_get_child(oldtnode, i);
right = tnode_get_child(oldtnode, i+1); right = tnode_get_child(oldtnode, i+1);
...@@ -839,7 +809,7 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err) ...@@ -839,7 +809,7 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err)
int size = tnode_child_length(tn); int size = tnode_child_length(tn);
int j; int j;
for(j = 0; j < size; j++) for (j = 0; j < size; j++)
if (tn->child[j]) if (tn->child[j])
tnode_free((struct tnode *)tn->child[j]); tnode_free((struct tnode *)tn->child[j]);
...@@ -849,7 +819,9 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err) ...@@ -849,7 +819,9 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err)
return oldtnode; return oldtnode;
} }
for(i = 0; i < olen; i += 2) { for (i = 0; i < olen; i += 2) {
struct tnode *newBinNode;
left = tnode_get_child(oldtnode, i); left = tnode_get_child(oldtnode, i);
right = tnode_get_child(oldtnode, i+1); right = tnode_get_child(oldtnode, i+1);
...@@ -858,38 +830,39 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err) ...@@ -858,38 +830,39 @@ static struct tnode *halve(struct trie *t, struct tnode *tn, int *err)
if (right == NULL) /* Both are empty */ if (right == NULL) /* Both are empty */
continue; continue;
put_child(t, tn, i/2, right); put_child(t, tn, i/2, right);
} else if (right == NULL) continue;
}
if (right == NULL) {
put_child(t, tn, i/2, left); put_child(t, tn, i/2, left);
continue;
}
/* Two nonempty children */ /* Two nonempty children */
else { newBinNode = (struct tnode *) tnode_get_child(tn, i/2);
struct tnode *newBinNode =
(struct tnode *) tnode_get_child(tn, i/2);
put_child(t, tn, i/2, NULL); put_child(t, tn, i/2, NULL);
if (!newBinNode) BUG_ON(!newBinNode);
BUG();
put_child(t, newBinNode, 0, left); put_child(t, newBinNode, 0, left);
put_child(t, newBinNode, 1, right); put_child(t, newBinNode, 1, right);
put_child(t, tn, i/2, resize(t, newBinNode)); put_child(t, tn, i/2, resize(t, newBinNode));
} }
}
tnode_free(oldtnode); tnode_free(oldtnode);
return tn; return tn;
} }
static void *trie_init(struct trie *t) static void trie_init(struct trie *t)
{ {
if (t) { if (!t)
return;
t->size = 0; t->size = 0;
t->trie = NULL; t->trie = NULL;
t->revision = 0; t->revision = 0;
#ifdef CONFIG_IP_FIB_TRIE_STATS #ifdef CONFIG_IP_FIB_TRIE_STATS
memset(&t->stats, 0, sizeof(struct trie_use_stats)); memset(&t->stats, 0, sizeof(struct trie_use_stats));
#endif #endif
}
return t;
} }
static struct leaf_info *find_leaf_info(struct hlist_head *head, int plen) static struct leaf_info *find_leaf_info(struct hlist_head *head, int plen)
...@@ -897,36 +870,34 @@ static struct leaf_info *find_leaf_info(struct hlist_head *head, int plen) ...@@ -897,36 +870,34 @@ static struct leaf_info *find_leaf_info(struct hlist_head *head, int plen)
struct hlist_node *node; struct hlist_node *node;
struct leaf_info *li; struct leaf_info *li;
hlist_for_each_entry(li, node, head, hlist) { hlist_for_each_entry(li, node, head, hlist)
if (li->plen == plen) if (li->plen == plen)
return li; return li;
}
return NULL; return NULL;
} }
static inline struct list_head * get_fa_head(struct leaf *l, int plen) static inline struct list_head * get_fa_head(struct leaf *l, int plen)
{ {
struct list_head *fa_head = NULL;
struct leaf_info *li = find_leaf_info(&l->list, plen); struct leaf_info *li = find_leaf_info(&l->list, plen);
if (li) if (!li)
fa_head = &li->falh; return NULL;
return fa_head; return &li->falh;
} }
static void insert_leaf_info(struct hlist_head *head, struct leaf_info *new) static void insert_leaf_info(struct hlist_head *head, struct leaf_info *new)
{ {
struct leaf_info *li = NULL, *last = NULL; struct leaf_info *li = NULL, *last = NULL;
struct hlist_node *node, *tmp; struct hlist_node *node;
write_lock_bh(&fib_lock); write_lock_bh(&fib_lock);
if (hlist_empty(head)) if (hlist_empty(head)) {
hlist_add_head(&new->hlist, head); hlist_add_head(&new->hlist, head);
else { } else {
hlist_for_each_entry_safe(li, node, tmp, head, hlist) { hlist_for_each_entry(li, node, head, hlist) {
if (new->plen > li->plen) if (new->plen > li->plen)
break; break;
...@@ -956,45 +927,43 @@ fib_find_node(struct trie *t, u32 key) ...@@ -956,45 +927,43 @@ fib_find_node(struct trie *t, u32 key)
check_tnode(tn); check_tnode(tn);
if (tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) { if (tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) {
pos=tn->pos + tn->bits; pos = tn->pos + tn->bits;
n = tnode_get_child(tn, tkey_extract_bits(key, tn->pos, tn->bits)); n = tnode_get_child(tn, tkey_extract_bits(key, tn->pos, tn->bits));
} } else
else
break; break;
} }
/* Case we have found a leaf. Compare prefixes */ /* Case we have found a leaf. Compare prefixes */
if (n != NULL && IS_LEAF(n) && tkey_equals(key, n->key)) { if (n != NULL && IS_LEAF(n) && tkey_equals(key, n->key))
struct leaf *l = (struct leaf *) n; return (struct leaf *)n;
return l;
}
return NULL; return NULL;
} }
static struct node *trie_rebalance(struct trie *t, struct tnode *tn) static struct node *trie_rebalance(struct trie *t, struct tnode *tn)
{ {
int i = 0; int i;
int wasfull; int wasfull;
t_key cindex, key; t_key cindex, key;
struct tnode *tp = NULL; struct tnode *tp = NULL;
if (!tn) BUG_ON(!tn);
BUG();
key = tn->key; key = tn->key;
i = 0; i = 0;
while (tn != NULL && NODE_PARENT(tn) != NULL) { while (tn != NULL && NODE_PARENT(tn) != NULL) {
if (i > 10) { if (i > 10) {
printk("Rebalance tn=%p \n", tn); printk("Rebalance tn=%p \n", tn);
if (tn) printk("tn->parent=%p \n", NODE_PARENT(tn)); if (tn)
printk("tn->parent=%p \n", NODE_PARENT(tn));
printk("Rebalance tp=%p \n", tp); printk("Rebalance tp=%p \n", tp);
if (tp) printk("tp->parent=%p \n", NODE_PARENT(tp)); if (tp)
printk("tp->parent=%p \n", NODE_PARENT(tp));
} }
if (i > 12) BUG(); BUG_ON(i > 12); /* Why is this a bug? -ojn */
i++; i++;
tp = NODE_PARENT(tn); tp = NODE_PARENT(tn);
...@@ -1055,15 +1024,14 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen) ...@@ -1055,15 +1024,14 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
if (tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) { if (tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) {
tp = tn; tp = tn;
pos=tn->pos + tn->bits; pos = tn->pos + tn->bits;
n = tnode_get_child(tn, tkey_extract_bits(key, tn->pos, tn->bits)); n = tnode_get_child(tn, tkey_extract_bits(key, tn->pos, tn->bits));
if (n && NODE_PARENT(n) != tn) { if (n && NODE_PARENT(n) != tn) {
printk("BUG tn=%p, n->parent=%p\n", tn, NODE_PARENT(n)); printk("BUG tn=%p, n->parent=%p\n", tn, NODE_PARENT(n));
BUG(); BUG();
} }
} } else
else
break; break;
} }
...@@ -1073,14 +1041,12 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen) ...@@ -1073,14 +1041,12 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
* tp is n's (parent) ----> NULL or TNODE * tp is n's (parent) ----> NULL or TNODE
*/ */
if (tp && IS_LEAF(tp)) BUG_ON(tp && IS_LEAF(tp));
BUG();
/* Case 1: n is a leaf. Compare prefixes */ /* Case 1: n is a leaf. Compare prefixes */
if (n != NULL && IS_LEAF(n) && tkey_equals(key, n->key)) { if (n != NULL && IS_LEAF(n) && tkey_equals(key, n->key)) {
struct leaf *l = ( struct leaf *) n; struct leaf *l = (struct leaf *) n;
li = leaf_info_new(plen); li = leaf_info_new(plen);
...@@ -1113,35 +1079,31 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen) ...@@ -1113,35 +1079,31 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
fa_head = &li->falh; fa_head = &li->falh;
insert_leaf_info(&l->list, li); insert_leaf_info(&l->list, li);
/* Case 2: n is NULL, and will just insert a new leaf */
if (t->trie && n == NULL) { if (t->trie && n == NULL) {
/* Case 2: n is NULL, and will just insert a new leaf */
NODE_SET_PARENT(l, tp); NODE_SET_PARENT(l, tp);
if (!tp) BUG_ON(!tp);
BUG();
else {
cindex = tkey_extract_bits(key, tp->pos, tp->bits); cindex = tkey_extract_bits(key, tp->pos, tp->bits);
put_child(t, (struct tnode *)tp, cindex, (struct node *)l); put_child(t, (struct tnode *)tp, cindex, (struct node *)l);
} } else {
}
/* Case 3: n is a LEAF or a TNODE and the key doesn't match. */ /* Case 3: n is a LEAF or a TNODE and the key doesn't match. */
else {
/* /*
* Add a new tnode here * Add a new tnode here
* first tnode need some special handling * first tnode need some special handling
*/ */
if (tp) if (tp)
pos=tp->pos+tp->bits; pos = tp->pos+tp->bits;
else else
pos=0; pos = 0;
if (n) { if (n) {
newpos = tkey_mismatch(key, pos, n->key); newpos = tkey_mismatch(key, pos, n->key);
tn = tnode_new(n->key, newpos, 1); tn = tnode_new(n->key, newpos, 1);
} } else {
else {
newpos = 0; newpos = 0;
tn = tnode_new(key, newpos, 1); /* First tnode */ tn = tnode_new(key, newpos, 1); /* First tnode */
} }
...@@ -1155,28 +1117,28 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen) ...@@ -1155,28 +1117,28 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
NODE_SET_PARENT(tn, tp); NODE_SET_PARENT(tn, tp);
missbit=tkey_extract_bits(key, newpos, 1); missbit = tkey_extract_bits(key, newpos, 1);
put_child(t, tn, missbit, (struct node *)l); put_child(t, tn, missbit, (struct node *)l);
put_child(t, tn, 1-missbit, n); put_child(t, tn, 1-missbit, n);
if (tp) { if (tp) {
cindex = tkey_extract_bits(key, tp->pos, tp->bits); cindex = tkey_extract_bits(key, tp->pos, tp->bits);
put_child(t, (struct tnode *)tp, cindex, (struct node *)tn); put_child(t, (struct tnode *)tp, cindex, (struct node *)tn);
} } else {
else {
t->trie = (struct node*) tn; /* First tnode */ t->trie = (struct node*) tn; /* First tnode */
tp = tn; tp = tn;
} }
} }
if (tp && tp->pos+tp->bits > 32) {
if (tp && tp->pos + tp->bits > 32)
printk("ERROR tp=%p pos=%d, bits=%d, key=%0x plen=%d\n", printk("ERROR tp=%p pos=%d, bits=%d, key=%0x plen=%d\n",
tp, tp->pos, tp->bits, key, plen); tp, tp->pos, tp->bits, key, plen);
}
/* Rebalance the trie */ /* Rebalance the trie */
t->trie = trie_rebalance(t, tp); t->trie = trie_rebalance(t, tp);
done: done:
t->revision++; t->revision++;
err:; err:
return fa_head; return fa_head;
} }
...@@ -1204,17 +1166,18 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -1204,17 +1166,18 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
key = ntohl(key); key = ntohl(key);
if (trie_debug) DBG("Insert table=%d %08x/%d\n", tb->tb_id, key, plen);
printk("Insert table=%d %08x/%d\n", tb->tb_id, key, plen);
mask = ntohl( inet_make_mask(plen) ); mask = ntohl(inet_make_mask(plen));
if (key & ~mask) if (key & ~mask)
return -EINVAL; return -EINVAL;
key = key & mask; key = key & mask;
if ((fi = fib_create_info(r, rta, nlhdr, &err)) == NULL) fi = fib_create_info(r, rta, nlhdr, &err);
if (!fi)
goto err; goto err;
l = fib_find_node(t, key); l = fib_find_node(t, key);
...@@ -1236,8 +1199,7 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -1236,8 +1199,7 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
* and we need to allocate a new one of those as well. * and we need to allocate a new one of those as well.
*/ */
if (fa && if (fa && fa->fa_info->fib_priority == fi->fib_priority) {
fa->fa_info->fib_priority == fi->fib_priority) {
struct fib_alias *fa_orig; struct fib_alias *fa_orig;
err = -EEXIST; err = -EEXIST;
...@@ -1285,7 +1247,7 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -1285,7 +1247,7 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
fa = fa_orig; fa = fa_orig;
} }
err = -ENOENT; err = -ENOENT;
if (!(nlhdr->nlmsg_flags&NLM_F_CREATE)) if (!(nlhdr->nlmsg_flags & NLM_F_CREATE))
goto out; goto out;
err = -ENOBUFS; err = -ENOBUFS;
...@@ -1298,9 +1260,6 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -1298,9 +1260,6 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
new_fa->fa_type = type; new_fa->fa_type = type;
new_fa->fa_scope = r->rtm_scope; new_fa->fa_scope = r->rtm_scope;
new_fa->fa_state = 0; new_fa->fa_state = 0;
#if 0
new_fa->dst = NULL;
#endif
/* /*
* Insert new entry to the list. * Insert new entry to the list.
*/ */
...@@ -1314,8 +1273,7 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -1314,8 +1273,7 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
write_lock_bh(&fib_lock); write_lock_bh(&fib_lock);
list_add_tail(&new_fa->fa_list, list_add_tail(&new_fa->fa_list, (fa ? &fa->fa_list : fa_head));
(fa ? &fa->fa_list : fa_head));
write_unlock_bh(&fib_lock); write_unlock_bh(&fib_lock);
...@@ -1328,7 +1286,7 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -1328,7 +1286,7 @@ fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
kmem_cache_free(fn_alias_kmem, new_fa); kmem_cache_free(fn_alias_kmem, new_fa);
out: out:
fib_release_info(fi); fib_release_info(fi);
err:; err:
return err; return err;
} }
...@@ -1342,7 +1300,6 @@ static inline int check_leaf(struct trie *t, struct leaf *l, t_key key, int *pl ...@@ -1342,7 +1300,6 @@ static inline int check_leaf(struct trie *t, struct leaf *l, t_key key, int *pl
struct hlist_node *node; struct hlist_node *node;
hlist_for_each_entry(li, node, hhead, hlist) { hlist_for_each_entry(li, node, hhead, hlist) {
i = li->plen; i = li->plen;
mask = ntohl(inet_make_mask(i)); mask = ntohl(inet_make_mask(i));
if (l->key != (key & mask)) if (l->key != (key & mask))
...@@ -1370,13 +1327,18 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result ...@@ -1370,13 +1327,18 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
struct node *n; struct node *n;
struct tnode *pn; struct tnode *pn;
int pos, bits; int pos, bits;
t_key key=ntohl(flp->fl4_dst); t_key key = ntohl(flp->fl4_dst);
int chopped_off; int chopped_off;
t_key cindex = 0; t_key cindex = 0;
int current_prefix_length = KEYLENGTH; int current_prefix_length = KEYLENGTH;
struct tnode *cn;
t_key node_prefix, key_prefix, pref_mismatch;
int mp;
n = t->trie; n = t->trie;
read_lock(&fib_lock); read_lock(&fib_lock);
if (!n) if (!n)
goto failed; goto failed;
...@@ -1394,7 +1356,6 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result ...@@ -1394,7 +1356,6 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
chopped_off = 0; chopped_off = 0;
while (pn) { while (pn) {
pos = pn->pos; pos = pn->pos;
bits = pn->bits; bits = pn->bits;
...@@ -1410,12 +1371,16 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result ...@@ -1410,12 +1371,16 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
goto backtrace; goto backtrace;
} }
if (IS_TNODE(n)) { if (IS_LEAF(n)) {
if ((ret = check_leaf(t, (struct leaf *)n, key, &plen, flp, res)) <= 0)
goto found;
else
goto backtrace;
}
#define HL_OPTIMIZE #define HL_OPTIMIZE
#ifdef HL_OPTIMIZE #ifdef HL_OPTIMIZE
struct tnode *cn = (struct tnode *)n; cn = (struct tnode *)n;
t_key node_prefix, key_prefix, pref_mismatch;
int mp;
/* /*
* It's a tnode, and we can do some extra checks here if we * It's a tnode, and we can do some extra checks here if we
...@@ -1500,24 +1465,19 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result ...@@ -1500,24 +1465,19 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
goto backtrace; goto backtrace;
if (current_prefix_length >= cn->pos) if (current_prefix_length >= cn->pos)
current_prefix_length=mp; current_prefix_length = mp;
} }
#endif #endif
pn = (struct tnode *)n; /* Descend */ pn = (struct tnode *)n; /* Descend */
chopped_off = 0; chopped_off = 0;
continue; continue;
}
if (IS_LEAF(n)) {
if ((ret = check_leaf(t, (struct leaf *)n, key, &plen, flp, res)) <= 0)
goto found;
}
backtrace: backtrace:
chopped_off++; chopped_off++;
/* As zero don't change the child key (cindex) */ /* As zero don't change the child key (cindex) */
while ((chopped_off <= pn->bits) && !(cindex & (1<<(chopped_off-1)))) { while ((chopped_off <= pn->bits) && !(cindex & (1<<(chopped_off-1))))
chopped_off++; chopped_off++;
}
/* Decrease current_... with bits chopped off */ /* Decrease current_... with bits chopped off */
if (current_prefix_length > pn->pos + pn->bits - chopped_off) if (current_prefix_length > pn->pos + pn->bits - chopped_off)
...@@ -1528,9 +1488,9 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result ...@@ -1528,9 +1488,9 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
* chopped off all bits in this tnode walk up to our parent. * chopped off all bits in this tnode walk up to our parent.
*/ */
if (chopped_off <= pn->bits) if (chopped_off <= pn->bits) {
cindex &= ~(1 << (chopped_off-1)); cindex &= ~(1 << (chopped_off-1));
else { } else {
if (NODE_PARENT(pn) == NULL) if (NODE_PARENT(pn) == NULL)
goto failed; goto failed;
...@@ -1559,8 +1519,7 @@ static int trie_leaf_remove(struct trie *t, t_key key) ...@@ -1559,8 +1519,7 @@ static int trie_leaf_remove(struct trie *t, t_key key)
struct node *n = t->trie; struct node *n = t->trie;
struct leaf *l; struct leaf *l;
if (trie_debug) DBG("entering trie_leaf_remove(%p)\n", n);
printk("entering trie_leaf_remove(%p)\n", n);
/* Note that in the case skipped bits, those bits are *not* checked! /* Note that in the case skipped bits, those bits are *not* checked!
* When we finish this, we will have NULL or a T_LEAF, and the * When we finish this, we will have NULL or a T_LEAF, and the
...@@ -1597,8 +1556,7 @@ static int trie_leaf_remove(struct trie *t, t_key key) ...@@ -1597,8 +1556,7 @@ static int trie_leaf_remove(struct trie *t, t_key key)
cindex = tkey_extract_bits(key, tp->pos, tp->bits); cindex = tkey_extract_bits(key, tp->pos, tp->bits);
put_child(t, (struct tnode *)tp, cindex, NULL); put_child(t, (struct tnode *)tp, cindex, NULL);
t->trie = trie_rebalance(t, tp); t->trie = trie_rebalance(t, tp);
} } else
else
t->trie = NULL; t->trie = NULL;
return 1; return 1;
...@@ -1615,6 +1573,9 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -1615,6 +1573,9 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
struct fib_alias *fa, *fa_to_delete; struct fib_alias *fa, *fa_to_delete;
struct list_head *fa_head; struct list_head *fa_head;
struct leaf *l; struct leaf *l;
int kill_li = 0;
struct leaf_info *li;
if (plen > 32) if (plen > 32)
return -EINVAL; return -EINVAL;
...@@ -1624,7 +1585,7 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -1624,7 +1585,7 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
memcpy(&key, rta->rta_dst, 4); memcpy(&key, rta->rta_dst, 4);
key = ntohl(key); key = ntohl(key);
mask = ntohl( inet_make_mask(plen) ); mask = ntohl(inet_make_mask(plen));
if (key & ~mask) if (key & ~mask)
return -EINVAL; return -EINVAL;
...@@ -1641,8 +1602,7 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -1641,8 +1602,7 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
if (!fa) if (!fa)
return -ESRCH; return -ESRCH;
if (trie_debug) DBG("Deleting %08x/%d tos=%d t=%p\n", key, plen, tos, t);
printk("Deleting %08x/%d tos=%d t=%p\n", key, plen, tos, t);
fa_to_delete = NULL; fa_to_delete = NULL;
fa_head = fa->fa_list.prev; fa_head = fa->fa_list.prev;
...@@ -1664,9 +1624,8 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -1664,9 +1624,8 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
} }
} }
if (fa_to_delete) { if (!fa_to_delete)
int kill_li = 0; return -ESRCH;
struct leaf_info *li;
fa = fa_to_delete; fa = fa_to_delete;
rtmsg_fib(RTM_DELROUTE, htonl(key), fa, plen, tb->tb_id, nlhdr, req); rtmsg_fib(RTM_DELROUTE, htonl(key), fa, plen, tb->tb_id, nlhdr, req);
...@@ -1695,8 +1654,6 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta, ...@@ -1695,8 +1654,6 @@ fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
fn_free_alias(fa); fn_free_alias(fa);
return 0; return 0;
}
return -ESRCH;
} }
static int trie_flush_list(struct trie *t, struct list_head *head) static int trie_flush_list(struct trie *t, struct list_head *head)
...@@ -1708,7 +1665,6 @@ static int trie_flush_list(struct trie *t, struct list_head *head) ...@@ -1708,7 +1665,6 @@ static int trie_flush_list(struct trie *t, struct list_head *head)
struct fib_info *fi = fa->fa_info; struct fib_info *fi = fa->fa_info;
if (fi && (fi->fib_flags&RTNH_F_DEAD)) { if (fi && (fi->fib_flags&RTNH_F_DEAD)) {
write_lock_bh(&fib_lock); write_lock_bh(&fib_lock);
list_del(&fa->fa_list); list_del(&fa->fa_list);
write_unlock_bh(&fib_lock); write_unlock_bh(&fib_lock);
...@@ -1728,11 +1684,9 @@ static int trie_flush_leaf(struct trie *t, struct leaf *l) ...@@ -1728,11 +1684,9 @@ static int trie_flush_leaf(struct trie *t, struct leaf *l)
struct leaf_info *li = NULL; struct leaf_info *li = NULL;
hlist_for_each_entry_safe(li, node, tmp, lih, hlist) { hlist_for_each_entry_safe(li, node, tmp, lih, hlist) {
found += trie_flush_list(t, &li->falh); found += trie_flush_list(t, &li->falh);
if (list_empty(&li->falh)) { if (list_empty(&li->falh)) {
write_lock_bh(&fib_lock); write_lock_bh(&fib_lock);
hlist_del(&li->hlist); hlist_del(&li->hlist);
write_unlock_bh(&fib_lock); write_unlock_bh(&fib_lock);
...@@ -1757,8 +1711,7 @@ static struct leaf *nextleaf(struct trie *t, struct leaf *thisleaf) ...@@ -1757,8 +1711,7 @@ static struct leaf *nextleaf(struct trie *t, struct leaf *thisleaf)
return (struct leaf *) t->trie; return (struct leaf *) t->trie;
p = (struct tnode*) t->trie; /* Start */ p = (struct tnode*) t->trie; /* Start */
} } else
else
p = (struct tnode *) NODE_PARENT(c); p = (struct tnode *) NODE_PARENT(c);
while (p) { while (p) {
...@@ -1771,11 +1724,11 @@ static struct leaf *nextleaf(struct trie *t, struct leaf *thisleaf) ...@@ -1771,11 +1724,11 @@ static struct leaf *nextleaf(struct trie *t, struct leaf *thisleaf)
pos = 0; pos = 0;
last = 1 << p->bits; last = 1 << p->bits;
for(idx = pos; idx < last ; idx++) { for (idx = pos; idx < last ; idx++) {
if (p->child[idx]) { if (!p->child[idx])
continue;
/* Decend if tnode */ /* Decend if tnode */
while (IS_TNODE(p->child[idx])) { while (IS_TNODE(p->child[idx])) {
p = (struct tnode*) p->child[idx]; p = (struct tnode*) p->child[idx];
idx = 0; idx = 0;
...@@ -1785,15 +1738,14 @@ static struct leaf *nextleaf(struct trie *t, struct leaf *thisleaf) ...@@ -1785,15 +1738,14 @@ static struct leaf *nextleaf(struct trie *t, struct leaf *thisleaf)
while (p->child[idx] == NULL && idx < (1 << p->bits)) idx++; while (p->child[idx] == NULL && idx < (1 << p->bits)) idx++;
/* Done with this tnode? */ /* Done with this tnode? */
if (idx >= (1 << p->bits) || p->child[idx] == NULL ) if (idx >= (1 << p->bits) || p->child[idx] == NULL)
goto up; goto up;
} }
return (struct leaf*) p->child[idx]; return (struct leaf*) p->child[idx];
} }
}
up: up:
/* No more children go up one step */ /* No more children go up one step */
c = (struct node*) p; c = (struct node *) p;
p = (struct tnode *) NODE_PARENT(p); p = (struct tnode *) NODE_PARENT(p);
} }
return NULL; /* Ready. Root of trie */ return NULL; /* Ready. Root of trie */
...@@ -1807,7 +1759,7 @@ static int fn_trie_flush(struct fib_table *tb) ...@@ -1807,7 +1759,7 @@ static int fn_trie_flush(struct fib_table *tb)
t->revision++; t->revision++;
for (h=0; (l = nextleaf(t, l)) != NULL; h++) { for (h = 0; (l = nextleaf(t, l)) != NULL; h++) {
found += trie_flush_leaf(t, l); found += trie_flush_leaf(t, l);
if (ll && hlist_empty(&ll->list)) if (ll && hlist_empty(&ll->list))
...@@ -1818,12 +1770,11 @@ static int fn_trie_flush(struct fib_table *tb) ...@@ -1818,12 +1770,11 @@ static int fn_trie_flush(struct fib_table *tb)
if (ll && hlist_empty(&ll->list)) if (ll && hlist_empty(&ll->list))
trie_leaf_remove(t, ll->key); trie_leaf_remove(t, ll->key);
if (trie_debug) DBG("trie_flush found=%d\n", found);
printk("trie_flush found=%d\n", found);
return found; return found;
} }
static int trie_last_dflt=-1; static int trie_last_dflt = -1;
static void static void
fn_trie_select_default(struct fib_table *tb, const struct flowi *flp, struct fib_result *res) fn_trie_select_default(struct fib_table *tb, const struct flowi *flp, struct fib_result *res)
...@@ -1913,9 +1864,9 @@ static int fn_trie_dump_fa(t_key key, int plen, struct list_head *fah, struct fi ...@@ -1913,9 +1864,9 @@ static int fn_trie_dump_fa(t_key key, int plen, struct list_head *fah, struct fi
int i, s_i; int i, s_i;
struct fib_alias *fa; struct fib_alias *fa;
u32 xkey=htonl(key); u32 xkey = htonl(key);
s_i=cb->args[3]; s_i = cb->args[3];
i = 0; i = 0;
list_for_each_entry(fa, fah, fa_list) { list_for_each_entry(fa, fah, fa_list) {
...@@ -1949,7 +1900,7 @@ static int fn_trie_dump_fa(t_key key, int plen, struct list_head *fah, struct fi ...@@ -1949,7 +1900,7 @@ static int fn_trie_dump_fa(t_key key, int plen, struct list_head *fah, struct fi
} }
i++; i++;
} }
cb->args[3]=i; cb->args[3] = i;
return skb->len; return skb->len;
} }
...@@ -1959,10 +1910,10 @@ static int fn_trie_dump_plen(struct trie *t, int plen, struct fib_table *tb, str ...@@ -1959,10 +1910,10 @@ static int fn_trie_dump_plen(struct trie *t, int plen, struct fib_table *tb, str
int h, s_h; int h, s_h;
struct list_head *fa_head; struct list_head *fa_head;
struct leaf *l = NULL; struct leaf *l = NULL;
s_h=cb->args[2];
for (h=0; (l = nextleaf(t, l)) != NULL; h++) { s_h = cb->args[2];
for (h = 0; (l = nextleaf(t, l)) != NULL; h++) {
if (h < s_h) if (h < s_h)
continue; continue;
if (h > s_h) if (h > s_h)
...@@ -1978,11 +1929,11 @@ static int fn_trie_dump_plen(struct trie *t, int plen, struct fib_table *tb, str ...@@ -1978,11 +1929,11 @@ static int fn_trie_dump_plen(struct trie *t, int plen, struct fib_table *tb, str
continue; continue;
if (fn_trie_dump_fa(l->key, plen, fa_head, tb, skb, cb)<0) { if (fn_trie_dump_fa(l->key, plen, fa_head, tb, skb, cb)<0) {
cb->args[2]=h; cb->args[2] = h;
return -1; return -1;
} }
} }
cb->args[2]=h; cb->args[2] = h;
return skb->len; return skb->len;
} }
...@@ -1994,8 +1945,7 @@ static int fn_trie_dump(struct fib_table *tb, struct sk_buff *skb, struct netlin ...@@ -1994,8 +1945,7 @@ static int fn_trie_dump(struct fib_table *tb, struct sk_buff *skb, struct netlin
s_m = cb->args[1]; s_m = cb->args[1];
read_lock(&fib_lock); read_lock(&fib_lock);
for (m=0; m<=32; m++) { for (m = 0; m <= 32; m++) {
if (m < s_m) if (m < s_m)
continue; continue;
if (m > s_m) if (m > s_m)
...@@ -2010,7 +1960,7 @@ static int fn_trie_dump(struct fib_table *tb, struct sk_buff *skb, struct netlin ...@@ -2010,7 +1960,7 @@ static int fn_trie_dump(struct fib_table *tb, struct sk_buff *skb, struct netlin
read_unlock(&fib_lock); read_unlock(&fib_lock);
cb->args[1] = m; cb->args[1] = m;
return skb->len; return skb->len;
out: out:
read_unlock(&fib_lock); read_unlock(&fib_lock);
return -1; return -1;
} }
...@@ -2065,7 +2015,8 @@ struct fib_table * __init fib_hash_init(int id) ...@@ -2065,7 +2015,8 @@ struct fib_table * __init fib_hash_init(int id)
static void putspace_seq(struct seq_file *seq, int n) static void putspace_seq(struct seq_file *seq, int n)
{ {
while (n--) seq_printf(seq, " "); while (n--)
seq_printf(seq, " ");
} }
static void printbin_seq(struct seq_file *seq, unsigned int v, int bits) static void printbin_seq(struct seq_file *seq, unsigned int v, int bits)
...@@ -2086,27 +2037,20 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n, ...@@ -2086,27 +2037,20 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n,
seq_printf(seq, "%d/", cindex); seq_printf(seq, "%d/", cindex);
printbin_seq(seq, cindex, bits); printbin_seq(seq, cindex, bits);
seq_printf(seq, ": "); seq_printf(seq, ": ");
} } else
else
seq_printf(seq, "<root>: "); seq_printf(seq, "<root>: ");
seq_printf(seq, "%s:%p ", IS_LEAF(n)?"Leaf":"Internal node", n); seq_printf(seq, "%s:%p ", IS_LEAF(n)?"Leaf":"Internal node", n);
if (IS_LEAF(n))
seq_printf(seq, "key=%d.%d.%d.%d\n",
n->key >> 24, (n->key >> 16) % 256, (n->key >> 8) % 256, n->key % 256);
else {
int plen = ((struct tnode *)n)->pos;
t_key prf=MASK_PFX(n->key, plen);
seq_printf(seq, "key=%d.%d.%d.%d/%d\n",
prf >> 24, (prf >> 16) % 256, (prf >> 8) % 256, prf % 256, plen);
}
if (IS_LEAF(n)) { if (IS_LEAF(n)) {
struct leaf *l=(struct leaf *)n; struct leaf *l = (struct leaf *)n;
struct fib_alias *fa; struct fib_alias *fa;
int i; int i;
for (i=32; i>=0; i--)
if (find_leaf_info(&l->list, i)) {
seq_printf(seq, "key=%d.%d.%d.%d\n",
n->key >> 24, (n->key >> 16) % 256, (n->key >> 8) % 256, n->key % 256);
for (i = 32; i >= 0; i--)
if (find_leaf_info(&l->list, i)) {
struct list_head *fa_head = get_fa_head(l, i); struct list_head *fa_head = get_fa_head(l, i);
if (!fa_head) if (!fa_head)
...@@ -2118,17 +2062,16 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n, ...@@ -2118,17 +2062,16 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n,
putspace_seq(seq, indent+2); putspace_seq(seq, indent+2);
seq_printf(seq, "{/%d...dumping}\n", i); seq_printf(seq, "{/%d...dumping}\n", i);
list_for_each_entry(fa, fa_head, fa_list) { list_for_each_entry(fa, fa_head, fa_list) {
putspace_seq(seq, indent+2); putspace_seq(seq, indent+2);
if (fa->fa_info->fib_nh == NULL) {
seq_printf(seq, "Error _fib_nh=NULL\n");
continue;
}
if (fa->fa_info == NULL) { if (fa->fa_info == NULL) {
seq_printf(seq, "Error fa_info=NULL\n"); seq_printf(seq, "Error fa_info=NULL\n");
continue; continue;
} }
if (fa->fa_info->fib_nh == NULL) {
seq_printf(seq, "Error _fib_nh=NULL\n");
continue;
}
seq_printf(seq, "{type=%d scope=%d TOS=%d}\n", seq_printf(seq, "{type=%d scope=%d TOS=%d}\n",
fa->fa_type, fa->fa_type,
...@@ -2136,11 +2079,16 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n, ...@@ -2136,11 +2079,16 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n,
fa->fa_tos); fa->fa_tos);
} }
} }
} } else {
else if (IS_TNODE(n)) {
struct tnode *tn = (struct tnode *)n; struct tnode *tn = (struct tnode *)n;
int plen = ((struct tnode *)n)->pos;
t_key prf = MASK_PFX(n->key, plen);
seq_printf(seq, "key=%d.%d.%d.%d/%d\n",
prf >> 24, (prf >> 16) % 256, (prf >> 8) % 256, prf % 256, plen);
putspace_seq(seq, indent); seq_printf(seq, "| "); putspace_seq(seq, indent); seq_printf(seq, "| ");
seq_printf(seq, "{key prefix=%08x/", tn->key&TKEY_GET_MASK(0, tn->pos)); seq_printf(seq, "{key prefix=%08x/", tn->key & TKEY_GET_MASK(0, tn->pos));
printbin_seq(seq, tkey_extract_bits(tn->key, 0, tn->pos), tn->pos); printbin_seq(seq, tkey_extract_bits(tn->key, 0, tn->pos), tn->pos);
seq_printf(seq, "}\n"); seq_printf(seq, "}\n");
putspace_seq(seq, indent); seq_printf(seq, "| "); putspace_seq(seq, indent); seq_printf(seq, "| ");
...@@ -2155,18 +2103,31 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n, ...@@ -2155,18 +2103,31 @@ static void printnode_seq(struct seq_file *seq, int indent, struct node *n,
static void trie_dump_seq(struct seq_file *seq, struct trie *t) static void trie_dump_seq(struct seq_file *seq, struct trie *t)
{ {
struct node *n = t->trie; struct node *n = t->trie;
int cindex=0; int cindex = 0;
int indent=1; int indent = 1;
int pend=0; int pend = 0;
int depth = 0; int depth = 0;
struct tnode *tn;
read_lock(&fib_lock); read_lock(&fib_lock);
seq_printf(seq, "------ trie_dump of t=%p ------\n", t); seq_printf(seq, "------ trie_dump of t=%p ------\n", t);
if (n) {
if (!n) {
seq_printf(seq, "------ trie is empty\n");
read_unlock(&fib_lock);
return;
}
printnode_seq(seq, indent, n, pend, cindex, 0); printnode_seq(seq, indent, n, pend, cindex, 0);
if (IS_TNODE(n)) {
struct tnode *tn = (struct tnode *)n; if (!IS_TNODE(n)) {
read_unlock(&fib_lock);
return;
}
tn = (struct tnode *)n;
pend = tn->pos+tn->bits; pend = tn->pos+tn->bits;
putspace_seq(seq, indent); seq_printf(seq, "\\--\n"); putspace_seq(seq, indent); seq_printf(seq, "\\--\n");
indent += 3; indent += 3;
...@@ -2174,29 +2135,24 @@ static void trie_dump_seq(struct seq_file *seq, struct trie *t) ...@@ -2174,29 +2135,24 @@ static void trie_dump_seq(struct seq_file *seq, struct trie *t)
while (tn && cindex < (1 << tn->bits)) { while (tn && cindex < (1 << tn->bits)) {
if (tn->child[cindex]) { if (tn->child[cindex]) {
/* Got a child */ /* Got a child */
printnode_seq(seq, indent, tn->child[cindex], pend, cindex, tn->bits); printnode_seq(seq, indent, tn->child[cindex], pend, cindex, tn->bits);
if (IS_LEAF(tn->child[cindex])) { if (IS_LEAF(tn->child[cindex])) {
cindex++; cindex++;
} else {
}
else {
/* /*
* New tnode. Decend one level * New tnode. Decend one level
*/ */
depth++; depth++;
n = tn->child[cindex]; tn = (struct tnode *)tn->child[cindex];
tn = (struct tnode *)n; pend = tn->pos + tn->bits;
pend = tn->pos+tn->bits;
putspace_seq(seq, indent); seq_printf(seq, "\\--\n"); putspace_seq(seq, indent); seq_printf(seq, "\\--\n");
indent+=3; indent += 3;
cindex=0; cindex = 0;
}
} }
else } else
cindex++; cindex++;
/* /*
...@@ -2204,7 +2160,6 @@ static void trie_dump_seq(struct seq_file *seq, struct trie *t) ...@@ -2204,7 +2160,6 @@ static void trie_dump_seq(struct seq_file *seq, struct trie *t)
*/ */
while (cindex >= (1 << tn->bits)) { while (cindex >= (1 << tn->bits)) {
/* /*
* Move upwards and test for root * Move upwards and test for root
* pop off all traversed nodes * pop off all traversed nodes
...@@ -2212,43 +2167,39 @@ static void trie_dump_seq(struct seq_file *seq, struct trie *t) ...@@ -2212,43 +2167,39 @@ static void trie_dump_seq(struct seq_file *seq, struct trie *t)
if (NODE_PARENT(tn) == NULL) { if (NODE_PARENT(tn) == NULL) {
tn = NULL; tn = NULL;
n = NULL;
break; break;
} }
else {
cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits);
tn = NODE_PARENT(tn);
cindex++; cindex++;
n = (struct node *)tn; tn = NODE_PARENT(tn);
pend = tn->pos+tn->bits; pend = tn->pos + tn->bits;
indent-=3; indent -= 3;
depth--; depth--;
} }
} }
}
}
else n = NULL;
}
else seq_printf(seq, "------ trie is empty\n");
read_unlock(&fib_lock); read_unlock(&fib_lock);
} }
static struct trie_stat *trie_stat_new(void) static struct trie_stat *trie_stat_new(void)
{ {
struct trie_stat *s = kmalloc(sizeof(struct trie_stat), GFP_KERNEL); struct trie_stat *s;
int i; int i;
if (s) { s = kmalloc(sizeof(struct trie_stat), GFP_KERNEL);
if (!s)
return NULL;
s->totdepth = 0; s->totdepth = 0;
s->maxdepth = 0; s->maxdepth = 0;
s->tnodes = 0; s->tnodes = 0;
s->leaves = 0; s->leaves = 0;
s->nullpointers = 0; s->nullpointers = 0;
for(i=0; i< MAX_CHILDS; i++) for (i = 0; i < MAX_CHILDS; i++)
s->nodesizes[i] = 0; s->nodesizes[i] = 0;
}
return s; return s;
} }
...@@ -2257,18 +2208,19 @@ static struct trie_stat *trie_collect_stats(struct trie *t) ...@@ -2257,18 +2208,19 @@ static struct trie_stat *trie_collect_stats(struct trie *t)
struct node *n = t->trie; struct node *n = t->trie;
struct trie_stat *s = trie_stat_new(); struct trie_stat *s = trie_stat_new();
int cindex = 0; int cindex = 0;
int indent = 1;
int pend = 0; int pend = 0;
int depth = 0; int depth = 0;
if (!s)
return NULL;
if (!n)
return s;
read_lock(&fib_lock); read_lock(&fib_lock);
if (s) {
if (n) {
if (IS_TNODE(n)) { if (IS_TNODE(n)) {
struct tnode *tn = (struct tnode *)n; struct tnode *tn = (struct tnode *)n;
pend = tn->pos+tn->bits; pend = tn->pos+tn->bits;
indent += 3;
s->nodesizes[tn->bits]++; s->nodesizes[tn->bits]++;
depth++; depth++;
...@@ -2284,9 +2236,7 @@ static struct trie_stat *trie_collect_stats(struct trie *t) ...@@ -2284,9 +2236,7 @@ static struct trie_stat *trie_collect_stats(struct trie *t)
s->maxdepth = depth; s->maxdepth = depth;
s->totdepth += depth; s->totdepth += depth;
s->leaves++; s->leaves++;
} } else {
else {
/* /*
* New tnode. Decend one level * New tnode. Decend one level
*/ */
...@@ -2299,11 +2249,9 @@ static struct trie_stat *trie_collect_stats(struct trie *t) ...@@ -2299,11 +2249,9 @@ static struct trie_stat *trie_collect_stats(struct trie *t)
tn = (struct tnode *)n; tn = (struct tnode *)n;
pend = tn->pos+tn->bits; pend = tn->pos+tn->bits;
indent += 3;
cindex = 0; cindex = 0;
} }
} } else {
else {
cindex++; cindex++;
s->nullpointers++; s->nullpointers++;
} }
...@@ -2313,33 +2261,26 @@ static struct trie_stat *trie_collect_stats(struct trie *t) ...@@ -2313,33 +2261,26 @@ static struct trie_stat *trie_collect_stats(struct trie *t)
*/ */
while (cindex >= (1 << tn->bits)) { while (cindex >= (1 << tn->bits)) {
/* /*
* Move upwards and test for root * Move upwards and test for root
* pop off all traversed nodes * pop off all traversed nodes
*/ */
if (NODE_PARENT(tn) == NULL) { if (NODE_PARENT(tn) == NULL) {
tn = NULL; tn = NULL;
n = NULL; n = NULL;
break; break;
} }
else {
cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits); cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits);
tn = NODE_PARENT(tn); tn = NODE_PARENT(tn);
cindex++; cindex++;
n = (struct node *)tn; n = (struct node *)tn;
pend = tn->pos+tn->bits; pend = tn->pos+tn->bits;
indent -= 3;
depth--; depth--;
} }
} }
} }
}
else n = NULL;
}
}
read_unlock(&fib_lock); read_unlock(&fib_lock);
return s; return s;
...@@ -2359,17 +2300,22 @@ static struct fib_alias *fib_triestat_get_next(struct seq_file *seq) ...@@ -2359,17 +2300,22 @@ static struct fib_alias *fib_triestat_get_next(struct seq_file *seq)
static void *fib_triestat_seq_start(struct seq_file *seq, loff_t *pos) static void *fib_triestat_seq_start(struct seq_file *seq, loff_t *pos)
{ {
void *v = NULL; if (!ip_fib_main_table)
return NULL;
if (ip_fib_main_table) if (*pos)
v = *pos ? fib_triestat_get_next(seq) : SEQ_START_TOKEN; return fib_triestat_get_next(seq);
return v; else
return SEQ_START_TOKEN;
} }
static void *fib_triestat_seq_next(struct seq_file *seq, void *v, loff_t *pos) static void *fib_triestat_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{ {
++*pos; ++*pos;
return v == SEQ_START_TOKEN ? fib_triestat_get_first(seq) : fib_triestat_get_next(seq); if (v == SEQ_START_TOKEN)
return fib_triestat_get_first(seq);
else
return fib_triestat_get_next(seq);
} }
static void fib_triestat_seq_stop(struct seq_file *seq, void *v) static void fib_triestat_seq_stop(struct seq_file *seq, void *v)
...@@ -2393,15 +2339,15 @@ static void collect_and_show(struct trie *t, struct seq_file *seq) ...@@ -2393,15 +2339,15 @@ static void collect_and_show(struct trie *t, struct seq_file *seq)
stat = trie_collect_stats(t); stat = trie_collect_stats(t);
bytes=0; bytes = 0;
seq_printf(seq, "trie=%p\n", t); seq_printf(seq, "trie=%p\n", t);
if (stat) { if (stat) {
if (stat->leaves) if (stat->leaves)
avdepth=stat->totdepth*100 / stat->leaves; avdepth = stat->totdepth*100 / stat->leaves;
else else
avdepth=0; avdepth = 0;
seq_printf(seq, "Aver depth: %d.%02d\n", avdepth / 100, avdepth % 100 ); seq_printf(seq, "Aver depth: %d.%02d\n", avdepth / 100, avdepth % 100);
seq_printf(seq, "Max depth: %4d\n", stat->maxdepth); seq_printf(seq, "Max depth: %4d\n", stat->maxdepth);
seq_printf(seq, "Leaves: %d\n", stat->leaves); seq_printf(seq, "Leaves: %d\n", stat->leaves);
...@@ -2455,10 +2401,8 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v) ...@@ -2455,10 +2401,8 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v)
if (trie_main) if (trie_main)
collect_and_show(trie_main, seq); collect_and_show(trie_main, seq);
} } else {
else { snprintf(bf, sizeof(bf), "*\t%08X\t%08X", 200, 400);
snprintf(bf, sizeof(bf),
"*\t%08X\t%08X", 200, 400);
seq_printf(seq, "%-127s\n", bf); seq_printf(seq, "%-127s\n", bf);
} }
...@@ -2520,22 +2464,27 @@ static struct fib_alias *fib_trie_get_next(struct seq_file *seq) ...@@ -2520,22 +2464,27 @@ static struct fib_alias *fib_trie_get_next(struct seq_file *seq)
static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos) static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos)
{ {
void *v = NULL; if (!ip_fib_main_table)
return NULL;
if (ip_fib_main_table) if (*pos)
v = *pos ? fib_trie_get_next(seq) : SEQ_START_TOKEN; return fib_trie_get_next(seq);
return v; else
return SEQ_START_TOKEN;
} }
static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{ {
++*pos; ++*pos;
return v == SEQ_START_TOKEN ? fib_trie_get_first(seq) : fib_trie_get_next(seq); if (v == SEQ_START_TOKEN)
return fib_trie_get_first(seq);
else
return fib_trie_get_next(seq);
} }
static void fib_trie_seq_stop(struct seq_file *seq, void *v) static void fib_trie_seq_stop(struct seq_file *seq, void *v)
{ {
} }
/* /*
...@@ -2555,9 +2504,7 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v) ...@@ -2555,9 +2504,7 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
if (trie_main) if (trie_main)
trie_dump_seq(seq, trie_main); trie_dump_seq(seq, trie_main);
} } else {
else {
snprintf(bf, sizeof(bf), snprintf(bf, sizeof(bf),
"*\t%08X\t%08X", 200, 400); "*\t%08X\t%08X", 200, 400);
seq_printf(seq, "%-127s\n", bf); seq_printf(seq, "%-127s\n", bf);
......
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