diff options
author | Thomas Haller <thaller@redhat.com> | 2014-11-27 12:09:04 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-11-27 15:55:15 (GMT) |
commit | f4020ebde5fe20790f20a5eb05bdca28c60c0ebb (patch) | |
tree | b70d40b937c543a637599f5e08a15e5a7f93ba80 | |
parent | 9d4bc0345a6ee350ed1493b932b19f5eb315a613 (diff) | |
download | libnl-f4020ebde5fe20790f20a5eb05bdca28c60c0ebb.zip libnl-f4020ebde5fe20790f20a5eb05bdca28c60c0ebb.tar.gz libnl-f4020ebde5fe20790f20a5eb05bdca28c60c0ebb.tar.bz2 |
idiag: make objects 'idiag_vegasinfo' and 'idiag_meminfo' comparable
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | lib/idiag/idiag_meminfo_obj.c | 15 | ||||
-rw-r--r-- | lib/idiag/idiag_vegasinfo_obj.c | 15 |
2 files changed, 30 insertions, 0 deletions
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 */ /** @} */ |