[PATCH 1/1] route/addr: consider CACHEINFO in addr_compare/nl_object_diff()
Thomas Haller
thaller at redhat.com
Thu Apr 3 09:00:17 PDT 2014
Indicate this change of behavior with the capability
NL_CAPABILITY_ADDR_COMPARE_CONSIDER_CACHEINFO.
Signed-off-by: Thomas Haller <thaller at redhat.com>
---
Was this left out on purpose? I think nl_object_diff() should
consider all attributes of the address.
Note that this is a behavioral change, still I think it's the
right thing to do.
include/netlink/utils.h | 8 ++++++++
lib/route/addr.c | 2 ++
lib/utils.c | 2 +-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/netlink/utils.h b/include/netlink/utils.h
index 2094bb4..627c757 100644
--- a/include/netlink/utils.h
+++ b/include/netlink/utils.h
@@ -90,6 +90,14 @@ enum {
NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE = 1,
#define NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE
+ /**
+ * Also consider the a_cacheinfo field (ADDR_ATTR_CACHEINFO) that contains the
+ * address timestamps and expiry when comparing struct rtnl_addr objects with
+ * nl_object_diff().
+ */
+ NL_CAPABILITY_ADDR_COMPARE_CONSIDER_CACHEINFO = 2,
+#define NL_CAPABILITY_ADDR_COMPARE_CONSIDER_CACHEINFO NL_CAPABILITY_ADDR_COMPARE_CONSIDER_CACHEINFO
+
__NL_CAPABILITY_MAX
#define NL_CAPABILITY_MAX (__NL_CAPABILITY_MAX - 1)
};
diff --git a/lib/route/addr.c b/lib/route/addr.c
index 97905f0..7726fb0 100644
--- a/lib/route/addr.c
+++ b/lib/route/addr.c
@@ -448,6 +448,8 @@ static int addr_compare(struct nl_object *_a, struct nl_object *_b,
b->a_multicast));
diff |= ADDR_DIFF(BROADCAST, nl_addr_cmp(a->a_bcast, b->a_bcast));
diff |= ADDR_DIFF(ANYCAST, nl_addr_cmp(a->a_anycast, b->a_anycast));
+ diff |= ADDR_DIFF(CACHEINFO, memcmp(&a->a_cacheinfo, &b->a_cacheinfo,
+ sizeof (a->a_cacheinfo)));
if (flags & LOOSE_COMPARISON)
diff |= ADDR_DIFF(FLAGS,
diff --git a/lib/utils.c b/lib/utils.c
index 49ff120..35b8375 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -1145,7 +1145,7 @@ int nl_has_capability (int capability)
_NL_SETV((i), 3, (v3)) | _NL_SETV((i), 7, (v7)) )
_NL_SET(0,
NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE,
- 0,
+ NL_CAPABILITY_ADDR_COMPARE_CONSIDER_CACHEINFO,
0,
0,
0,
--
1.9.0
More information about the libnl
mailing list