Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache: add nl_cache_resync_v2() #420

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/netlink/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ extern int nl_cache_resync(struct nl_sock *,
struct nl_cache *,
change_func_t,
void *);
extern int nl_cache_resync_v2(struct nl_sock *,
struct nl_cache *,
change_func_v2_t,
void *);
extern int nl_cache_include(struct nl_cache *,
struct nl_object *,
change_func_t,
Expand Down
21 changes: 19 additions & 2 deletions lib/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,14 +902,16 @@ static int resync_cb(struct nl_object *c, struct nl_parser_param *p)
ca->ca_change_data);
}

int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
change_func_t change_cb, void *data)
static int cache_resync(struct nl_sock *sk, struct nl_cache *cache,
change_func_t change_cb, change_func_v2_t change_cb_v2,
void *data)
{
struct nl_object *obj, *next;
struct nl_af_group *grp;
struct nl_cache_assoc ca = {
.ca_cache = cache,
.ca_change = change_cb,
.ca_change_v2 = change_cb_v2,
.ca_change_data = data,
};
struct nl_parser_param p = {
Expand Down Expand Up @@ -954,6 +956,9 @@ int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
nl_cache_remove(obj);
if (change_cb)
change_cb(cache, obj, NL_ACT_DEL, data);
else if (change_cb_v2)
change_cb_v2(cache, obj, NULL, 0, NL_ACT_DEL,
data);
nl_object_put(obj);
}
}
Expand All @@ -965,6 +970,18 @@ int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
return err;
}

int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
change_func_t change_cb, void *data)
{
return cache_resync(sk, cache, change_cb, NULL, data);
}

int nl_cache_resync_v2(struct nl_sock *sk, struct nl_cache *cache,
change_func_v2_t change_cb_v2, void *data)
{
return cache_resync(sk, cache, NULL, change_cb_v2, data);
}

/** @} */

/**
Expand Down
5 changes: 5 additions & 0 deletions libnl-3.sym
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,8 @@ global:
nla_get_uint;
nla_put_uint;
} libnl_3_10;

libnl_3_12 {
global:
nl_cache_resync_v2;
} libnl_3_11;