Cache Management | | Type Specific Cache Operations | | +----------------+ +------------+ | request update | | msg_parser | | | +----------------+ +------------+ +- - - - -^- - - - - - - -^- -|- - - - nl_cache_update: | | | | 1) --------- co_request_update ------+ | | | | | 2) destroy old cache +----------- pp_cb ---------|---+ | | | 3) ---------- nl_recvmsgs ----------+ +- cb_valid -+ +--------------+ | | | | | nl_cache_add |<-----+ + - - -v- -|- - - - - - - - - - - +--------------+ | | +-------------+ | nl_recvmsgs | | | +-----|-^-----+ +---v-|---+ | | | nl_recv | +---------+ | | Core Netlink
Modules | |
Cacheable Object | |
Access Functions | |
int | nl_cache_nitems (struct nl_cache *cache) |
Return the number of items in the cache. | |
int | nl_cache_nitems_filter (struct nl_cache *cache, struct nl_object *filter) |
Return the number of items matching a filter in the cache. | |
int | nl_cache_is_empty (struct nl_cache *cache) |
Returns true if the cache is empty. | |
nl_cache_ops * | nl_cache_get_ops (struct nl_cache *cache) |
Return the operations set of the cache. | |
nl_object * | nl_cache_get_first (struct nl_cache *cache) |
Return the first element in the cache. | |
nl_object * | nl_cache_get_last (struct nl_cache *cache) |
Return the last element in the cache. | |
nl_object * | nl_cache_get_next (struct nl_object *obj) |
Return the next element in the cache. | |
nl_object * | nl_cache_get_prev (struct nl_object *obj) |
Return the previous element in the cache. | |
Cache Creation/Deletion | |
nl_cache * | nl_cache_alloc (void) |
Allocate an empty cache of no certain type. | |
nl_cache * | nl_cache_alloc_from_ops (struct nl_cache_ops *ops) |
Allocate an empty cache based on cache operations. | |
nl_cache * | nl_cache_alloc_name (const char *kind) |
Allocate an empty cache based on type name. | |
void | nl_cache_clear (struct nl_cache *cache) |
Clear a cache. | |
void | nl_cache_free (struct nl_cache *cache) |
Free a cache. | |
Cache Modifications | |
int | nl_cache_add (struct nl_cache *cache, struct nl_object *obj) |
Add an element to the cache. | |
int | nl_cache_parse_and_add (struct nl_cache *cache, struct nl_msg *msg) |
Parse a netlink message and add it to the cache. | |
void | nl_cache_delete (struct nl_cache *cache, struct nl_object *obj) |
Delete an element from a cache. | |
int | nl_cache_pickup (struct nl_handle *handle, struct nl_cache *cache) |
Pickup a netlink dump response and put it into a cache. | |
int | nl_cache_update (struct nl_handle *handle, struct nl_cache *cache) |
Update (synchronize) a local cache with the kernel. | |
Dumping | |
void | nl_cache_dump (struct nl_cache *cache, struct nl_dump_params *params) |
Dump all elements of a cache. | |
void | nl_cache_dump_filter (struct nl_cache *cache, struct nl_dump_params *params, struct nl_object *filter) |
Dump all elements of a cache (filtered). | |
Iterators | |
void | nl_cache_foreach (struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg) |
Call a callback on each element of the cache. | |
void | nl_cache_foreach_filter (struct nl_cache *cache, struct nl_object *filter, void(*cb)(struct nl_object *, void *), void *arg) |
Call a callback on each element of the cache (filtered). |
int nl_cache_nitems | ( | struct nl_cache * | cache | ) |
int nl_cache_nitems_filter | ( | struct nl_cache * | cache, | |
struct nl_object * | filter | |||
) |
int nl_cache_is_empty | ( | struct nl_cache * | cache | ) |
struct nl_cache_ops* nl_cache_get_ops | ( | struct nl_cache * | cache | ) |
struct nl_object* nl_cache_get_first | ( | struct nl_cache * | cache | ) |
struct nl_object* nl_cache_get_last | ( | struct nl_cache * | cache | ) |
struct nl_object* nl_cache_get_next | ( | struct nl_object * | obj | ) |
struct nl_object* nl_cache_get_prev | ( | struct nl_object * | obj | ) |
struct nl_cache* nl_cache_alloc | ( | void | ) |
Allocate an empty cache of no certain type.
Definition at line 172 of file cache.c.
Referenced by nl_cache_alloc_from_ops().
struct nl_cache* nl_cache_alloc_from_ops | ( | struct nl_cache_ops * | ops | ) |
Allocate an empty cache based on cache operations.
ops | cache operations to base the cache on |
Definition at line 193 of file cache.c.
References nl_cache_alloc().
Referenced by flnl_result_alloc_cache(), nl_cache_alloc_name(), rtnl_addr_alloc_cache(), rtnl_class_alloc_cache(), rtnl_cls_alloc_cache(), rtnl_link_alloc_cache(), rtnl_neigh_alloc_cache(), rtnl_neightbl_alloc_cache(), rtnl_qdisc_alloc_cache(), rtnl_route_alloc_cache(), and rtnl_rule_alloc_cache_by_family().
struct nl_cache* nl_cache_alloc_name | ( | const char * | kind | ) |
Allocate an empty cache based on type name.
kind | Name of cache type |
Definition at line 211 of file cache.c.
References nl_cache_alloc_from_ops(), and nl_cache_mngt_lookup().
void nl_cache_clear | ( | struct nl_cache * | cache | ) |
Clear a cache.
cache | cache to clear |
Definition at line 230 of file cache.c.
References nl_cache_delete().
Referenced by nl_cache_free(), and nl_cache_update().
void nl_cache_free | ( | struct nl_cache * | cache | ) |
Free a cache.
cache | Cache to free. |
Definition at line 248 of file cache.c.
References nl_cache_clear().
Referenced by rtnl_addr_alloc_cache(), rtnl_class_alloc_cache(), rtnl_cls_alloc_cache(), rtnl_link_alloc_cache(), rtnl_neigh_alloc_cache(), rtnl_neightbl_alloc_cache(), and rtnl_qdisc_alloc_cache().
int nl_cache_add | ( | struct nl_cache * | cache, | |
struct nl_object * | obj | |||
) |
Add an element to the cache.
cache | cache to add a element to | |
obj | Common obj to be added to the cache |
obj
to the tail of the cache cache
and. The cache is enlarged as needed.
Definition at line 272 of file cache.c.
References nl_object_clone(), nl_object_put(), and nl_object_shared().
int nl_cache_parse_and_add | ( | struct nl_cache * | cache, | |
struct nl_msg * | msg | |||
) |
Parse a netlink message and add it to the cache.
cache | cache to add element to | |
msg | netlink message |
Definition at line 336 of file cache.c.
References nlmsg_hdr().
void nl_cache_delete | ( | struct nl_cache * | cache, | |
struct nl_object * | obj | |||
) |
Delete an element from a cache.
cache | cache to delete the element from | |
obj | Object to delete |
obj
from the cache cache
.
Definition at line 353 of file cache.c.
References nl_object_put().
Referenced by nl_cache_clear().
int nl_cache_pickup | ( | struct nl_handle * | handle, | |
struct nl_cache * | cache | |||
) |
Pickup a netlink dump response and put it into a cache.
handle | Netlink handle. | |
cache | Cache to put items into. |
Definition at line 391 of file cache.c.
References nl_cb_clone(), NL_CB_CUSTOM, nl_cb_destroy(), nl_cb_set(), NL_CB_VALID, nl_geterror(), nl_handle_get_cb(), and nl_recvmsgs().
Referenced by flnl_lookup(), and nl_cache_update().
int nl_cache_update | ( | struct nl_handle * | handle, | |
struct nl_cache * | cache | |||
) |
Update (synchronize) a local cache with the kernel.
handle | netlink handle | |
cache | cache to update |
cache
with the state in the kernel. During this process the cache gets emptied and refilled with the new content received from the kernel.
Definition at line 432 of file cache.c.
References nl_cache_clear(), and nl_cache_pickup().
Referenced by rtnl_addr_alloc_cache(), rtnl_class_alloc_cache(), rtnl_cls_alloc_cache(), rtnl_link_alloc_cache(), rtnl_neigh_alloc_cache(), rtnl_neightbl_alloc_cache(), rtnl_qdisc_alloc_cache(), rtnl_route_alloc_cache(), and rtnl_rule_alloc_cache_by_family().
void nl_cache_dump | ( | struct nl_cache * | cache, | |
struct nl_dump_params * | params | |||
) |
Dump all elements of a cache.
cache | cache to dump | |
params | dumping parameters |
Definition at line 462 of file cache.c.
References nl_cache_dump_filter().
void nl_cache_dump_filter | ( | struct nl_cache * | cache, | |
struct nl_dump_params * | params, | |||
struct nl_object * | filter | |||
) |
Dump all elements of a cache (filtered).
cache | cache to dump | |
params | dumping parameters (optional) | |
filter | filter object |
Definition at line 477 of file cache.c.
References nl_dump_params::dp_type, and NL_DUMP_FULL.
Referenced by nl_cache_dump().
void nl_cache_foreach | ( | struct nl_cache * | cache, | |
void(*)(struct nl_object *, void *) | cb, | |||
void * | arg | |||
) |
Call a callback on each element of the cache.
cache | cache to iterate on | |
cb | callback function | |
arg | argument passed to callback function |
Definition at line 518 of file cache.c.
References nl_cache_foreach_filter().
void nl_cache_foreach_filter | ( | struct nl_cache * | cache, | |
struct nl_object * | filter, | |||
void(*)(struct nl_object *, void *) | cb, | |||
void * | arg | |||
) |
Call a callback on each element of the cache (filtered).
cache | cache to iterate on | |
filter | filter object | |
cb | callback function | |
arg | argument passed to callback function |
Definition at line 535 of file cache.c.
Referenced by nl_cache_foreach(), rtnl_class_foreach_child(), rtnl_class_foreach_cls(), rtnl_qdisc_foreach_child(), and rtnl_qdisc_foreach_cls().