Skip to content

Commit

Permalink
route/addr: consider CACHEINFO in addr_compare()/nl_object_diff()
Browse files Browse the repository at this point in the history
Indicate this change of behavior with the capability
NL_CAPABILITY_ROUTE_ADDR_COMPARE_CACHEINFO.

This is a behavioral change as we now consider an additional
field when comparing addresses.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
  • Loading branch information
thom311 committed Nov 27, 2014
1 parent b5a6d36 commit a60b3e4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions include/netlink/utils.h
Expand Up @@ -121,6 +121,14 @@ enum {
NL_CAPABILITY_ROUTE_LINK_GET_KERNEL_FAIL_OPNOTSUPP = 5,
#define NL_CAPABILITY_ROUTE_LINK_GET_KERNEL_FAIL_OPNOTSUPP NL_CAPABILITY_ROUTE_LINK_GET_KERNEL_FAIL_OPNOTSUPP

/**
* 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_ROUTE_ADDR_COMPARE_CACHEINFO = 6,
#define NL_CAPABILITY_ROUTE_ADDR_COMPARE_CACHEINFO NL_CAPABILITY_ROUTE_ADDR_COMPARE_CACHEINFO

__NL_CAPABILITY_MAX
#define NL_CAPABILITY_MAX (__NL_CAPABILITY_MAX - 1)
};
Expand Down
2 changes: 2 additions & 0 deletions lib/route/addr.c
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.c
Expand Up @@ -1149,7 +1149,7 @@ int nl_has_capability (int capability)
NL_CAPABILITY_ROUTE_LINK_CLS_ADD_ACT_OWN_REFERENCE,
NL_CAPABILITY_NL_CONNECT_RETRY_GENERATE_PORT_ON_ADDRINUSE,
NL_CAPABILITY_ROUTE_LINK_GET_KERNEL_FAIL_OPNOTSUPP,
0,
NL_CAPABILITY_ROUTE_ADDR_COMPARE_CACHEINFO,
0,
0),
#undef _NL_SET
Expand Down

0 comments on commit a60b3e4

Please sign in to comment.