diff options
author | David Ahern <dsa@cumulusnetworks.com> | 2015-10-30 22:08:41 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-11-20 10:25:34 (GMT) |
commit | 4b205cab171a45180ad33c5e5aeff0987cdfd370 (patch) | |
tree | 01dda0b56e7a9a179a403d444109d3666428d632 | |
parent | 45556c7abd3813ddea7b5784d62edfa16e8746ff (diff) | |
download | libnl-4b205cab171a45180ad33c5e5aeff0987cdfd370.zip libnl-4b205cab171a45180ad33c5e5aeff0987cdfd370.tar.gz libnl-4b205cab171a45180ad33c5e5aeff0987cdfd370.tar.bz2 |
route/link/vxlan: add support for link_info compare
Signed-off-by: Balki Raman <ramanb@cumulusnetworks.com>
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
[thaller@redhat.com: whitespace, add capability, consider local6/group6]
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | include/netlink/utils.h | 6 | ||||
-rw-r--r-- | lib/route/link/vxlan.c | 29 | ||||
-rw-r--r-- | lib/utils.c | 2 |
3 files changed, 36 insertions, 1 deletions
diff --git a/include/netlink/utils.h b/include/netlink/utils.h index babe1b2..72a98f4 100644 --- a/include/netlink/utils.h +++ b/include/netlink/utils.h @@ -185,6 +185,12 @@ enum { NL_CAPABILITY_RTNL_LINK_VLAN_INGRESS_MAP_CLEAR = 14, #define NL_CAPABILITY_RTNL_LINK_VLAN_INGRESS_MAP_CLEAR NL_CAPABILITY_RTNL_LINK_VLAN_INGRESS_MAP_CLEAR + /** + * Consider vxlan link info for nl_object_diff(). + */ + NL_CAPABILITY_RTNL_LINK_VXLAN_IO_COMPARE = 15, +#define NL_CAPABILITY_RTNL_LINK_VXLAN_IO_COMPARE NL_CAPABILITY_RTNL_LINK_VXLAN_IO_COMPARE + __NL_CAPABILITY_MAX, NL_CAPABILITY_MAX = (__NL_CAPABILITY_MAX - 1), #define NL_CAPABILITY_MAX NL_CAPABILITY_MAX diff --git a/lib/route/link/vxlan.c b/lib/route/link/vxlan.c index 60857fc..10387bd 100644 --- a/lib/route/link/vxlan.c +++ b/lib/route/link/vxlan.c @@ -445,6 +445,34 @@ nla_put_failure: return 0; } +static int vxlan_compare(struct rtnl_link *link_a, struct rtnl_link *link_b, + uint32_t attrs, int flags) +{ + struct vxlan_info *a = link_a->l_info; + struct vxlan_info *b = link_b->l_info; + int diff = 0; + +#define VXLAN_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, VXLAN_ATTR_##ATTR, a, b, EXPR) + + diff |= VXLAN_DIFF(ID, a->vxi_id != b->vxi_id); + diff |= VXLAN_DIFF(GROUP, a->vxi_group != b->vxi_group); + diff |= VXLAN_DIFF(LINK, a->vxi_link != b->vxi_link); + diff |= VXLAN_DIFF(LOCAL, a->vxi_local != b->vxi_local); + diff |= VXLAN_DIFF(TOS, a->vxi_tos != b->vxi_tos); + diff |= VXLAN_DIFF(TTL, a->vxi_ttl != b->vxi_ttl); + diff |= VXLAN_DIFF(LEARNING, a->vxi_learning != b->vxi_learning); + diff |= VXLAN_DIFF(AGEING, a->vxi_ageing != b->vxi_ageing); + diff |= VXLAN_DIFF(PORT_RANGE, + a->vxi_port_range.low != b->vxi_port_range.low); + diff |= VXLAN_DIFF(PORT_RANGE, + a->vxi_port_range.high != b->vxi_port_range.high); + diff |= VXLAN_DIFF(GROUP6, memcmp(&a->vxi_group6, &b->vxi_group6, sizeof(a->vxi_group6)) != 0); + diff |= VXLAN_DIFF(LOCAL6, memcmp(&a->vxi_local6, &b->vxi_local6, sizeof(a->vxi_local6)) != 0); +#undef VXLAN_DIFF + + return diff; +} + static struct rtnl_link_info_ops vxlan_info_ops = { .io_name = "vxlan", .io_alloc = vxlan_alloc, @@ -456,6 +484,7 @@ static struct rtnl_link_info_ops vxlan_info_ops = { .io_clone = vxlan_clone, .io_put_attrs = vxlan_put_attrs, .io_free = vxlan_free, + .io_compare = vxlan_compare, }; /** @cond SKIP */ diff --git a/lib/utils.c b/lib/utils.c index ca98ab3..3258946 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -1158,7 +1158,7 @@ int nl_has_capability (int capability) NL_CAPABILITY_RTNL_LINK_VLAN_PROTOCOL_SERIALZE, NL_CAPABILITY_RTNL_LINK_PARSE_GRE_REMOTE, NL_CAPABILITY_RTNL_LINK_VLAN_INGRESS_MAP_CLEAR, - 0, + NL_CAPABILITY_RTNL_LINK_VXLAN_IO_COMPARE, 0), /* IMPORTANT: these capability numbers are intended to be universal and stable * for libnl3. Don't allocate new numbers on your own that differ from upstream |