[PATCH 3/3] idiag: fix idiagnl_compare() to compare all attributes

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


This is not important for nl_object_identical() which only considers
the required attributes. But for using nl_object_diff() or nl_object_filter(),
all attributes must be compared.

Signed-off-by: Thomas Haller <thaller at redhat.com>
---
 lib/idiag/idiag_msg_obj.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/lib/idiag/idiag_msg_obj.c b/lib/idiag/idiag_msg_obj.c
index 6e4948e..07b7d00 100644
--- a/lib/idiag/idiag_msg_obj.c
+++ b/lib/idiag/idiag_msg_obj.c
@@ -861,10 +861,28 @@ static int idiagnl_compare(struct nl_object *_a, struct nl_object *_b,
 	int diff = 0;
 
 #define _DIFF(ATTR, EXPR) ATTR_DIFF(attrs, IDIAGNL_ATTR_##ATTR, a, b, EXPR)
-	diff |= _DIFF(FAMILY, a->idiag_family != b->idiag_family);
-	diff |= _DIFF(STATE,  a->idiag_state != b->idiag_state);
-	diff |= _DIFF(SPORT,  a->idiag_sport != b->idiag_sport);
-	diff |= _DIFF(DPORT,  a->idiag_dport != b->idiag_dport);
+	diff |= _DIFF(FAMILY,    a->idiag_family != b->idiag_family);
+	diff |= _DIFF(STATE,     a->idiag_state != b->idiag_state);
+	diff |= _DIFF(TIMER,     a->idiag_timer != b->idiag_timer);
+	diff |= _DIFF(RETRANS,   a->idiag_retrans != b->idiag_retrans);
+	diff |= _DIFF(SPORT,     a->idiag_sport != b->idiag_sport);
+	diff |= _DIFF(DPORT,     a->idiag_dport != b->idiag_dport);
+	diff |= _DIFF(SRC,       nl_addr_cmp (a->idiag_src, b->idiag_src));
+	diff |= _DIFF(DST,       nl_addr_cmp (a->idiag_dst, b->idiag_dst));
+	diff |= _DIFF(IFINDEX,   a->idiag_ifindex != b->idiag_ifindex);
+	diff |= _DIFF(EXPIRES,   a->idiag_expires != b->idiag_expires);
+	diff |= _DIFF(RQUEUE,    a->idiag_rqueue != b->idiag_rqueue);
+	diff |= _DIFF(WQUEUE,    a->idiag_wqueue != b->idiag_wqueue);
+	diff |= _DIFF(UID,       a->idiag_uid != b->idiag_uid);
+	diff |= _DIFF(INODE,     a->idiag_inode != b->idiag_inode);
+	diff |= _DIFF(TOS,       a->idiag_tos != b->idiag_tos);
+	diff |= _DIFF(TCLASS,    a->idiag_tclass != b->idiag_tclass);
+	diff |= _DIFF(SHUTDOWN,  a->idiag_shutdown != b->idiag_shutdown);
+	diff |= _DIFF(CONG,      strcmp(a->idiag_cong, b->idiag_cong));
+	diff |= _DIFF(MEMINFO,   nl_object_diff((struct nl_object *) a->idiag_meminfo, (struct nl_object *) b->idiag_meminfo));
+	diff |= _DIFF(VEGASINFO, nl_object_diff((struct nl_object *) a->idiag_vegasinfo, (struct nl_object *) b->idiag_vegasinfo));
+	diff |= _DIFF(TCPINFO,   memcmp(&a->idiag_tcpinfo, &b->idiag_tcpinfo, sizeof(a->idiag_tcpinfo)));
+	diff |= _DIFF(SKMEMINFO, memcmp(a->idiag_skmeminfo, b->idiag_skmeminfo, sizeof(a->idiag_skmeminfo)));
 #undef _DIFF
 	return diff;
 }
-- 
1.9.3




More information about the libnl mailing list