[PATCH libnl v2 4/5] cache: add new NL_OBJ_DUMP cache flag (ce_flags)
David Ahern
dsa at cumulusnetworks.com
Sat Jun 18 15:30:08 PDT 2016
From: Roopa Prabhu <roopa at cumulusnetworks.com>
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 at cumulusnetworks.com>
---
include/netlink-private/types.h | 1 +
lib/cache.c | 18 +++++++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/include/netlink-private/types.h b/include/netlink-private/types.h
index 5da8f59..853f44c 100644
--- a/include/netlink-private/types.h
+++ b/include/netlink-private/types.h
@@ -113,6 +113,7 @@ struct nl_parser_param;
#define LOOSE_COMPARISON 1
#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 9b69fe8..960459d 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,
--
2.1.4
More information about the libnl
mailing list