]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
idiag: make objects 'idiag_vegasinfo' and 'idiag_meminfo' comparable
authorThomas Haller <thaller@redhat.com>
Thu, 27 Nov 2014 12:09:04 +0000 (13:09 +0100)
committerThomas Haller <thaller@redhat.com>
Thu, 27 Nov 2014 15:55:15 +0000 (16:55 +0100)
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
lib/idiag/idiag_meminfo_obj.c
lib/idiag/idiag_vegasinfo_obj.c

index 7a044f437fee344fcd8d61d8b0e99b9f6aaa5d04..f07800fdb3c496ee24c7eef8a9e87119b4c39f1c 100644 (file)
@@ -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 */
 /** @} */
index ffeb35783d77f2d15c9926cfc82649a3a34d3697..eddd8af0e8503860436bb5908a7f67805fbde2ee 100644 (file)
@@ -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 */
 /** @} */