Skip to content

Commit

Permalink
cache: add nl_cache_resync_v2()
Browse files Browse the repository at this point in the history
When the include callback v2 support was added in 66d032a
("cache_mngr: add include callback v2"), resync_cb() was updated to
handle both old and v2 callbacks, but no actual nl_cache_resync_v2() was
added to make use of it.

Fix this by adding an appropriate implementation.

Signed-off-by: Jonas Gorski <[email protected]>
  • Loading branch information
KanjiMonster committed Feb 5, 2025
1 parent 470c0a6 commit 8db9926
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
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;

0 comments on commit 8db9926

Please sign in to comment.