libnl 3.7.0
Caching System

Related sections in the development guide: More...

Modules

 Cache
 
 Manager
 Manager keeping caches up to date automatically.
 

Cache Operations Sets

void nl_cache_ops_get (struct nl_cache_ops *ops)
 Increment reference counter. More...
 
void nl_cache_ops_put (struct nl_cache_ops *ops)
 Decrement reference counter. More...
 
struct nl_cache_ops * nl_cache_ops_lookup (const char *name)
 Lookup cache operations by name. More...
 
struct nl_cache_ops * nl_cache_ops_lookup_safe (const char *name)
 Lookup cache operations by name. More...
 
struct nl_cache_ops * nl_cache_ops_associate (int protocol, int msgtype)
 Associate protocol and message type to cache operations. More...
 
struct nl_cache_ops * nl_cache_ops_associate_safe (int protocol, int msgtype)
 Associate protocol and message type to cache operations. More...
 
struct nl_msgtype * nl_msgtype_lookup (struct nl_cache_ops *ops, int msgtype)
 Lookup message type cache association. More...
 
void nl_cache_ops_foreach (void(*cb)(struct nl_cache_ops *, void *), void *arg)
 Call a function for each registered cache operation. More...
 
void nl_cache_ops_set_flags (struct nl_cache_ops *ops, unsigned int flags)
 Set default flags for caches of this type. More...
 
int nl_cache_mngt_register (struct nl_cache_ops *ops)
 Register a set of cache operations. More...
 
int nl_cache_mngt_unregister (struct nl_cache_ops *ops)
 Unregister a set of cache operations. More...
 

Global Cache Provisioning/Requiring

void nl_cache_mngt_provide (struct nl_cache *cache)
 Provide a cache for global use. More...
 
void nl_cache_mngt_unprovide (struct nl_cache *cache)
 Unprovide a cache for global use. More...
 
struct nl_cache * __nl_cache_mngt_require (const char *name)
 
struct nl_cache * nl_cache_mngt_require (const char *name)
 Return cache previously provided via nl_cache_mngt_provide() More...
 
struct nl_cache * nl_cache_mngt_require_safe (const char *name)
 Return cache previously provided via nl_cache_mngt_provide() More...
 

Detailed Description

Related sections in the development guide:

Header

#include <netlink/cache.h>

Function Documentation

◆ nl_cache_ops_get()

void nl_cache_ops_get ( struct nl_cache_ops *  ops)

Increment reference counter.

Parameters
opsCache operations

Definition at line 50 of file cache_mngt.c.

Referenced by nl_cache_mngt_provide(), nl_cache_ops_associate_safe(), and nl_cache_ops_lookup_safe().

+ Here is the caller graph for this function:

◆ nl_cache_ops_put()

void nl_cache_ops_put ( struct nl_cache_ops *  ops)

Decrement reference counter.

Parameters
opsCache operations

Definition at line 59 of file cache_mngt.c.

Referenced by nl_cache_alloc_name(), nl_cache_mngr_add(), nl_cache_mngt_unprovide(), and nl_object_alloc_name().

+ Here is the caller graph for this function:

◆ nl_cache_ops_lookup()

struct nl_cache_ops * nl_cache_ops_lookup ( const char *  name)

Lookup cache operations by name.

Parameters
namename of the cache type
Attention
This function is not safe, it does not increment the reference counter. Please use nl_cache_ops_lookup_safe().
Returns
The cache operations or NULL if not found.

Definition at line 73 of file cache_mngt.c.

◆ nl_cache_ops_lookup_safe()

struct nl_cache_ops * nl_cache_ops_lookup_safe ( const char *  name)

Lookup cache operations by name.

Parameters
namename of the cache type
Note
The reference counter of the returned cache operation is incremented and must be decremented after use with nl_cache_ops_put().
Returns
The cache operations or NULL if not found.

Definition at line 93 of file cache_mngt.c.

References nl_cache_ops_get().

Referenced by nl_cache_alloc_name(), nl_cache_mngr_add(), and nl_object_alloc_name().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nl_cache_ops_associate()

struct nl_cache_ops * nl_cache_ops_associate ( int  protocol,
int  msgtype 
)

Associate protocol and message type to cache operations.

Parameters
protocolnetlink protocol
msgtypenetlink message type
Attention
This function is not safe, it does not increment the reference counter. Please use nl_cache_ops_associate_safe().
See also
nl_cache_ops_associate_safe()
Returns
The cache operations or NULL if no match found.

Definition at line 134 of file cache_mngt.c.

◆ nl_cache_ops_associate_safe()

struct nl_cache_ops * nl_cache_ops_associate_safe ( int  protocol,
int  msgtype 
)

Associate protocol and message type to cache operations.

Parameters
protocolnetlink protocol
msgtypenetlink message type

Searches the registered cache operations for a matching protocol and message type.

Note
The reference counter of the returned cache operation is incremented and must be decremented after use with nl_cache_ops_put().
Returns
The cache operations or NULL if no no match was found.

Definition at line 158 of file cache_mngt.c.

References nl_cache_ops_get().

+ Here is the call graph for this function:

◆ nl_msgtype_lookup()

struct nl_msgtype * nl_msgtype_lookup ( struct nl_cache_ops *  ops,
int  msgtype 
)

Lookup message type cache association.

Parameters
opscache operations
msgtypenetlink message type

Searches for a matching message type association ing the specified cache operations.

Attention
The guranteed lifetime of the returned message type is bound to the lifetime of the underlying cache operations.
Returns
A message type association or NULL.

Definition at line 183 of file cache_mngt.c.

◆ nl_cache_ops_foreach()

void nl_cache_ops_foreach ( void(*)(struct nl_cache_ops *, void *)  cb,
void *  arg 
)

Call a function for each registered cache operation.

Parameters
cbCallback function to be called
argUser specific argument.

Definition at line 212 of file cache_mngt.c.

◆ nl_cache_ops_set_flags()

void nl_cache_ops_set_flags ( struct nl_cache_ops *  ops,
unsigned int  flags 
)

Set default flags for caches of this type.

Parameters
opsCache ops
flagsFlags to set

The cache operation flags will be derived to all caches allocates based on this set of cache operations.

Definition at line 230 of file cache_mngt.c.

◆ nl_cache_mngt_register()

int nl_cache_mngt_register ( struct nl_cache_ops *  ops)

Register a set of cache operations.

Parameters
opscache operations

Called by users of caches to announce the avaibility of a certain cache type.

Returns
0 on success or a negative error code.

Definition at line 246 of file cache_mngt.c.

Referenced by genl_register().

+ Here is the caller graph for this function:

◆ nl_cache_mngt_unregister()

int nl_cache_mngt_unregister ( struct nl_cache_ops *  ops)

Unregister a set of cache operations.

Parameters
opscache operations

Called by users of caches to announce a set of cache operations is no longer available. The specified cache operations must have been registered previously using nl_cache_mngt_register()

Returns
0 on success or a negative error code

Definition at line 281 of file cache_mngt.c.

Referenced by genl_unregister().

+ Here is the caller graph for this function:

◆ nl_cache_mngt_provide()

void nl_cache_mngt_provide ( struct nl_cache *  cache)

Provide a cache for global use.

Parameters
cachecache to provide

Offers the specified cache to be used by other modules. Only one cache per type may be shared at a time, a previsouly provided caches will be overwritten.

Definition at line 326 of file cache_mngt.c.

References nl_cache_get(), and nl_cache_ops_get().

Referenced by nl_cache_mngr_add_cache().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nl_cache_mngt_unprovide()

void nl_cache_mngt_unprovide ( struct nl_cache *  cache)

Unprovide a cache for global use.

Parameters
cachecache to unprovide

Cancels the offer to use a cache globally. The cache will no longer be returned via lookups but may still be in use.

Definition at line 359 of file cache_mngt.c.

References nl_cache_free(), and nl_cache_ops_put().

Referenced by nl_cache_mngr_free().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __nl_cache_mngt_require()

struct nl_cache * __nl_cache_mngt_require ( const char *  name)

Definition at line 377 of file cache_mngt.c.

◆ nl_cache_mngt_require()

struct nl_cache * nl_cache_mngt_require ( const char *  name)

Return cache previously provided via nl_cache_mngt_provide()

Parameters
nameName of cache to lookup
Attention
This function is not safe, it does not increment the reference counter. Please use nl_cache_mngt_require_safe().
See also
nl_cache_mngt_require_safe()
Returns
Pointer to cache or NULL if none registered

Definition at line 402 of file cache_mngt.c.

Referenced by nl_cache_mngt_require_safe().

+ Here is the caller graph for this function:

◆ nl_cache_mngt_require_safe()

struct nl_cache * nl_cache_mngt_require_safe ( const char *  name)

Return cache previously provided via nl_cache_mngt_provide()

Parameters
nameName of cache to lookup
Note
The reference counter of the returned cache is incremented and must be decremented after use with nl_cache_put().
Returns
Pointer to cache or NULL if none registered

Definition at line 424 of file cache_mngt.c.

References nl_cache_get(), and nl_cache_mngt_require().

+ Here is the call graph for this function: