summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Graf <tgraf@redhat.com>2012-04-21 15:48:37 +0200
committerThomas Graf <tgraf@redhat.com>2012-04-21 15:48:37 +0200
commit516536625fb6bd3b3d28cf4bc47b29e9b352cf30 (patch)
tree918e4318e22ee3761f57bf1435aca1547c69ed73
parent743756f3b4f634d0c08cb6e883428e63f8b28acc (diff)
downloadlibnl-516536625fb6bd3b3d28cf4bc47b29e9b352cf30.tar.gz
cache_mngr: Provide nl_cache_mngr_info() to pring cache manager details
Useful for debugging and testing
-rw-r--r--include/netlink/cache.h2
-rw-r--r--lib/cache_mngr.c42
2 files changed, 44 insertions, 0 deletions
diff --git a/include/netlink/cache.h b/include/netlink/cache.h
index e42f692..1e2bb9d 100644
--- a/include/netlink/cache.h
+++ b/include/netlink/cache.h
@@ -127,6 +127,8 @@ extern int nl_cache_mngr_get_fd(struct nl_cache_mngr *);
extern int nl_cache_mngr_poll(struct nl_cache_mngr *,
int);
extern int nl_cache_mngr_data_ready(struct nl_cache_mngr *);
+extern void nl_cache_mngr_info(struct nl_cache_mngr *,
+ struct nl_dump_params *);
extern void nl_cache_mngr_free(struct nl_cache_mngr *);
#ifdef __cplusplus
diff --git a/lib/cache_mngr.c b/lib/cache_mngr.c
index 9388f40..15b545d 100644
--- a/lib/cache_mngr.c
+++ b/lib/cache_mngr.c
@@ -368,6 +368,48 @@ int nl_cache_mngr_data_ready(struct nl_cache_mngr *mngr)
}
/**
+ * Print information about cache manager
+ * @arg mngr Cache manager
+ * @arg p Dumping parameters
+ *
+ * Prints information about the cache manager including all managed caches.
+ *
+ * @note This is a debugging function.
+ */
+void nl_cache_mngr_info(struct nl_cache_mngr *mngr, struct nl_dump_params *p)
+{
+ char buf[128];
+ int i;
+
+ nl_dump_line(p, "cache-manager <%p>\n", mngr);
+ nl_dump_line(p, " .protocol = %s\n",
+ nl_nlfamily2str(mngr->cm_protocol, buf, sizeof(buf)));
+ nl_dump_line(p, " .flags = %#x\n", mngr->cm_flags);
+ nl_dump_line(p, " .nassocs = %u\n", mngr->cm_nassocs);
+ nl_dump_line(p, " .sock = <%p>\n", mngr->cm_sock);
+
+ for (i = 0; i < mngr->cm_nassocs; i++) {
+ struct nl_cache_assoc *assoc = &mngr->cm_assocs[i];
+
+ if (assoc->ca_cache) {
+ nl_dump_line(p, " .cache[%d] = <%p> {\n", i, assoc->ca_cache);
+ nl_dump_line(p, " .name = %s\n", assoc->ca_cache->c_ops->co_name);
+ nl_dump_line(p, " .change_func = <%p>\n", assoc->ca_change);
+ nl_dump_line(p, " .change_data = <%p>\n", assoc->ca_change_data);
+ nl_dump_line(p, " .nitems = %u\n", nl_cache_nitems(assoc->ca_cache));
+ nl_dump_line(p, " .objects = {\n");
+
+ p->dp_prefix += 6;
+ nl_cache_dump(assoc->ca_cache, p);
+ p->dp_prefix -= 6;
+
+ nl_dump_line(p, " }\n");
+ nl_dump_line(p, " }\n");
+ }
+ }
+}
+
+/**
* Free cache manager and all caches.
* @arg mngr Cache manager.
*