open vswitch源代码解析(二)flow table解析函数入口ovs_flow_tbl_lookup_stats
2014-07-31 08:47
776 查看
flow table解析函数入口ovs_flow_tbl_lookup_stats
flow table解析函数ovs_flow_tbl_lookup_stats主要完成从flow table db中寻找可用于key的flow rule,其中用到了hash机制首先快速查找,如果miss再进行full lookup;
首先咱们注解一下hash查找的过程:
该代码片断即为hash查找的主要过程,
hash = flow_hash(&masked_key, key_start, key_end);
head = find_bucket(ti, hash);
(*n_mask_hit)++;
hlist_for_each_entry_rcu(flow, head, hash_node[ti->node_ver]) {
if (flow->mask == mask && flow->hash == hash &&
flow_cmp_masked_key(flow, &masked_key,
key_start, key_end))
return flow;
}
这部分代码还真他妈的不懂什么意思。
flow table解析函数ovs_flow_tbl_lookup_stats主要完成从flow table db中寻找可用于key的flow rule,其中用到了hash机制首先快速查找,如果miss再进行full lookup;
首先咱们注解一下hash查找的过程:
ce = NULL; entries = this_cpu_ptr(tbl->mask_cache); /* Find the cache entry 'ce' to operate on. */ for (seg = 0; seg < MC_HASH_SEGS; seg++) { int index = hash & (MC_HASH_ENTRIES - 1); struct mask_cache_entry *e; e = &entries[index]; if (e->skb_hash == skb_hash) { struct sw_flow_mask *cache; int i = e->mask_index; if (likely(i < ma->max)) { cache = rcu_dereference(ma->masks[i]); if (cache) { flow = masked_flow_lookup(ti, key, cache, n_mask_hit); /*cache contains avaliable sector to find all hit*/ if (flow) return flow; } } /* Cache miss. This is the best cache * replacement candidate. */ e->skb_hash = 0; ce = e; break; } if (!ce || e->skb_hash < ce->skb_hash) ce = e; /* A better replacement cache candidate. */ hash >>= MC_HASH_SHIFT; }
该代码片断即为hash查找的主要过程,
hash = flow_hash(&masked_key, key_start, key_end);
head = find_bucket(ti, hash);
(*n_mask_hit)++;
hlist_for_each_entry_rcu(flow, head, hash_node[ti->node_ver]) {
if (flow->mask == mask && flow->hash == hash &&
flow_cmp_masked_key(flow, &masked_key,
key_start, key_end))
return flow;
}
这部分代码还真他妈的不懂什么意思。
相关文章推荐
- open vswitch源代码解析(一)数据报解析总流程
- Open vSwitch(OvS)源代码之Linux RCU锁机制分析
- Open vSwitch(OvS)源代码分析之工作流程(flow流表查询)
- 在 Ubuntu 12.04 上通过源代码安装 Open vSwitch (OVS)
- Open vSwitch(OvS)源代码之Linux RCU锁机制分析
- HippCRM入口 index.php源代码解析
- open vswitch研究:ovs的安装和使用
- 全面解析Linux 内核 3.10.x - 内核入口函数__kernel_entry
- 1.2. chromium源代码分析 - chromiumframe - 入口函数
- 在 Ubuntu 12.04 上通过安装源安装 Open vSwitch (OVS)
- Open vSwitch框架解析
- 安装配置openstack 中的 Open vSwitch (OVS) service
- open vswitch研究:flow
- php源代码解析:引用与函数执行
- linux之open函数解析
- 在 Ubuntu 12.04 上通过安装源安装 Open vSwitch (OVS)
- 网页中先全部解析JavaScript,(若有事件/入口函数)再调用
- open vswitch研究:ovs的安装和使用
- CentOS6 rpm 安装Open vSwitch(OVS)报错
- 探索 OpenStack 之(7):Neutron 深入探索之 Open vSwitch (OVS) + GRE 之 Neutron节点篇