Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9929
  • 博文数量: 29
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 245
  • 用 户 组: 普通用户
  • 注册时间: 2018-03-29 14:38
文章分类
文章存档

2019年(29)

我的朋友

分类: LINUX

2019-09-21 15:17:49

fib_insert_node()信息插入debug(追的主表的ID为254(RT_TABLE_MAIN))
(Ubuntu 14.04 Desktop基于3.13.1 kernel添加debug信息)
code:(fib_trie.c)
fid_insert_node()
{
......
while (n != NULL &&  NODE_TYPE(n) == T_TNODE) {
tn = (struct tnode *) n;
printk("fib_insert_node 1054 n->key = %0x\n",n->key);
check_tnode(tn);

if (tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) {
tp = tn;
pos = tn->pos + tn->bits;
printk("fib_insert_node 1060 tn->pos = %d tn->key = %0x key = %0x,n->key = %0x\n",
                              tn->pos,tn->key,key,n->key);
n = tnode_get_child(tn,tkey_extract_bits(key,tn->pos,tn->bits));
printk("fib_insert_node 1065 key = %0x,n->key = %0x\n",key,n->key);
} else
break;
}
......
else {
/* Case 3: n is a LEAF or a TNODE and the key doesn't match. */
/*
*  Add a new tnode here
*  first tnode need some special handling
*/

if (n) {
pos = tp ? tp->pos+tp->bits : 0;
newpos = tkey_mismatch(key, pos, n->key);
tn = tnode_new(n->key, newpos, 1);
printk("fib_insert_node 1125 pos = %d,newpos = %d\nkey = %0x,
                      n->key = %0x\n",pos,newpos,key,n->key);
} else {
newpos = 0;
tn = tnode_new(key, newpos, 1); /* First tnode */
printk("fib_insert_node 1129 First tnode\n");
}


if (!tn) {
free_leaf_info(li);
free_leaf(l);
return NULL;
}

node_set_parent((struct rt_trie_node *)tn, tp);

missbit = tkey_extract_bits(key, newpos, 1);
put_child(tn, missbit, (struct rt_trie_node *)l);
put_child(tn, 1-missbit, n);
printk("fib_insert_node 1143 missbit = %d\n",missbit);
if (tp) {
cindex = tkey_extract_bits(key, tp->pos, tp->bits);
put_child(tp, cindex, (struct rt_trie_node *)tn);
printk("fib_insert_node 1147 cindex = %d,tp->key = %0x\n",cindex,tp->key);
} else {
rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn);
tp = tn;
printk("fib_insert_node 1151 First tnode\n");
}
}
......
}
1.BringUp
Main(fib_trie):
  +-- 0.0.0.0/4 1 0 0
     |-- 0.0.0.0
        /0 universe UNICAST
     |-- 10.139.68.0
        /24 link UNICAST

[   21.705079] Insert table=254 0a8b4400/24(First tnode 创建)
[   21.705088] fib_insert_node 1142 missbit = 0

[   21.712936] Insert table=254 00000000/0(First tnode 创建)
[   21.712954] fib_insert_node 1125 pos = 0,newpos = 4
[   21.712954] key = 0,n->key = a8b4400
[   21.712955] fib_insert_node 1142 missbit = 0

2.add 10.139.68.11
Main(fib_trie):
  +-- 0.0.0.0/4 1 0 0
     |-- 0.0.0.0
        /0 universe UNICAST
     +-- 10.139.68.0/28 1 0 0
        |-- 10.139.68.0
           /24 link UNICAST
        |-- 10.139.68.11
           /32 link UNICAST

[  193.720747] Insert table=254 0a8b440b/32
[  193.720763] fib_insert_node 1125 pos = 5,newpos = 28
[  193.720763] key = a8b440b,n->key = a8b4400
[  193.720764] fib_insert_node 1142 missbit = 1
[  193.720765] fib_insert_node 1146 cindex = 1,tp->key = a8b4400

3.add 10.139.70.1
Main(fib_trie):
  +-- 0.0.0.0/4 1 0 0
     |-- 0.0.0.0
        /0 universe UNICAST
     +-- 10.139.68.0/22 1 0 0
        +-- 10.139.68.0/28 1 0 0
           |-- 10.139.68.0
              /24 link UNICAST
           |-- 10.139.68.11
              /32 link UNICAST
        |-- 10.139.70.1
           /32 link UNICAST

[   89.082913] Insert table=254 0a8b4601/32
[   89.082923] fib_insert_node 1054 n->key = a8b4400
[   89.082924] fib_insert_node 1060 tn->pos = 4 tn->key = a8b4400 key = a8b4601,n->key = a8b4400
[   89.082925] fib_insert_node 1065 key = a8b4601,n->key = a8b4400
[   89.082926] fib_insert_node 1054 n->key = a8b4400
[   89.082927] fib_insert_node 1125 pos = 5,newpos = 22


4.add 10.139.70.11
Main(fib_trie):
  +-- 0.0.0.0/4 1 0 0
     |-- 0.0.0.0
        /0 universe UNICAST
     +-- 10.139.68.0/22 1 0 0
        +-- 10.139.68.0/28 1 0 0
           |-- 10.139.68.0
              /24 link UNICAST
           |-- 10.139.68.11
              /32 link UNICAST
        +-- 10.139.70.0/28 1 0 0
           |-- 10.139.70.1
              /32 link UNICAST
           |-- 10.139.70.11
              /32 link UNICAST

[  319.950946] Insert table=254 0a8b460b/32
[  319.950964] fib_insert_node 1125 pos = 23,newpos = 28
[  319.950964] key = a8b460b,n->key = a8b4601
[  319.950965] fib_insert_node 1142 missbit = 1
[  319.950966] fib_insert_node 1146 cindex = 1,tp->key = a8b4400

5.add 20.139.68.159
Main(fib_trie):
  +-- 0.0.0.0/3 2 0 1
     |-- 0.0.0.0
        /0 universe UNICAST
     +-- 10.139.68.0/22 1 0 0
        +-- 10.139.68.0/28 1 0 0
           |-- 10.139.68.0
              /24 link UNICAST
           |-- 10.139.68.11
              /32 link UNICAST
        +-- 10.139.70.0/28 1 0 0
           |-- 10.139.70.1
              /32 link UNICAST
           |-- 10.139.70.11
              /32 link UNICAST
     |-- 20.139.68.159
        /32 link UNICAST

[  431.659310] Insert table=254 148b449f/32(First tnode 创建)
[  431.659328] fib_insert_node 1125 pos = 0,newpos = 3
[  431.659328] key = 148b449f,n->key = a8b4400
[  431.659330] fib_insert_node 1142 missbit = 1

阅读(2303) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
请登录后评论。

登录 注册