|
Modules | |
| Cache Implementation | |
| Object | |
Access Functions | |
| int | nl_cache_nitems (struct nl_cache *cache) |
| Return the number of items in the cache. More... | |
| int | nl_cache_nitems_filter (struct nl_cache *cache, struct nl_object *filter) |
| Return the number of items matching a filter in the cache. More... | |
| int | nl_cache_is_empty (struct nl_cache *cache) |
| Returns true if the cache is empty. More... | |
| struct nl_cache_ops * | nl_cache_get_ops (struct nl_cache *cache) |
| Return the operations set of the cache. More... | |
| struct nl_object * | nl_cache_get_first (struct nl_cache *cache) |
| Return the first element in the cache. More... | |
| struct nl_object * | nl_cache_get_last (struct nl_cache *cache) |
| Return the last element in the cache. More... | |
| struct nl_object * | nl_cache_get_next (struct nl_object *obj) |
| Return the next element in the cache. More... | |
| struct nl_object * | nl_cache_get_prev (struct nl_object *obj) |
| Return the previous element in the cache. More... | |
Cache Creation/Deletion | |
| struct nl_cache * | nl_cache_alloc (struct nl_cache_ops *ops) |
| Allocate an empty cache. More... | |
| int | nl_cache_alloc_and_fill (struct nl_cache_ops *ops, struct nl_sock *sock, struct nl_cache **result) |
| int | nl_cache_alloc_name (const char *kind, struct nl_cache **result) |
| Allocate an empty cache based on type name. More... | |
| struct nl_cache * | nl_cache_subset (struct nl_cache *orig, struct nl_object *filter) |
| Allocate a new cache containing a subset of a cache. More... | |
| void | nl_cache_clear (struct nl_cache *cache) |
| Clear a cache. More... | |
| void | nl_cache_free (struct nl_cache *cache) |
| Free a cache. More... | |
Cache Modifications | |
| int | nl_cache_add (struct nl_cache *cache, struct nl_object *obj) |
| Add object to a cache. More... | |
| int | nl_cache_move (struct nl_cache *cache, struct nl_object *obj) |
| Move object from one cache to another. More... | |
| void | nl_cache_remove (struct nl_object *obj) |
| Removes an object from a cache. More... | |
| struct nl_object * | nl_cache_search (struct nl_cache *cache, struct nl_object *needle) |
| Search for an object in a cache. More... | |
Synchronization | |
| int | nl_cache_request_full_dump (struct nl_sock *sk, struct nl_cache *cache) |
| Request a full dump from the kernel to fill a cache. More... | |
| int | __cache_pickup (struct nl_sock *sk, struct nl_cache *cache, struct nl_parser_param *param) |
| int | nl_cache_pickup (struct nl_sock *sk, struct nl_cache *cache) |
| Pickup a netlink dump response and put it into a cache. More... | |
| int | nl_cache_include (struct nl_cache *cache, struct nl_object *obj, change_func_t change_cb) |
| int | nl_cache_resync (struct nl_sock *sk, struct nl_cache *cache, change_func_t change_cb) |
Parsing | |
| int | nl_cache_parse_and_add (struct nl_cache *cache, struct nl_msg *msg) |
| Parse a netlink message and add it to the cache. More... | |
| int | nl_cache_refill (struct nl_sock *sk, struct nl_cache *cache) |
| (Re)fill a cache with the contents in the kernel. More... | |
Utillities | |
| void | nl_cache_mark_all (struct nl_cache *cache) |
| Mark all objects in a cache. More... | |
Dumping | |
| void | nl_cache_dump (struct nl_cache *cache, struct nl_dump_params *params) |
| Dump all elements of a cache. More... | |
| 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). More... | |
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. More... | |
| 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). More... | |
References nl_cache::c_ops, nl_cb_clone(), NL_CB_CUSTOM, nl_cb_put(), nl_cb_set(), NL_CB_VALID, NL_DBG, nl_geterror(), nl_recvmsgs(), NLE_NOMEM, NULL, and nl_sock::s_cb.
Referenced by nl_cache_pickup(), and nl_cache_resync().


Add object to a cache.
Adds the given object to the specified cache. The object is cloned if it has been added to another cache already.
References nl_cache::c_ops, nl_cache_ops::co_obj_ops, nl_object_clone(), nl_object_get(), NLE_NOMEM, and NLE_OBJ_MISMATCH.
Referenced by nl_cache_subset().


| struct nl_cache* nl_cache_alloc | ( | struct nl_cache_ops * | ops | ) |
Allocate an empty cache.
References nl_cache::c_items, nl_cache::c_ops, NL_DBG, nl_init_list_head, and NULL.
Referenced by flnl_result_alloc_cache(), nfnl_nft_chain_alloc_cache(), nfnl_nft_rule_alloc_cache(), nfnl_nft_set_alloc_cache(), nfnl_nft_setelem_alloc_cache(), nfnl_nft_table_alloc_cache(), nl_cache_alloc_and_fill(), nl_cache_alloc_name(), nl_cache_mngr_add(), nl_cache_subset(), rtnl_class_alloc_cache(), rtnl_cls_alloc_cache(), rtnl_route_alloc_cache(), and rtnl_rule_alloc_cache().

| int nl_cache_alloc_and_fill | ( | struct nl_cache_ops * | ops, |
| struct nl_sock * | sock, | ||
| struct nl_cache ** | result | ||
| ) |
References nl_cache_alloc(), nl_cache_free(), nl_cache_refill(), and NLE_NOMEM.
Referenced by genl_ctrl_alloc_cache(), nfnl_ct_alloc_cache(), rtnl_addr_alloc_cache(), rtnl_link_alloc_cache(), rtnl_neigh_alloc_cache(), rtnl_neightbl_alloc_cache(), and rtnl_qdisc_alloc_cache().


Allocate an empty cache based on type name.
References nl_cache_alloc(), nl_cache_ops_lookup(), NLE_NOCACHE, and NLE_NOMEM.

Clear a cache.
Removes all elements of a cache.
References nl_cache::c_items, nl_cache_remove(), NL_DBG, and nl_list_for_each_entry_safe.
Referenced by nl_cache_free(), and nl_cache_refill().


| void nl_cache_dump | ( | struct nl_cache * | cache, |
| struct nl_dump_params * | params | ||
| ) |
Dump all elements of a cache.
Dumps all elements of the cache to the file descriptor fd.
References nl_cache_dump_filter(), and NULL.
Referenced by main().


| 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).
Dumps all elements of the cache to the file descriptor fd given they match the given filter filter.
References BUG, nl_cache::c_items, nl_cache::c_ops, nl_cache_ops::co_obj_ops, nl_dump_params::dp_type, dump_from_ops(), NL_DBG, NL_DUMP_DETAILS, NL_DUMP_MAX, nl_list_for_each_entry, nl_object_match_filter(), NULL, and nl_object_ops::oo_dump.
Referenced by main(), and 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.
Calls a callback function cb on each element of the cache. The argument arg is passed on the callback function.
References nl_cache_foreach_filter(), and NULL.
Referenced by main().


| 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).
Calls a callback function cb on each element of the cache that matches the filter. The argument arg is passed on to the callback function.
References BUG, nl_cache::c_items, nl_cache::c_ops, nl_cache_ops::co_obj_ops, nl_list_for_each_entry_safe, nl_object_match_filter(), and NULL.
Referenced by nl_cache_foreach().


Free a cache.
Removes all elements of a cache and frees all memory.
References nl_cache_clear(), and NL_DBG.
Referenced by genl_ctrl_resolve(), genl_mngt_resolve(), genl_ops_resolve(), main(), nl_cache_alloc_and_fill(), nl_cache_mngr_add(), nl_cache_mngr_free(), rtnl_class_alloc_cache(), and rtnl_cls_alloc_cache().


Return the first element in the cache.
References nl_cache::c_items, nl_list_head::next, nl_list_entry, and NULL.
Return the last element in the cache.
References nl_cache::c_items, nl_list_entry, NULL, and nl_list_head::prev.
Return the next element in the cache.
References nl_list_at_tail, nl_list_entry, and NULL.
| struct nl_cache_ops* nl_cache_get_ops | ( | struct nl_cache * | cache | ) |
Return the previous element in the cache.
References nl_list_at_head, nl_list_entry, and NULL.
| int nl_cache_include | ( | struct nl_cache * | cache, |
| struct nl_object * | obj, | ||
| change_func_t | change_cb | ||
| ) |
Returns true if the cache is empty.
References nl_cache::c_items.
Mark all objects in a cache.
References nl_cache::c_items, NL_DBG, nl_list_for_each_entry, and nl_object_mark().
Referenced by nl_cache_resync().


Move object from one cache to another.
Removes the given object from its associated cache if needed and adds it to the new cache.
References nl_cache::c_ops, nl_cache_ops::co_obj_ops, nl_cache_remove(), NL_DBG, nl_object_get(), and NLE_OBJ_MISMATCH.

Return the number of items matching a filter in the cache.
References BUG, nl_cache::c_items, nl_cache::c_ops, nl_cache_ops::co_obj_ops, nl_list_for_each_entry, nl_object_match_filter(), and NULL.

Parse a netlink message and add it to the cache.
Parses a netlink message by calling the cache specific message parser and adds the new element to the cache.
References nl_cache::c_ops, nl_cache_parse(), nlmsg_hdr(), NULL, and nl_parser_param::pp_cb.

Pickup a netlink dump response and put it into a cache.
Waits for netlink messages to arrive, parses them and puts them into the specified cache.
References __cache_pickup(), and nl_parser_param::pp_cb.
Referenced by flnl_lookup(), and nl_cache_refill().


(Re)fill a cache with the contents in the kernel.
Clears the specified cache and fills it with the current state in the kernel.
References nl_cache_clear(), nl_cache_pickup(), nl_cache_request_full_dump(), and NL_DBG.
Referenced by nfnl_nft_chain_alloc_cache(), nfnl_nft_rule_alloc_cache(), nfnl_nft_set_alloc_cache(), nfnl_nft_setelem_alloc_cache(), nfnl_nft_table_alloc_cache(), nl_cache_alloc_and_fill(), nl_cache_mngr_add(), rtnl_class_alloc_cache(), rtnl_cls_alloc_cache(), rtnl_route_alloc_cache(), and rtnl_rule_alloc_cache().


Removes an object from a cache.
Removes the object obj from the cache it is assigned to, since an object can only be assigned to one cache at a time, the cache must ne be passed along with it.
References nl_cache::c_nitems, NL_DBG, nl_object_put(), and NULL.
Referenced by nl_cache_clear(), nl_cache_move(), nl_cache_resync(), and nl_object_free().


Request a full dump from the kernel to fill a cache.
Send a dumping request to the kernel causing it to dump all objects related to the specified cache to the netlink socket.
Use nl_cache_pickup() to read the objects from the socket and fill them into a cache.
References nl_cache::c_ops, nl_cache_ops::co_request_update, NL_DBG, NLE_OPNOTSUPP, and NULL.
Referenced by nl_cache_refill(), and nl_cache_resync().

| int nl_cache_resync | ( | struct nl_sock * | sk, |
| struct nl_cache * | cache, | ||
| change_func_t | change_cb | ||
| ) |
References __cache_pickup(), nl_cache::c_items, nl_cache_assoc::ca_cache, NL_ACT_DEL, nl_cache_mark_all(), nl_cache_remove(), nl_cache_request_full_dump(), NL_DBG, nl_list_for_each_entry_safe, nl_object_get(), nl_object_is_marked(), nl_object_put(), and nl_parser_param::pp_cb.

Search for an object in a cache.
Iterates over the cache and looks for an object with identical identifiers as the needle.
References nl_cache::c_items, nl_list_for_each_entry, nl_object_get(), nl_object_identical(), and NULL.

Allocate a new cache containing a subset of a cache.
References BUG, nl_cache::c_items, nl_cache::c_ops, nl_cache_ops::co_obj_ops, nl_cache_add(), nl_cache_alloc(), nl_list_for_each_entry, nl_object_match_filter(), and NULL.
