summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopa Prabhu <roopa@cumulusnetworks.com>2016-06-18 22:30:08 (GMT)
committerThomas Haller <thaller@redhat.com>2016-07-08 10:02:07 (GMT)
commit6b15d040dcccf41d9686387fa6072f138e9c22e8 (patch)
treea86af50d1da21ccbb05a3be9c7d72470f6d61683
parente8abec0b4c6dcb2af752202fb022b89de0442234 (diff)
downloadlibnl-6b15d040dcccf41d9686387fa6072f138e9c22e8.zip
libnl-6b15d040dcccf41d9686387fa6072f138e9c22e8.tar.gz
libnl-6b15d040dcccf41d9686387fa6072f138e9c22e8.tar.bz2
cache: add new NL_OBJ_DUMP cache flag (ce_flags)
kernel does not include NLM_F_APPEND or NLM_F_REPLACE flags during dumps. This flag helps distinguish object cache inclusion due to netlink dumps from those resulting from netlink notifications. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
-rw-r--r--include/netlink-private/types.h1
-rw-r--r--lib/cache.c18
2 files changed, 16 insertions, 3 deletions
diff --git a/include/netlink-private/types.h b/include/netlink-private/types.h
index 0f67ddd..ad1a6d0 100644
--- a/include/netlink-private/types.h
+++ b/include/netlink-private/types.h
@@ -114,6 +114,7 @@ struct nl_parser_param;
#define ID_COMPARISON 2
#define NL_OBJ_MARK 1
+#define NL_OBJ_DUMP 2 /* object received due to a dump */
struct nl_data
{
diff --git a/lib/cache.c b/lib/cache.c
index 9aba0c9..ba5fa72 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -714,6 +714,7 @@ static int pickup_checkdup_cb(struct nl_object *c, struct nl_parser_param *p)
{
struct nl_cache *cache = (struct nl_cache *)p->pp_arg;
struct nl_object *old;
+ int ret;
old = nl_cache_search(cache, c);
if (old) {
@@ -726,7 +727,11 @@ static int pickup_checkdup_cb(struct nl_object *c, struct nl_parser_param *p)
nl_object_put(old);
}
- return nl_cache_add(cache, c);
+ c->ce_flags |= NL_OBJ_DUMP;
+ ret = nl_cache_add(cache, c);
+ c->ce_flags &= ~NL_OBJ_DUMP;
+
+ return ret;
}
static int pickup_cb(struct nl_object *c, struct nl_parser_param *p)
@@ -783,8 +788,10 @@ int nl_cache_pickup(struct nl_sock *sk, struct nl_cache *cache)
return __nl_cache_pickup(sk, cache, 0);
}
+
static int cache_include(struct nl_cache *cache, struct nl_object *obj,
- struct nl_msgtype *type, change_func_t cb, void *data)
+ struct nl_msgtype *type, change_func_t cb,
+ void *data)
{
struct nl_object *old;
@@ -856,8 +863,13 @@ int nl_cache_include(struct nl_cache *cache, struct nl_object *obj,
static int resync_cb(struct nl_object *c, struct nl_parser_param *p)
{
struct nl_cache_assoc *ca = p->pp_arg;
+ int ret;
+
+ c->ce_flags |= NL_OBJ_DUMP;
+ ret = nl_cache_include(ca->ca_cache, c, ca->ca_change, ca->ca_change_data);
+ c->ce_flags &= ~NL_OBJ_DUMP;
- return nl_cache_include(ca->ca_cache, c, ca->ca_change, ca->ca_change_data);
+ return ret;
}
int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,