[PATCH 2/3] idiag: make object idiag_vegasinfo and idiag_meminfo comparable

Thomas Haller thaller at redhat.com
Thu Nov 27 04:09:04 PST 2014


Signed-off-by: Thomas Haller <thaller at redhat.com>
---
 lib/idiag/idiag_meminfo_obj.c   | 15 +++++++++++++++
 lib/idiag/idiag_vegasinfo_obj.c | 15 +++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/lib/idiag/idiag_meminfo_obj.c b/lib/idiag/idiag_meminfo_obj.c
index 7a044f4..f07800f 100644
--- a/lib/idiag/idiag_meminfo_obj.c
+++ b/lib/idiag/idiag_meminfo_obj.c
@@ -81,9 +81,24 @@ void idiagnl_meminfo_set_tmem(struct idiagnl_meminfo *minfo, uint32_t tmem)
 /** @} */
 
 /** @cond SKIP */
+static int idiagnl_meminfo_compare(struct nl_object *_a, struct nl_object *_b,
+                                     uint32_t attrs, int flags)
+{
+	struct idiagnl_meminfo *a = (struct idiagnl_meminfo *) _a;
+	struct idiagnl_meminfo *b = (struct idiagnl_meminfo *) _b;
+
+	/* meminfo is a very simple object. It has no attribe flags (ce_mask),
+	 * hence compare just returns 0 or 1, not a bit mask of attributes. */
+	return a->idiag_rmem != b->idiag_rmem ||
+	       a->idiag_wmem != b->idiag_wmem ||
+	       a->idiag_fmem != b->idiag_fmem ||
+	       a->idiag_tmem != b->idiag_tmem;
+}
+
 struct nl_object_ops idiagnl_meminfo_obj_ops = {
 	.oo_name	= "idiag/idiag_meminfo",
 	.oo_size	= sizeof(struct idiagnl_meminfo),
+	.oo_compare     = idiagnl_meminfo_compare,
 };
 /** @endcond */
 /** @} */
diff --git a/lib/idiag/idiag_vegasinfo_obj.c b/lib/idiag/idiag_vegasinfo_obj.c
index ffeb357..eddd8af 100644
--- a/lib/idiag/idiag_vegasinfo_obj.c
+++ b/lib/idiag/idiag_vegasinfo_obj.c
@@ -84,9 +84,24 @@ void idiagnl_vegasinfo_set_minrtt(struct idiagnl_vegasinfo *vinfo, uint32_t
 /** @} */
 
 /** @cond SKIP */
+static int idiagnl_vegasinfo_compare(struct nl_object *_a, struct nl_object *_b,
+                                     uint32_t attrs, int flags)
+{
+	struct idiagnl_vegasinfo *a = (struct idiagnl_vegasinfo *) _a;
+	struct idiagnl_vegasinfo *b = (struct idiagnl_vegasinfo *) _b;
+
+	/* vegasinfo is a very simple object. It has no attribe flags (ce_mask),
+	 * hence compare just returns 0 or 1, not a bit mask of attributes. */
+	return a->tcpv_enabled != b->tcpv_enabled ||
+	       a->tcpv_rttcnt != b->tcpv_rttcnt ||
+	       a->tcpv_rtt != b->tcpv_rtt ||
+	       a->tcpv_minrtt != b->tcpv_minrtt;
+}
+
 struct nl_object_ops idiagnl_vegasinfo_obj_ops = {
 	.oo_name	= "idiag/idiag_vegasinfo",
 	.oo_size	= sizeof(struct idiagnl_vegasinfo),
+	.oo_compare     = idiagnl_vegasinfo_compare,
 };
 /** @endcond */
 /** @} */
-- 
1.9.3




More information about the libnl mailing list