上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 70 下一页
摘要: 1、常用的时间存储方式 1)time_t类型,这本质上是一个长整数,表示从1970-01-01 00:00:00到目前计时时间的秒数,如果需要更精确一点的,可以使用timeval精确到毫秒。 2)tm结构,这本质上是一个结构体,里面包含了各时间字段 struct tm { int tm_sec; / 阅读全文
posted @ 2022-03-16 20:06 codestacklinuxer 阅读(88) 评论(0) 推荐(0)
摘要: 在内核中,顺序锁和读写锁比较相似,都是针对多读少写且快速处理的临界区的锁机制。 对于 rwlock 而言,rwlock的全称是"reader-writer spin lock",和普通的spinlock不同,它对"read"和"write"的操作进行了区分。如果当前没有writer,那么多个read 阅读全文
posted @ 2022-03-09 10:59 codestacklinuxer 阅读(40) 评论(0) 推荐(0)
摘要: 转载自: 理论 3.6版本内核移除了FIB查询前的路由缓存,取而代之的是下一跳缓存,这在路由缓存的前世今生 中已经说过了。本文要说的是在该版本中引入的另一个概念:FIB Nexthop Exception,用于记录下一跳的例外情形。 它有什么用呢? 内核通过查询转发信息表(fib_lookup),得 阅读全文
posted @ 2022-03-07 20:25 codestacklinuxer 阅读(46) 评论(0) 推荐(0)
摘要: 看下以前的文章首先说明一下 Routing与 Neighboring subsystem的关联 1、在路由过程中,需要寻找或创建 struct dst_entry (另一种形式是 struct rtable)。 dst_entry 通过neighbour 域与 struct neighbour 关联 阅读全文
posted @ 2022-03-07 18:48 codestacklinuxer 阅读(112) 评论(0) 推荐(0)
摘要: fib_table_lookup 可以参考:https://blog.csdn.net/shichaog/article/details/44658205 1405 int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp 阅读全文
posted @ 2022-03-07 12:10 codestacklinuxer 阅读(38) 评论(0) 推荐(0)
摘要: 3.6版本以前的路由缓存 缓存无处不在。现代计算机系统中,Cache是CPU与内存间存在一种容量较小但速度很高的存储器,用来存放CPU刚使用过或最近使用的数据。路由缓存就是基于这种思想的软件实现。内核查询FIB前,固定先查询cache中的记录,如果cache命中(hit),那就直接用就好了,不必查询 阅读全文
posted @ 2022-03-07 10:59 codestacklinuxer 阅读(92) 评论(0) 推荐(0)
摘要: /proc/net/stat/rt_cache /proc/net/rt_acct /proc/net/fib_triestat /proc/net/fib_trie ip route get xxxx(ip 地址) ip route list table (local main xxx) Scop 阅读全文
posted @ 2022-03-07 10:55 codestacklinuxer 阅读(113) 评论(0) 推荐(0)
摘要: 见之前的文章fib数据结构 路由fib创建 当通过netlink,操作类型为RTM_NEWROUTE时,调用inet_rtm_newroute函数添加路由。 功能:a)、将用户空间配置内容传过来 rtm_to_fib_config(保存路由表项的 ip 类型 tos 出接口 网关 metric 目的 阅读全文
posted @ 2022-03-05 12:58 codestacklinuxer 阅读(125) 评论(0) 推荐(0)
摘要: sock结构体中有两个成员缓存路由:sk_rx_dst缓存入口路由,sk_dst_cache缓存出口路由 skb结构体中的_skb_refdst在特定时刻仅缓存一种路由,防止反复查找 skb_dst_set需要在调用前增加引用计数(dst_clone);而skb_dst_set_noref不需要,其 阅读全文
posted @ 2022-03-05 12:58 codestacklinuxer 阅读(195) 评论(0) 推荐(0)
摘要: 规则的添加 在规则初始化时,会注册添加函数fib_nl_newrule rtnl_register(PF_UNSPEC, RTM_NEWRULE, fib_nl_newrule, NULL); 接下来,分析创建规则fib_nl_newrule函数功能: (1)根据应用层传递的协议类型,找到相应的fi 阅读全文
posted @ 2022-03-04 14:48 codestacklinuxer 阅读(69) 评论(0) 推荐(0)
上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 70 下一页