Skip to content

Commit 4c60f1d

Browse files
baker.zhangdavem330
authored andcommitted
fib_trie: only calc for the un-first node
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>
1 parent 5c70ef8 commit 4c60f1d

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

net/ipv4/fib_trie.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,12 +1117,8 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
11171117
* first tnode need some special handling
11181118
*/
11191119

1120-
if (tp)
1121-
pos = tp->pos+tp->bits;
1122-
else
1123-
pos = 0;
1124-
11251120
if (n) {
1121+
pos = tp ? tp->pos+tp->bits : 0;
11261122
newpos = tkey_mismatch(key, pos, n->key);
11271123
tn = tnode_new(n->key, newpos, 1);
11281124
} else {

0 commit comments

Comments
 (0)