Add support for per cache flags
This patch adds support for per cache flags and adds a flag NL_CACHE_AF_ITER to iter over all supported families when filling the cache. Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
parent
c83ecb38c1
commit
dd8a87da96
4 changed files with 31 additions and 0 deletions
|
@ -79,6 +79,7 @@ struct nl_cache
|
|||
int c_nitems;
|
||||
int c_iarg1;
|
||||
int c_iarg2;
|
||||
unsigned int c_flags;
|
||||
struct nl_hash_table * hashtable;
|
||||
struct nl_cache_ops * c_ops;
|
||||
};
|
||||
|
|
|
@ -168,6 +168,11 @@ struct nl_parser_param
|
|||
void * pp_arg;
|
||||
};
|
||||
|
||||
/**
|
||||
* Cache flags
|
||||
*/
|
||||
#define NL_CACHE_AF_ITER 0x0001
|
||||
|
||||
/**
|
||||
* Cache Operations
|
||||
*
|
||||
|
@ -189,6 +194,9 @@ struct nl_cache_ops
|
|||
/** cache object hash size **/
|
||||
int co_hash_size;
|
||||
|
||||
/** cache flags */
|
||||
unsigned int co_flags;
|
||||
|
||||
/** Group definition */
|
||||
struct nl_af_group * co_groups;
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ extern int nl_cache_include(struct nl_cache *,
|
|||
void *);
|
||||
extern void nl_cache_set_arg1(struct nl_cache *, int);
|
||||
extern void nl_cache_set_arg2(struct nl_cache *, int);
|
||||
extern void nl_cache_set_flags(struct nl_cache *, unsigned int);
|
||||
|
||||
/* General */
|
||||
extern int nl_cache_is_empty(struct nl_cache *);
|
||||
|
|
21
lib/cache.c
21
lib/cache.c
|
@ -190,6 +190,7 @@ struct nl_cache *nl_cache_alloc(struct nl_cache_ops *ops)
|
|||
|
||||
nl_init_list_head(&cache->c_items);
|
||||
cache->c_ops = ops;
|
||||
cache->c_flags |= ops->co_flags;
|
||||
|
||||
/*
|
||||
* If object type provides a hash keygen
|
||||
|
@ -565,6 +566,26 @@ void nl_cache_set_arg2(struct nl_cache *cache, int arg)
|
|||
cache->c_iarg2 = arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cache ops flags
|
||||
* @arg ops Cache ops
|
||||
* @arg arg flags
|
||||
*/
|
||||
void nl_cache_ops_set_flags(struct nl_cache_ops *ops, unsigned int flags)
|
||||
{
|
||||
ops->co_flags |= flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cache flags
|
||||
* @arg cache Cache
|
||||
* @arg arg flags
|
||||
*/
|
||||
void nl_cache_set_flags(struct nl_cache *cache, unsigned int flags)
|
||||
{
|
||||
cache->c_flags |= flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke the request-update operation
|
||||
* @arg sk Netlink socket.
|
||||
|
|
Loading…
Add table
Reference in a new issue