Skip to content

Commit b7e1b4a

Browse files
KanjiMonsterthom311
authored andcommitted
cache: add nl_cache_resync_v2()
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]> #420
1 parent 470c0a6 commit b7e1b4a

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

include/netlink/cache.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ extern int nl_cache_resync(struct nl_sock *,
8080
struct nl_cache *,
8181
change_func_t,
8282
void *);
83+
extern int nl_cache_resync_v2(struct nl_sock *,
84+
struct nl_cache *,
85+
change_func_v2_t,
86+
void *);
8387
extern int nl_cache_include(struct nl_cache *,
8488
struct nl_object *,
8589
change_func_t,

lib/cache.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,14 +902,16 @@ static int resync_cb(struct nl_object *c, struct nl_parser_param *p)
902902
ca->ca_change_data);
903903
}
904904

905-
int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
906-
change_func_t change_cb, void *data)
905+
static int cache_resync(struct nl_sock *sk, struct nl_cache *cache,
906+
change_func_t change_cb, change_func_v2_t change_cb_v2,
907+
void *data)
907908
{
908909
struct nl_object *obj, *next;
909910
struct nl_af_group *grp;
910911
struct nl_cache_assoc ca = {
911912
.ca_cache = cache,
912913
.ca_change = change_cb,
914+
.ca_change_v2 = change_cb_v2,
913915
.ca_change_data = data,
914916
};
915917
struct nl_parser_param p = {
@@ -954,6 +956,9 @@ int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
954956
nl_cache_remove(obj);
955957
if (change_cb)
956958
change_cb(cache, obj, NL_ACT_DEL, data);
959+
else if (change_cb_v2)
960+
change_cb_v2(cache, obj, NULL, 0, NL_ACT_DEL,
961+
data);
957962
nl_object_put(obj);
958963
}
959964
}
@@ -965,6 +970,18 @@ int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
965970
return err;
966971
}
967972

973+
int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
974+
change_func_t change_cb, void *data)
975+
{
976+
return cache_resync(sk, cache, change_cb, NULL, data);
977+
}
978+
979+
int nl_cache_resync_v2(struct nl_sock *sk, struct nl_cache *cache,
980+
change_func_v2_t change_cb_v2, void *data)
981+
{
982+
return cache_resync(sk, cache, NULL, change_cb_v2, data);
983+
}
984+
968985
/** @} */
969986

970987
/**

libnl-3.sym

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,8 @@ global:
385385
nla_get_uint;
386386
nla_put_uint;
387387
} libnl_3_10;
388+
389+
libnl_3_12 {
390+
global:
391+
nl_cache_resync_v2;
392+
} libnl_3_11;

0 commit comments

Comments
 (0)