[PATCH 2/4] Add new rtnl_link_af_data_compare function to compare af_data

roopa at cumulusnetworks.com roopa at cumulusnetworks.com
Tue Jan 8 07:37:54 EST 2013


From: root <root at squeeze>

This patch adds a new function rtnl_linl_af_data_compare to
compare link af_data

Signed-off-by: Roopa Prabhu <roopa at cumulusnetworks.com>
---
 lib/route/link/api.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/lib/route/link/api.c b/lib/route/link/api.c
index a12eb09..0485aae 100644
--- a/lib/route/link/api.c
+++ b/lib/route/link/api.c
@@ -350,6 +350,34 @@ errout:
 	return err;
 }
 
+/**
+ * Compare af data for a link address family
+ * @arg a		Link object a
+ * @arg b		Link object b
+ * @arg family		Link address family
+ *
+ * This function will compare af_data between two links
+ * a and b of family given by arg family
+ *
+ * @return 0 on compare success or 1 on compare failure
+ */
+int rtnl_link_af_data_compare(struct rtnl_link *a, struct rtnl_link *b,
+			      int family, uint32_t attrs, int flags)
+{
+	struct rtnl_link_af_ops *af_ops = rtnl_link_af_ops_lookup(family);
+
+	if (!a->l_af_data[family] && !b->l_af_data[family])
+		return 0;
+
+	if (!a->l_af_data[family] || !b->l_af_data[family])
+		return ~0;
+
+	if (af_ops->ao_compare)
+		return af_ops->ao_compare(a, b, family, attrs, flags);
+
+	return 0;
+}
+
 /** @} */
 
 /** @} */
-- 
1.7.10.4




More information about the libnl mailing list