Skip to content

Commit

Permalink
fib_trie: only calc for the un-first node
Browse files Browse the repository at this point in the history
This is a enhancement.

for the first node in fib_trie, newpos is 0, bit is 1.
Only for the leaf or node with unmatched key need calc pos.

Signed-off-by: baker.zhang <baker.kernel@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
baker.zhang authored and David S. Miller committed Oct 10, 2013
1 parent 5c70ef8 commit 4c60f1d
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions net/ipv4/fib_trie.c
Original file line number Diff line number Diff line change
Expand Up @@ -1117,12 +1117,8 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
* first tnode need some special handling
*/

if (tp)
pos = tp->pos+tp->bits;
else
pos = 0;

if (n) {
pos = tp ? tp->pos+tp->bits : 0;
newpos = tkey_mismatch(key, pos, n->key);
tn = tnode_new(n->key, newpos, 1);
} else {
Expand Down

0 comments on commit 4c60f1d

Please sign in to comment.