From d1c019024101687303eeed4c4e369a69ca90e739 Mon Sep 17 00:00:00 2001 From: David Ahern Date: Fri, 30 Oct 2015 15:08:39 -0700 Subject: [PATCH] route/link: add link info compare operation Signed-off-by: Balki Raman Signed-off-by: David Ahern Signed-off-by: Thomas Haller --- include/netlink-private/route/link/api.h | 6 ++++++ lib/route/link.c | 1 + lib/route/link/api.c | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/include/netlink-private/route/link/api.h b/include/netlink-private/route/link/api.h index bb98ccc..85f83f3 100644 --- a/include/netlink-private/route/link/api.h +++ b/include/netlink-private/route/link/api.h @@ -60,6 +60,10 @@ struct rtnl_link_info_ops * in either io_alloc() or io_parse(). */ void (*io_free)(struct rtnl_link *); + /** Called to compare link info parameters between two links. */ + int (*io_compare)(struct rtnl_link *, struct rtnl_link *, + uint32_t attrs, int flags); + struct nl_list_head io_list; }; @@ -145,6 +149,8 @@ extern int rtnl_link_af_unregister(struct rtnl_link_af_ops *); extern int rtnl_link_af_data_compare(struct rtnl_link *a, struct rtnl_link *b, int family); +extern int rtnl_link_info_data_compare(struct rtnl_link *a, + struct rtnl_link *b); #ifdef __cplusplus } diff --git a/lib/route/link.c b/lib/route/link.c index 8ef43b5..cfe3779 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -960,6 +960,7 @@ static int link_compare(struct nl_object *_a, struct nl_object *_b, goto protinfo_mismatch; } + diff |= LINK_DIFF(LINKINFO, rtnl_link_info_data_compare(a, b) != 0); out: return diff; diff --git a/lib/route/link/api.c b/lib/route/link/api.c index 6d1e12f..00893ad 100644 --- a/lib/route/link/api.c +++ b/lib/route/link/api.c @@ -391,6 +391,28 @@ out: return ret; } +/** + * Compare link info data + * @arg a Link object a + * @arg b Link object b + * + * This function will compare link_info data between two links + * a and b + * + * @return 0 if link_info data matches or is not present + * or != 0 if it mismatches. + */ +int rtnl_link_info_data_compare(struct rtnl_link *a, struct rtnl_link *b) +{ + if (a->l_info_ops != b->l_info_ops) + return ~0; + + if (!a->l_info_ops || !a->l_info_ops->io_compare) + return 0; + + return a->l_info_ops->io_compare(a, b, ~0, 0); +} + /** @} */ /** @} */ -- 2.40.0