struct fib_result *res)
{
struct fib_table *table;
table = fib_get_table(net, RT_TABLE_LOCAL); 先查LOCAL
if (!table-> tb_lookup(table, flp, res))
return 0;
table = fib_get_table(net, RT_TABLE_MAIN); 再查MAIN
if (!table-> tb_lookup(table, flp, res))
return 0;
return -ENETUNREACH;
}
{
struct hlist_head *ptr;
ptr = id == RT_TABLE_LOCAL ?
&net->ipv4.fib_table_hash[ TABLE_LOCAL_INDEX] :
&net->ipv4.fib_table_hash[ TABLE_MAIN_INDEX];
return hlist_entry(ptr->first, struct fib_table, tb_hlist); 根据传入的id找到fib_table
}
fn_hash_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result *res)
{
int err;
struct fn_zone *fz;
struct fn_hash *t = (struct fn_hash *)tb->tb_data; 获得路由区队列
read_lock(&fib_hash_lock);
for (fz = t->fn_zone_list; fz; fz = fz->fz_next) { 扫描网络区
struct hlist_head *head;
struct hlist_node *node;
struct fib_node *f;
__be32 k = fz_key(flp->fl4_dst, fz); 取目标地址在该网络区的网络号 fl4_det&((fz)->fz_mask)
head = &fz->fz_hash [fn_hash(k, fz)]; fn_hash(k, fz)得到hash关键字 获得hash链头
hlist_for_each_entry(f, node, head, fn_hash) {
if (f->fn_key != k) 通过fn_key找到匹配的fib node节点
continue;
err = fib_semantic_match(&f->fn_alias, 进入fib semantic查找
flp, res,
270



被折叠的 条评论
为什么被折叠?



