diff options
author | David Ahern <dsa@cumulusnetworks.com> | 2015-12-18 17:50:03 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-02-12 17:09:04 (GMT) |
commit | a09b8558148b31e469d463907d103fa78d81612c (patch) | |
tree | 0ecd7ff2d09af28256b69d612beea3f0a6aff3ca /lib/object.c | |
parent | 58396ae2ae7c91fb95d1de9654be5b12fd2343d2 (diff) | |
download | libnl-a09b8558148b31e469d463907d103fa78d81612c.zip libnl-a09b8558148b31e469d463907d103fa78d81612c.tar.gz libnl-a09b8558148b31e469d463907d103fa78d81612c.tar.bz2 |
lib: update ce-mask to uint64_t
lib/route/link.c already defines 32 attributes which fills the current
uint32_t used for ce_mask. To accommodate more attributes the mask needs
to be expanded. This patch updates the definition to uint64_t.
The nl_object_diff API is maintained for ABI with existing users. A new
nl_object_diff64 API is added for the expanded attribute list. The MSB
of the 32-bit API is used to indicate if higher order attributes had a
mismatch. (Suggested by Thomas).
Note that LINK_ATTR_LINK_NETNSID changes. But since the attribute flags
are not public API it shouldn't be a problem.
http://lists.infradead.org/pipermail/libnl/2015-December/002078.html
http://lists.infradead.org/pipermail/libnl/2015-December/002083.html
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/object.c')
-rw-r--r-- | lib/object.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/object.c b/lib/object.c index cad24e0..a88ac00 100644 --- a/lib/object.c +++ b/lib/object.c @@ -358,17 +358,42 @@ int nl_object_identical(struct nl_object *a, struct nl_object *b) * * @return Bitmask describing differences or 0 if they are completely identical. */ -uint32_t nl_object_diff(struct nl_object *a, struct nl_object *b) +uint64_t nl_object_diff64(struct nl_object *a, struct nl_object *b) { struct nl_object_ops *ops = obj_ops(a); if (ops != obj_ops(b) || ops->oo_compare == NULL) - return UINT32_MAX; + return UINT64_MAX; return ops->oo_compare(a, b, ~0, 0); } /** + * Compute 32-bit bitmask representing difference in attribute values + * @arg a an object + * @arg b another object of same type + * + * The bitmask returned is specific to an object type, each bit set represents + * an attribute which mismatches in either of the two objects. Unavailability + * of an attribute in one object and presence in the other is regarded a + * mismatch as well. + * + * @return Bitmask describing differences or 0 if they are completely identical. + * 32nd bit indicates if higher bits from the 64-bit compare were + * different. + */ +uint32_t nl_object_diff(struct nl_object *a, struct nl_object *b) +{ + uint64_t diff; + + diff = nl_object_diff64(a, b); + + return (diff & ~((uint64_t) 0xFFFFFFFF)) + ? (uint32_t) diff | (1 << 31) + : (uint32_t) diff; +} + +/** * Match a filter against an object * @arg obj object to check * @arg filter object of same type acting as filter |