linux释放缓存,linux路由内核实现分析(四)---路由缓存机制(3)

 2023-09-25 阅读 18 评论 0

摘要:在函数ip_rt_init( )中进行了rt_hash_bucket的初始化,代码如下: rt_hash_table = (struct rt_hash_bucket *) alloc_large_system_hash("IP route cache", sizeof(struct rt_hash_bucket), rhash_entries, (num_physpages >= 128 * 1024) ?

在函数ip_rt_init( )中进行了rt_hash_bucket的初始化,代码如下:

 rt_hash_table = (struct rt_hash_bucket *)

              alloc_large_system_hash("IP route cache",

                                   sizeof(struct rt_hash_bucket),

                                   rhash_entries,

                                   (num_physpages >= 128 * 1024) ?

                                   15 : 17,

                                   0,

                                   &rt_hash_log,

                                   &rt_hash_mask,

                                   0);

       memset(rt_hash_table, 0, (rt_hash_mask + 1) * sizeof(struct rt_hash_bucket));

      

使用alloc_large_system_hash函数初始化了一个哈希表

在该函数中还创建了slab句柄,用于存储具体的r_table项

ipv4_dst_ops.kmem_cachep =

                        kmem_cache_create("ip_dst_cache", sizeof(struct rtable), 0,

                              SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);

 

 

路由缓存查找过程

 

数据包进入网络层之后,第一个调用的函数是ip_  rcv函数,通过pskb_may_pull完成碎片重组之后还要进行一些有效性检查,最后调用

return NF_HOOK(PF_INET, NF_IP_PRE_ROUTING, skb, dev, NULL,

               ip_rcv_finish);

 

进入ip_rcv_finish函数,ip_rcv_finish函数开始就调用了ip_route_input以生成路由信息。

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/94604.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息