OvS: data structure analysis

hmap usage:

in include/openvswitch/shash.h, we have:

at first glance, it is a hmap encapsulated in shash.

In case we forget what is a hmap:

Obviously, it is the simplist hash map linked list. The mask means the max-hash value, the n means the total number of hashed members saved in hmap. Buckets[i] all have same hash value according to mask.

When we save key-value things, first put it in a shash_node, together with hmap_node inside it, push the hmap_node to the hmap hash linked list defined inside shash. When we search for search value of a key, gen key's hash and find in the hmap inside shash, get the hmap_node, CONTAINER_OF the hmap_node is the shash_node, then shash_node->name, shash_node->data is reachable.

posted on 2017-01-15 13:05  三叁  阅读(301)  评论(0编辑  收藏  举报

导航