diff options
author | Thomas Haller <thaller@redhat.com> | 2015-11-20 10:26:23 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-11-20 10:26:23 (GMT) |
commit | ef32af0f6afd2a0e503d5c535c5e105d76d64629 (patch) | |
tree | 01dda0b56e7a9a179a403d444109d3666428d632 | |
parent | acdeaf498d53d04ef4ca0e744b6c47e07e76c121 (diff) | |
parent | 4b205cab171a45180ad33c5e5aeff0987cdfd370 (diff) | |
download | libnl-ef32af0f6afd2a0e503d5c535c5e105d76d64629.zip libnl-ef32af0f6afd2a0e503d5c535c5e105d76d64629.tar.gz libnl-ef32af0f6afd2a0e503d5c535c5e105d76d64629.tar.bz2 |
route/link/vxlan: merge branch 'vxlan-io-compare'
http://lists.infradead.org/pipermail/libnl/2015-October/001997.html
-rw-r--r-- | include/netlink-private/route/link/api.h | 6 | ||||
-rw-r--r-- | include/netlink/utils.h | 6 | ||||
-rw-r--r-- | lib/route/link.c | 1 | ||||
-rw-r--r-- | lib/route/link/api.c | 22 | ||||
-rw-r--r-- | lib/route/link/vxlan.c | 233 | ||||
-rw-r--r-- | lib/utils.c | 2 |
6 files changed, 167 insertions, 103 deletions
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/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.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); +} + /** @} */ /** @} */ diff --git a/lib/route/link/vxlan.c b/lib/route/link/vxlan.c index 184373e..10387bd 100644 --- a/lib/route/link/vxlan.c +++ b/lib/route/link/vxlan.c @@ -34,22 +34,22 @@ #include <linux/if_link.h> /** @cond SKIP */ -#define VXLAN_HAS_ID (1<<0) -#define VXLAN_HAS_GROUP (1<<1) -#define VXLAN_HAS_LINK (1<<2) -#define VXLAN_HAS_LOCAL (1<<3) -#define VXLAN_HAS_TTL (1<<4) -#define VXLAN_HAS_TOS (1<<5) -#define VXLAN_HAS_LEARNING (1<<6) -#define VXLAN_HAS_AGEING (1<<7) -#define VXLAN_HAS_LIMIT (1<<8) -#define VXLAN_HAS_PORT_RANGE (1<<9) -#define VXLAN_HAS_PROXY (1<<10) -#define VXLAN_HAS_RSC (1<<11) -#define VXLAN_HAS_L2MISS (1<<12) -#define VXLAN_HAS_L3MISS (1<<13) -#define VXLAN_HAS_GROUP6 (1<<14) -#define VXLAN_HAS_LOCAL6 (1<<15) +#define VXLAN_ATTR_ID (1<<0) +#define VXLAN_ATTR_GROUP (1<<1) +#define VXLAN_ATTR_LINK (1<<2) +#define VXLAN_ATTR_LOCAL (1<<3) +#define VXLAN_ATTR_TTL (1<<4) +#define VXLAN_ATTR_TOS (1<<5) +#define VXLAN_ATTR_LEARNING (1<<6) +#define VXLAN_ATTR_AGEING (1<<7) +#define VXLAN_ATTR_LIMIT (1<<8) +#define VXLAN_ATTR_PORT_RANGE (1<<9) +#define VXLAN_ATTR_PROXY (1<<10) +#define VXLAN_ATTR_RSC (1<<11) +#define VXLAN_ATTR_L2MISS (1<<12) +#define VXLAN_ATTR_L3MISS (1<<13) +#define VXLAN_ATTR_GROUP6 (1<<14) +#define VXLAN_ATTR_LOCAL6 (1<<15) struct vxlan_info { @@ -69,7 +69,7 @@ struct vxlan_info uint8_t vxi_rsc; uint8_t vxi_l2miss; uint8_t vxi_l3miss; - uint32_t vxi_mask; + uint32_t ce_mask; }; /** @endcond */ @@ -128,89 +128,89 @@ static int vxlan_parse(struct rtnl_link *link, struct nlattr *data, if (tb[IFLA_VXLAN_ID]) { vxi->vxi_id = nla_get_u32(tb[IFLA_VXLAN_ID]); - vxi->vxi_mask |= VXLAN_HAS_ID; + vxi->ce_mask |= VXLAN_ATTR_ID; } if (tb[IFLA_VXLAN_GROUP6]) { nla_memcpy(&vxi->vxi_group6, tb[IFLA_VXLAN_GROUP6], sizeof(vxi->vxi_group6)); - vxi->vxi_mask |= VXLAN_HAS_GROUP6; + vxi->ce_mask |= VXLAN_ATTR_GROUP6; } if (tb[IFLA_VXLAN_GROUP]) { nla_memcpy(&vxi->vxi_group, tb[IFLA_VXLAN_GROUP], sizeof(vxi->vxi_group)); - vxi->vxi_mask |= VXLAN_HAS_GROUP; - vxi->vxi_mask &= ~VXLAN_HAS_GROUP6; + vxi->ce_mask |= VXLAN_ATTR_GROUP; + vxi->ce_mask &= ~VXLAN_ATTR_GROUP6; } if (tb[IFLA_VXLAN_LINK]) { vxi->vxi_link = nla_get_u32(tb[IFLA_VXLAN_LINK]); - vxi->vxi_mask |= VXLAN_HAS_LINK; + vxi->ce_mask |= VXLAN_ATTR_LINK; } if (tb[IFLA_VXLAN_LOCAL6]) { nla_memcpy(&vxi->vxi_local6, tb[IFLA_VXLAN_LOCAL6], sizeof(vxi->vxi_local6)); - vxi->vxi_mask |= VXLAN_HAS_LOCAL6; + vxi->ce_mask |= VXLAN_ATTR_LOCAL6; } if (tb[IFLA_VXLAN_LOCAL]) { nla_memcpy(&vxi->vxi_local, tb[IFLA_VXLAN_LOCAL], sizeof(vxi->vxi_local)); - vxi->vxi_mask |= VXLAN_HAS_LOCAL; - vxi->vxi_mask &= ~VXLAN_HAS_LOCAL6; + vxi->ce_mask |= VXLAN_ATTR_LOCAL; + vxi->ce_mask &= ~VXLAN_ATTR_LOCAL6; } if (tb[IFLA_VXLAN_TTL]) { vxi->vxi_ttl = nla_get_u8(tb[IFLA_VXLAN_TTL]); - vxi->vxi_mask |= VXLAN_HAS_TTL; + vxi->ce_mask |= VXLAN_ATTR_TTL; } if (tb[IFLA_VXLAN_TOS]) { vxi->vxi_tos = nla_get_u8(tb[IFLA_VXLAN_TOS]); - vxi->vxi_mask |= VXLAN_HAS_TOS; + vxi->ce_mask |= VXLAN_ATTR_TOS; } if (tb[IFLA_VXLAN_LEARNING]) { vxi->vxi_learning = nla_get_u8(tb[IFLA_VXLAN_LEARNING]); - vxi->vxi_mask |= VXLAN_HAS_LEARNING; + vxi->ce_mask |= VXLAN_ATTR_LEARNING; } if (tb[IFLA_VXLAN_AGEING]) { vxi->vxi_ageing = nla_get_u32(tb[IFLA_VXLAN_AGEING]); - vxi->vxi_mask |= VXLAN_HAS_AGEING; + vxi->ce_mask |= VXLAN_ATTR_AGEING; } if (tb[IFLA_VXLAN_LIMIT]) { vxi->vxi_limit = nla_get_u32(tb[IFLA_VXLAN_LIMIT]); - vxi->vxi_mask |= VXLAN_HAS_LIMIT; + vxi->ce_mask |= VXLAN_ATTR_LIMIT; } if (tb[IFLA_VXLAN_PORT_RANGE]) { nla_memcpy(&vxi->vxi_port_range, tb[IFLA_VXLAN_PORT_RANGE], sizeof(vxi->vxi_port_range)); - vxi->vxi_mask |= VXLAN_HAS_PORT_RANGE; + vxi->ce_mask |= VXLAN_ATTR_PORT_RANGE; } if (tb[IFLA_VXLAN_PROXY]) { vxi->vxi_proxy = nla_get_u8(tb[IFLA_VXLAN_PROXY]); - vxi->vxi_mask |= VXLAN_HAS_PROXY; + vxi->ce_mask |= VXLAN_ATTR_PROXY; } if (tb[IFLA_VXLAN_RSC]) { vxi->vxi_rsc = nla_get_u8(tb[IFLA_VXLAN_RSC]); - vxi->vxi_mask |= VXLAN_HAS_RSC; + vxi->ce_mask |= VXLAN_ATTR_RSC; } if (tb[IFLA_VXLAN_L2MISS]) { vxi->vxi_l2miss = nla_get_u8(tb[IFLA_VXLAN_L2MISS]); - vxi->vxi_mask |= VXLAN_HAS_L2MISS; + vxi->ce_mask |= VXLAN_ATTR_L2MISS; } if (tb[IFLA_VXLAN_L3MISS]) { vxi->vxi_l3miss = nla_get_u8(tb[IFLA_VXLAN_L3MISS]); - vxi->vxi_mask |= VXLAN_HAS_L3MISS; + vxi->ce_mask |= VXLAN_ATTR_L3MISS; } err = 0; @@ -242,13 +242,13 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) nl_dump_line(p, " vxlan-id %u\n", vxi->vxi_id); - if (vxi->vxi_mask & VXLAN_HAS_GROUP) { + if (vxi->ce_mask & VXLAN_ATTR_GROUP) { nl_dump(p, " group "); if (inet_ntop(AF_INET, &vxi->vxi_group, addr, sizeof(addr))) nl_dump_line(p, "%s\n", addr); else nl_dump_line(p, "%#x\n", ntohs(vxi->vxi_group)); - } else if (vxi->vxi_mask & VXLAN_HAS_GROUP6) { + } else if (vxi->ce_mask & VXLAN_ATTR_GROUP6) { nl_dump(p, " group "); if (inet_ntop(AF_INET6, &vxi->vxi_group6, addr, sizeof(addr))) nl_dump_line(p, "%s\n", addr); @@ -256,7 +256,7 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) nl_dump_line(p, "%#x\n", vxi->vxi_group6); } - if (vxi->vxi_mask & VXLAN_HAS_LINK) { + if (vxi->ce_mask & VXLAN_ATTR_LINK) { nl_dump(p, " link "); name = NULL; @@ -270,13 +270,13 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) nl_dump_line(p, "%u\n", vxi->vxi_link); } - if (vxi->vxi_mask & VXLAN_HAS_LOCAL) { + if (vxi->ce_mask & VXLAN_ATTR_LOCAL) { nl_dump(p, " local "); if (inet_ntop(AF_INET, &vxi->vxi_local, addr, sizeof(addr))) nl_dump_line(p, "%s\n", addr); else nl_dump_line(p, "%#x\n", ntohs(vxi->vxi_local)); - } else if (vxi->vxi_mask & VXLAN_HAS_LOCAL6) { + } else if (vxi->ce_mask & VXLAN_ATTR_LOCAL6) { nl_dump(p, " local "); if (inet_ntop(AF_INET6, &vxi->vxi_local6, addr, sizeof(addr))) nl_dump_line(p, "%s\n", addr); @@ -285,7 +285,7 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) } - if (vxi->vxi_mask & VXLAN_HAS_TTL) { + if (vxi->ce_mask & VXLAN_ATTR_TTL) { nl_dump(p, " ttl "); if(vxi->vxi_ttl) nl_dump_line(p, "%u\n", vxi->vxi_ttl); @@ -293,7 +293,7 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) nl_dump_line(p, "inherit\n"); } - if (vxi->vxi_mask & VXLAN_HAS_TOS) { + if (vxi->ce_mask & VXLAN_ATTR_TOS) { nl_dump(p, " tos "); if (vxi->vxi_tos == 1) nl_dump_line(p, "inherit\n", vxi->vxi_tos); @@ -301,7 +301,7 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) nl_dump_line(p, "%#x\n", vxi->vxi_tos); } - if (vxi->vxi_mask & VXLAN_HAS_LEARNING) { + if (vxi->ce_mask & VXLAN_ATTR_LEARNING) { nl_dump(p, " learning "); if (vxi->vxi_learning) nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_learning); @@ -309,7 +309,7 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) nl_dump_line(p, "disabled\n"); } - if (vxi->vxi_mask & VXLAN_HAS_AGEING) { + if (vxi->ce_mask & VXLAN_ATTR_AGEING) { nl_dump(p, " ageing "); if (vxi->vxi_ageing) nl_dump_line(p, "%u seconds\n", vxi->vxi_ageing); @@ -317,7 +317,7 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) nl_dump_line(p, "disabled\n"); } - if (vxi->vxi_mask & VXLAN_HAS_LIMIT) { + if (vxi->ce_mask & VXLAN_ATTR_LIMIT) { nl_dump(p, " limit "); if (vxi->vxi_limit) nl_dump_line(p, "%u\n", vxi->vxi_limit); @@ -325,12 +325,12 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) nl_dump_line(p, "unlimited\n"); } - if (vxi->vxi_mask & VXLAN_HAS_PORT_RANGE) + if (vxi->ce_mask & VXLAN_ATTR_PORT_RANGE) nl_dump_line(p, " port range %u - %u\n", ntohs(vxi->vxi_port_range.low), ntohs(vxi->vxi_port_range.high)); - if (vxi->vxi_mask & VXLAN_HAS_PROXY) { + if (vxi->ce_mask & VXLAN_ATTR_PROXY) { nl_dump(p, " proxy "); if (vxi->vxi_proxy) nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_proxy); @@ -338,7 +338,7 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) nl_dump_line(p, "disabled\n"); } - if (vxi->vxi_mask & VXLAN_HAS_RSC) { + if (vxi->ce_mask & VXLAN_ATTR_RSC) { nl_dump(p, " rsc "); if (vxi->vxi_rsc) nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_rsc); @@ -346,7 +346,7 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) nl_dump_line(p, "disabled\n"); } - if (vxi->vxi_mask & VXLAN_HAS_L2MISS) { + if (vxi->ce_mask & VXLAN_ATTR_L2MISS) { nl_dump(p, " l2miss "); if (vxi->vxi_l2miss) nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_l2miss); @@ -354,7 +354,7 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) nl_dump_line(p, "disabled\n"); } - if (vxi->vxi_mask & VXLAN_HAS_L3MISS) { + if (vxi->ce_mask & VXLAN_ATTR_L3MISS) { nl_dump(p, " l3miss "); if (vxi->vxi_l3miss) nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_l3miss); @@ -389,53 +389,53 @@ static int vxlan_put_attrs(struct nl_msg *msg, struct rtnl_link *link) if (!(data = nla_nest_start(msg, IFLA_INFO_DATA))) return -NLE_MSGSIZE; - if (vxi->vxi_mask & VXLAN_HAS_ID) + if (vxi->ce_mask & VXLAN_ATTR_ID) NLA_PUT_U32(msg, IFLA_VXLAN_ID, vxi->vxi_id); - if (vxi->vxi_mask & VXLAN_HAS_GROUP) + if (vxi->ce_mask & VXLAN_ATTR_GROUP) NLA_PUT(msg, IFLA_VXLAN_GROUP, sizeof(vxi->vxi_group), &vxi->vxi_group); - if (vxi->vxi_mask & VXLAN_HAS_GROUP6) + if (vxi->ce_mask & VXLAN_ATTR_GROUP6) NLA_PUT(msg, IFLA_VXLAN_GROUP6, sizeof(vxi->vxi_group6), &vxi->vxi_group6); - if (vxi->vxi_mask & VXLAN_HAS_LINK) + if (vxi->ce_mask & VXLAN_ATTR_LINK) NLA_PUT_U32(msg, IFLA_VXLAN_LINK, vxi->vxi_link); - if (vxi->vxi_mask & VXLAN_HAS_LOCAL) + if (vxi->ce_mask & VXLAN_ATTR_LOCAL) NLA_PUT(msg, IFLA_VXLAN_LOCAL, sizeof(vxi->vxi_local), &vxi->vxi_local); - if (vxi->vxi_mask & VXLAN_HAS_LOCAL6) + if (vxi->ce_mask & VXLAN_ATTR_LOCAL6) NLA_PUT(msg, IFLA_VXLAN_LOCAL6, sizeof(vxi->vxi_local6), &vxi->vxi_local6); - if (vxi->vxi_mask & VXLAN_HAS_TTL) + if (vxi->ce_mask & VXLAN_ATTR_TTL) NLA_PUT_U8(msg, IFLA_VXLAN_TTL, vxi->vxi_ttl); - if (vxi->vxi_mask & VXLAN_HAS_TOS) + if (vxi->ce_mask & VXLAN_ATTR_TOS) NLA_PUT_U8(msg, IFLA_VXLAN_TOS, vxi->vxi_tos); - if (vxi->vxi_mask & VXLAN_HAS_LEARNING) + if (vxi->ce_mask & VXLAN_ATTR_LEARNING) NLA_PUT_U8(msg, IFLA_VXLAN_LEARNING, vxi->vxi_learning); - if (vxi->vxi_mask & VXLAN_HAS_AGEING) + if (vxi->ce_mask & VXLAN_ATTR_AGEING) NLA_PUT_U32(msg, IFLA_VXLAN_AGEING, vxi->vxi_ageing); - if (vxi->vxi_mask & VXLAN_HAS_LIMIT) + if (vxi->ce_mask & VXLAN_ATTR_LIMIT) NLA_PUT_U32(msg, IFLA_VXLAN_LIMIT, vxi->vxi_limit); - if (vxi->vxi_mask & VXLAN_HAS_PORT_RANGE) + if (vxi->ce_mask & VXLAN_ATTR_PORT_RANGE) NLA_PUT(msg, IFLA_VXLAN_PORT_RANGE, sizeof(vxi->vxi_port_range), &vxi->vxi_port_range); - if (vxi->vxi_mask & VXLAN_HAS_PROXY) + if (vxi->ce_mask & VXLAN_ATTR_PROXY) NLA_PUT_U8(msg, IFLA_VXLAN_PROXY, vxi->vxi_proxy); - if (vxi->vxi_mask & VXLAN_HAS_RSC) + if (vxi->ce_mask & VXLAN_ATTR_RSC) NLA_PUT_U8(msg, IFLA_VXLAN_RSC, vxi->vxi_rsc); - if (vxi->vxi_mask & VXLAN_HAS_L2MISS) + if (vxi->ce_mask & VXLAN_ATTR_L2MISS) NLA_PUT_U8(msg, IFLA_VXLAN_L2MISS, vxi->vxi_l2miss); - if (vxi->vxi_mask & VXLAN_HAS_L3MISS) + if (vxi->ce_mask & VXLAN_ATTR_L3MISS) NLA_PUT_U8(msg, IFLA_VXLAN_L3MISS, vxi->vxi_l3miss); nla_nest_end(msg, data); @@ -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 */ @@ -520,7 +549,7 @@ int rtnl_link_vxlan_set_id(struct rtnl_link *link, uint32_t id) return -NLE_INVAL; vxi->vxi_id = id; - vxi->vxi_mask |= VXLAN_HAS_ID; + vxi->ce_mask |= VXLAN_ATTR_ID; return 0; } @@ -541,7 +570,7 @@ int rtnl_link_vxlan_get_id(struct rtnl_link *link, uint32_t *id) if(!id) return -NLE_INVAL; - if (vxi->vxi_mask & VXLAN_HAS_ID) + if (vxi->ce_mask & VXLAN_ATTR_ID) *id = vxi->vxi_id; else return -NLE_AGAIN; @@ -566,14 +595,14 @@ int rtnl_link_vxlan_set_group(struct rtnl_link *link, struct nl_addr *addr) (nl_addr_get_len(addr) == sizeof(vxi->vxi_group))) { memcpy(&vxi->vxi_group, nl_addr_get_binary_addr(addr), sizeof(vxi->vxi_group)); - vxi->vxi_mask |= VXLAN_HAS_GROUP; - vxi->vxi_mask &= ~VXLAN_HAS_GROUP6; + vxi->ce_mask |= VXLAN_ATTR_GROUP; + vxi->ce_mask &= ~VXLAN_ATTR_GROUP6; } else if ((nl_addr_get_family(addr) == AF_INET6) && (nl_addr_get_len(addr) == sizeof(vxi->vxi_group6))) { memcpy(&vxi->vxi_group6, nl_addr_get_binary_addr(addr), sizeof(vxi->vxi_group6)); - vxi->vxi_mask |= VXLAN_HAS_GROUP6; - vxi->vxi_mask &= ~VXLAN_HAS_GROUP; + vxi->ce_mask |= VXLAN_ATTR_GROUP6; + vxi->ce_mask &= ~VXLAN_ATTR_GROUP; } else return -NLE_INVAL; @@ -596,9 +625,9 @@ int rtnl_link_vxlan_get_group(struct rtnl_link *link, struct nl_addr **addr) if (!addr) return -NLE_INVAL; - if (vxi->vxi_mask & VXLAN_HAS_GROUP) + if (vxi->ce_mask & VXLAN_ATTR_GROUP) *addr = nl_addr_build(AF_INET, &vxi->vxi_group, sizeof(vxi->vxi_group)); - else if (vxi->vxi_mask & VXLAN_HAS_GROUP6) + else if (vxi->ce_mask & VXLAN_ATTR_GROUP6) *addr = nl_addr_build(AF_INET6, &vxi->vxi_group6, sizeof(vxi->vxi_group6)); else return -NLE_AGAIN; @@ -620,7 +649,7 @@ int rtnl_link_vxlan_set_link(struct rtnl_link *link, uint32_t index) IS_VXLAN_LINK_ASSERT(link); vxi->vxi_link = index; - vxi->vxi_mask |= VXLAN_HAS_LINK; + vxi->ce_mask |= VXLAN_ATTR_LINK; return 0; } @@ -641,7 +670,7 @@ int rtnl_link_vxlan_get_link(struct rtnl_link *link, uint32_t *index) if (!index) return -NLE_INVAL; - if (!(vxi->vxi_mask & VXLAN_HAS_LINK)) + if (!(vxi->ce_mask & VXLAN_ATTR_LINK)) return -NLE_AGAIN; *index = vxi->vxi_link; @@ -666,14 +695,14 @@ int rtnl_link_vxlan_set_local(struct rtnl_link *link, struct nl_addr *addr) (nl_addr_get_len(addr) == sizeof(vxi->vxi_local))) { memcpy(&vxi->vxi_local, nl_addr_get_binary_addr(addr), sizeof(vxi->vxi_local)); - vxi->vxi_mask |= VXLAN_HAS_LOCAL; - vxi->vxi_mask &= VXLAN_HAS_LOCAL6; + vxi->ce_mask |= VXLAN_ATTR_LOCAL; + vxi->ce_mask &= VXLAN_ATTR_LOCAL6; } else if ((nl_addr_get_family(addr) == AF_INET6) && (nl_addr_get_len(addr) == sizeof(vxi->vxi_local6))) { memcpy(&vxi->vxi_local6, nl_addr_get_binary_addr(addr), sizeof(vxi->vxi_local6)); - vxi->vxi_mask |= VXLAN_HAS_LOCAL6; - vxi->vxi_mask &= ~VXLAN_HAS_LOCAL; + vxi->ce_mask |= VXLAN_ATTR_LOCAL6; + vxi->ce_mask &= ~VXLAN_ATTR_LOCAL; } else return -NLE_INVAL; @@ -696,9 +725,9 @@ int rtnl_link_vxlan_get_local(struct rtnl_link *link, struct nl_addr **addr) if (!addr) return -NLE_INVAL; - if (vxi->vxi_mask & VXLAN_HAS_LOCAL) + if (vxi->ce_mask & VXLAN_ATTR_LOCAL) *addr = nl_addr_build(AF_INET, &vxi->vxi_local, sizeof(vxi->vxi_local)); - else if (vxi->vxi_mask & VXLAN_HAS_LOCAL6) + else if (vxi->ce_mask & VXLAN_ATTR_LOCAL6) *addr = nl_addr_build(AF_INET6, &vxi->vxi_local6, sizeof(vxi->vxi_local6)); else return -NLE_AGAIN; @@ -720,7 +749,7 @@ int rtnl_link_vxlan_set_ttl(struct rtnl_link *link, uint8_t ttl) IS_VXLAN_LINK_ASSERT(link); vxi->vxi_ttl = ttl; - vxi->vxi_mask |= VXLAN_HAS_TTL; + vxi->ce_mask |= VXLAN_ATTR_TTL; return 0; } @@ -737,7 +766,7 @@ int rtnl_link_vxlan_get_ttl(struct rtnl_link *link) IS_VXLAN_LINK_ASSERT(link); - if (!(vxi->vxi_mask & VXLAN_HAS_TTL)) + if (!(vxi->ce_mask & VXLAN_ATTR_TTL)) return -NLE_AGAIN; return vxi->vxi_ttl; @@ -757,7 +786,7 @@ int rtnl_link_vxlan_set_tos(struct rtnl_link *link, uint8_t tos) IS_VXLAN_LINK_ASSERT(link); vxi->vxi_tos = tos; - vxi->vxi_mask |= VXLAN_HAS_TOS; + vxi->ce_mask |= VXLAN_ATTR_TOS; return 0; } @@ -774,7 +803,7 @@ int rtnl_link_vxlan_get_tos(struct rtnl_link *link) IS_VXLAN_LINK_ASSERT(link); - if (!(vxi->vxi_mask & VXLAN_HAS_TOS)) + if (!(vxi->ce_mask & VXLAN_ATTR_TOS)) return -NLE_AGAIN; return vxi->vxi_tos; @@ -794,7 +823,7 @@ int rtnl_link_vxlan_set_learning(struct rtnl_link *link, uint8_t learning) IS_VXLAN_LINK_ASSERT(link); vxi->vxi_learning = learning; - vxi->vxi_mask |= VXLAN_HAS_LEARNING; + vxi->ce_mask |= VXLAN_ATTR_LEARNING; return 0; } @@ -811,7 +840,7 @@ int rtnl_link_vxlan_get_learning(struct rtnl_link *link) IS_VXLAN_LINK_ASSERT(link); - if (!(vxi->vxi_mask & VXLAN_HAS_LEARNING)) + if (!(vxi->ce_mask & VXLAN_ATTR_LEARNING)) return -NLE_AGAIN; return vxi->vxi_learning; @@ -853,7 +882,7 @@ int rtnl_link_vxlan_set_ageing(struct rtnl_link *link, uint32_t expiry) IS_VXLAN_LINK_ASSERT(link); vxi->vxi_ageing = expiry; - vxi->vxi_mask |= VXLAN_HAS_AGEING; + vxi->ce_mask |= VXLAN_ATTR_AGEING; return 0; } @@ -874,7 +903,7 @@ int rtnl_link_vxlan_get_ageing(struct rtnl_link *link, uint32_t *expiry) if (!expiry) return -NLE_INVAL; - if (vxi->vxi_mask & VXLAN_HAS_AGEING) + if (vxi->ce_mask & VXLAN_ATTR_AGEING) *expiry = vxi->vxi_ageing; else return -NLE_AGAIN; @@ -896,7 +925,7 @@ int rtnl_link_vxlan_set_limit(struct rtnl_link *link, uint32_t limit) IS_VXLAN_LINK_ASSERT(link); vxi->vxi_limit = limit; - vxi->vxi_mask |= VXLAN_HAS_LIMIT; + vxi->ce_mask |= VXLAN_ATTR_LIMIT; return 0; } @@ -917,7 +946,7 @@ int rtnl_link_vxlan_get_limit(struct rtnl_link *link, uint32_t *limit) if (!limit) return -NLE_INVAL; - if (vxi->vxi_mask & VXLAN_HAS_LIMIT) + if (vxi->ce_mask & VXLAN_ATTR_LIMIT) *limit = vxi->vxi_limit; else return -NLE_AGAIN; @@ -943,7 +972,7 @@ int rtnl_link_vxlan_set_port_range(struct rtnl_link *link, return -NLE_INVAL; memcpy(&vxi->vxi_port_range, range, sizeof(vxi->vxi_port_range)); - vxi->vxi_mask |= VXLAN_HAS_PORT_RANGE; + vxi->ce_mask |= VXLAN_ATTR_PORT_RANGE; return 0; } @@ -965,7 +994,7 @@ int rtnl_link_vxlan_get_port_range(struct rtnl_link *link, if (!range) return -NLE_INVAL; - if (vxi->vxi_mask & VXLAN_HAS_PORT_RANGE) + if (vxi->ce_mask & VXLAN_ATTR_PORT_RANGE) memcpy(range, &vxi->vxi_port_range, sizeof(*range)); else return -NLE_AGAIN; @@ -987,7 +1016,7 @@ int rtnl_link_vxlan_set_proxy(struct rtnl_link *link, uint8_t proxy) IS_VXLAN_LINK_ASSERT(link); vxi->vxi_proxy = proxy; - vxi->vxi_mask |= VXLAN_HAS_PROXY; + vxi->ce_mask |= VXLAN_ATTR_PROXY; return 0; } @@ -1004,7 +1033,7 @@ int rtnl_link_vxlan_get_proxy(struct rtnl_link *link) IS_VXLAN_LINK_ASSERT(link); - if (!(vxi->vxi_mask & VXLAN_HAS_PROXY)) + if (!(vxi->ce_mask & VXLAN_ATTR_PROXY)) return -NLE_AGAIN; return vxi->vxi_proxy; @@ -1046,7 +1075,7 @@ int rtnl_link_vxlan_set_rsc(struct rtnl_link *link, uint8_t rsc) IS_VXLAN_LINK_ASSERT(link); vxi->vxi_rsc = rsc; - vxi->vxi_mask |= VXLAN_HAS_RSC; + vxi->ce_mask |= VXLAN_ATTR_RSC; return 0; } @@ -1063,7 +1092,7 @@ int rtnl_link_vxlan_get_rsc(struct rtnl_link *link) IS_VXLAN_LINK_ASSERT(link); - if (!(vxi->vxi_mask & VXLAN_HAS_RSC)) + if (!(vxi->ce_mask & VXLAN_ATTR_RSC)) return -NLE_AGAIN; return vxi->vxi_rsc; @@ -1105,7 +1134,7 @@ int rtnl_link_vxlan_set_l2miss(struct rtnl_link *link, uint8_t miss) IS_VXLAN_LINK_ASSERT(link); vxi->vxi_l2miss = miss; - vxi->vxi_mask |= VXLAN_HAS_L2MISS; + vxi->ce_mask |= VXLAN_ATTR_L2MISS; return 0; } @@ -1122,7 +1151,7 @@ int rtnl_link_vxlan_get_l2miss(struct rtnl_link *link) IS_VXLAN_LINK_ASSERT(link); - if (!(vxi->vxi_mask & VXLAN_HAS_L2MISS)) + if (!(vxi->ce_mask & VXLAN_ATTR_L2MISS)) return -NLE_AGAIN; return vxi->vxi_l2miss; @@ -1164,7 +1193,7 @@ int rtnl_link_vxlan_set_l3miss(struct rtnl_link *link, uint8_t miss) IS_VXLAN_LINK_ASSERT(link); vxi->vxi_l3miss = miss; - vxi->vxi_mask |= VXLAN_HAS_L3MISS; + vxi->ce_mask |= VXLAN_ATTR_L3MISS; return 0; } @@ -1181,7 +1210,7 @@ int rtnl_link_vxlan_get_l3miss(struct rtnl_link *link) IS_VXLAN_LINK_ASSERT(link); - if (!(vxi->vxi_mask & VXLAN_HAS_L3MISS)) + if (!(vxi->ce_mask & VXLAN_ATTR_L3MISS)) return -NLE_AGAIN; return vxi->vxi_l3miss; 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 |