summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Ahern <dsa@cumulusnetworks.com>2015-12-18 17:50:03 (GMT)
committerThomas Haller <thaller@redhat.com>2016-02-12 17:09:04 (GMT)
commita09b8558148b31e469d463907d103fa78d81612c (patch)
tree0ecd7ff2d09af28256b69d612beea3f0a6aff3ca /lib
parent58396ae2ae7c91fb95d1de9654be5b12fd2343d2 (diff)
downloadlibnl-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')
-rw-r--r--lib/fib_lookup/lookup.c4
-rw-r--r--lib/fib_lookup/request.c6
-rw-r--r--lib/genl/family.c6
-rw-r--r--lib/idiag/idiag_meminfo_obj.c4
-rw-r--r--lib/idiag/idiag_msg_obj.c6
-rw-r--r--lib/idiag/idiag_vegasinfo_obj.c4
-rw-r--r--lib/netfilter/ct_obj.c6
-rw-r--r--lib/netfilter/exp_obj.c6
-rw-r--r--lib/netfilter/log_obj.c6
-rw-r--r--lib/netfilter/queue_obj.c6
-rw-r--r--lib/object.c29
-rw-r--r--lib/route/addr.c6
-rw-r--r--lib/route/link.c9
-rw-r--r--lib/route/neigh.c6
-rw-r--r--lib/route/neightbl.c6
-rw-r--r--lib/route/route_obj.c7
-rw-r--r--lib/route/rule.c6
-rw-r--r--lib/route/tc.c6
-rw-r--r--lib/xfrm/ae.c6
-rw-r--r--lib/xfrm/sa.c5
-rw-r--r--lib/xfrm/sp.c5
21 files changed, 88 insertions, 57 deletions
diff --git a/lib/fib_lookup/lookup.c b/lib/fib_lookup/lookup.c
index 9b24635..43b6126 100644
--- a/lib/fib_lookup/lookup.c
+++ b/lib/fib_lookup/lookup.c
@@ -141,8 +141,8 @@ static void result_dump_details(struct nl_object *obj, struct nl_dump_params *p)
result_dump_line(obj, p);
}
-static int result_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t result_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
return 0;
}
diff --git a/lib/fib_lookup/request.c b/lib/fib_lookup/request.c
index 1b021b6..5bd49d6 100644
--- a/lib/fib_lookup/request.c
+++ b/lib/fib_lookup/request.c
@@ -53,12 +53,12 @@ static int request_clone(struct nl_object *_dst, struct nl_object *_src)
return 0;
}
-static int request_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t request_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct flnl_request *a = (struct flnl_request *) _a;
struct flnl_request *b = (struct flnl_request *) _b;
- int diff = 0;
+ uint64_t diff = 0;
#define REQ_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, REQUEST_ATTR_##ATTR, a, b, EXPR)
diff --git a/lib/genl/family.c b/lib/genl/family.c
index 9155c8f..45c3d45 100644
--- a/lib/genl/family.c
+++ b/lib/genl/family.c
@@ -147,12 +147,12 @@ static void family_dump_stats(struct nl_object *obj, struct nl_dump_params *p)
family_dump_details(obj, p);
}
-static int family_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t family_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct genl_family *a = (struct genl_family *) _a;
struct genl_family *b = (struct genl_family *) _b;
- int diff = 0;
+ uint64_t diff = 0;
#define FAM_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, FAMILY_ATTR_##ATTR, a, b, EXPR)
diff --git a/lib/idiag/idiag_meminfo_obj.c b/lib/idiag/idiag_meminfo_obj.c
index f07800f..1c327bb 100644
--- a/lib/idiag/idiag_meminfo_obj.c
+++ b/lib/idiag/idiag_meminfo_obj.c
@@ -81,8 +81,8 @@ void idiagnl_meminfo_set_tmem(struct idiagnl_meminfo *minfo, uint32_t tmem)
/** @} */
/** @cond SKIP */
-static int idiagnl_meminfo_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t idiagnl_meminfo_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct idiagnl_meminfo *a = (struct idiagnl_meminfo *) _a;
struct idiagnl_meminfo *b = (struct idiagnl_meminfo *) _b;
diff --git a/lib/idiag/idiag_msg_obj.c b/lib/idiag/idiag_msg_obj.c
index d7cf722..beaa9cc 100644
--- a/lib/idiag/idiag_msg_obj.c
+++ b/lib/idiag/idiag_msg_obj.c
@@ -853,12 +853,12 @@ static char *_idiagnl_attrs2str(int attrs, char *buf, size_t len)
ARRAY_SIZE(idiagnl_attrs));
}
-static int idiagnl_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t idiagnl_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct idiagnl_msg *a = (struct idiagnl_msg *) _a;
struct idiagnl_msg *b = (struct idiagnl_msg *) _b;
- int diff = 0;
+ uint64_t diff = 0;
#define _DIFF(ATTR, EXPR) ATTR_DIFF(attrs, IDIAGNL_ATTR_##ATTR, a, b, EXPR)
diff |= _DIFF(FAMILY, a->idiag_family != b->idiag_family);
diff --git a/lib/idiag/idiag_vegasinfo_obj.c b/lib/idiag/idiag_vegasinfo_obj.c
index eddd8af..f02eea0 100644
--- a/lib/idiag/idiag_vegasinfo_obj.c
+++ b/lib/idiag/idiag_vegasinfo_obj.c
@@ -84,8 +84,8 @@ void idiagnl_vegasinfo_set_minrtt(struct idiagnl_vegasinfo *vinfo, uint32_t
/** @} */
/** @cond SKIP */
-static int idiagnl_vegasinfo_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t idiagnl_vegasinfo_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct idiagnl_vegasinfo *a = (struct idiagnl_vegasinfo *) _a;
struct idiagnl_vegasinfo *b = (struct idiagnl_vegasinfo *) _b;
diff --git a/lib/netfilter/ct_obj.c b/lib/netfilter/ct_obj.c
index c8af870..1079ec0 100644
--- a/lib/netfilter/ct_obj.c
+++ b/lib/netfilter/ct_obj.c
@@ -297,12 +297,12 @@ static void ct_dump_stats(struct nl_object *a, struct nl_dump_params *p)
}
}
-static int ct_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t ct_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct nfnl_ct *a = (struct nfnl_ct *) _a;
struct nfnl_ct *b = (struct nfnl_ct *) _b;
- int diff = 0;
+ uint64_t diff = 0;
#define CT_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, CT_ATTR_##ATTR, a, b, EXPR)
#define CT_DIFF_VAL(ATTR, FIELD) CT_DIFF(ATTR, a->FIELD != b->FIELD)
diff --git a/lib/netfilter/exp_obj.c b/lib/netfilter/exp_obj.c
index 591cf45..aef43b7 100644
--- a/lib/netfilter/exp_obj.c
+++ b/lib/netfilter/exp_obj.c
@@ -301,12 +301,12 @@ static int exp_cmp_l4proto_icmp (union nfnl_exp_protodata *a, union nfnl_exp_pro
return d;
}
-static int exp_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t exp_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct nfnl_exp *a = (struct nfnl_exp *) _a;
struct nfnl_exp *b = (struct nfnl_exp *) _b;
- int diff = 0;
+ uint64_t diff = 0;
#define EXP_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, EXP_ATTR_##ATTR, a, b, EXPR)
#define EXP_DIFF_VAL(ATTR, FIELD) EXP_DIFF(ATTR, a->FIELD != b->FIELD)
diff --git a/lib/netfilter/log_obj.c b/lib/netfilter/log_obj.c
index 3fdb347..65985d8 100644
--- a/lib/netfilter/log_obj.c
+++ b/lib/netfilter/log_obj.c
@@ -229,12 +229,12 @@ unsigned int nfnl_log_str2flags(const char *name)
return __str2flags(name, log_flags, ARRAY_SIZE(log_flags));
}
-static int nfnl_log_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t nfnl_log_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct nfnl_log *a = (struct nfnl_log *) _a;
struct nfnl_log *b = (struct nfnl_log *) _b;
- int diff = 0;
+ uint64_t diff = 0;
#define NFNL_LOG_DIFF(ATTR, EXPR) \
ATTR_DIFF(attrs, LOG_ATTR_##ATTR, a, b, EXPR)
diff --git a/lib/netfilter/queue_obj.c b/lib/netfilter/queue_obj.c
index 36ed3c5..040bbed 100644
--- a/lib/netfilter/queue_obj.c
+++ b/lib/netfilter/queue_obj.c
@@ -161,12 +161,12 @@ uint32_t nfnl_queue_get_copy_range(const struct nfnl_queue *queue)
return queue->queue_copy_range;
}
-static int nfnl_queue_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t nfnl_queue_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct nfnl_queue *a = (struct nfnl_queue *) _a;
struct nfnl_queue *b = (struct nfnl_queue *) _b;
- int diff = 0;
+ uint64_t diff = 0;
#define NFNL_QUEUE_DIFF(ATTR, EXPR) \
ATTR_DIFF(attrs, QUEUE_ATTR_##ATTR, a, b, EXPR)
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
diff --git a/lib/route/addr.c b/lib/route/addr.c
index 3bde2bf..33df1c8 100644
--- a/lib/route/addr.c
+++ b/lib/route/addr.c
@@ -429,12 +429,12 @@ static void addr_dump_stats(struct nl_object *obj, struct nl_dump_params *p)
addr_dump_details(obj, p);
}
-static int addr_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t addr_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct rtnl_addr *a = (struct rtnl_addr *) _a;
struct rtnl_addr *b = (struct rtnl_addr *) _b;
- int diff = 0;
+ uint64_t diff = 0;
#define ADDR_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, ADDR_ATTR_##ATTR, a, b, EXPR)
diff --git a/lib/route/link.c b/lib/route/link.c
index d763d97..1fa2672 100644
--- a/lib/route/link.c
+++ b/lib/route/link.c
@@ -61,7 +61,8 @@
#define LINK_ATTR_PHYS_PORT_ID (1 << 28)
#define LINK_ATTR_NS_FD (1 << 29)
#define LINK_ATTR_NS_PID (1 << 30)
-#define LINK_ATTR_LINK_NETNSID (1 << 31)
+/* 31 used by 32-bit api */
+#define LINK_ATTR_LINK_NETNSID ((uint64_t) 1 << 32)
static struct nl_cache_ops rtnl_link_ops;
static struct nl_object_ops link_obj_ops;
@@ -955,12 +956,12 @@ static void link_keygen(struct nl_object *obj, uint32_t *hashkey,
return;
}
-static int link_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t link_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct rtnl_link *a = (struct rtnl_link *) _a;
struct rtnl_link *b = (struct rtnl_link *) _b;
- int diff = 0;
+ uint64_t diff = 0;
#define LINK_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, LINK_ATTR_##ATTR, a, b, EXPR)
diff --git a/lib/route/neigh.c b/lib/route/neigh.c
index 436d766..9fdcaca 100644
--- a/lib/route/neigh.c
+++ b/lib/route/neigh.c
@@ -260,12 +260,12 @@ static void neigh_keygen(struct nl_object *obj, uint32_t *hashkey,
return;
}
-static int neigh_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t neigh_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct rtnl_neigh *a = (struct rtnl_neigh *) _a;
struct rtnl_neigh *b = (struct rtnl_neigh *) _b;
- int diff = 0;
+ uint64_t diff = 0;
#define NEIGH_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, NEIGH_ATTR_##ATTR, a, b, EXPR)
diff --git a/lib/route/neightbl.c b/lib/route/neightbl.c
index f9c9c27..7fd106b 100644
--- a/lib/route/neightbl.c
+++ b/lib/route/neightbl.c
@@ -54,12 +54,12 @@ static struct nl_cache_ops rtnl_neightbl_ops;
static struct nl_object_ops neightbl_obj_ops;
/** @endcond */
-static int neightbl_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t neightbl_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct rtnl_neightbl *a = (struct rtnl_neightbl *) _a;
struct rtnl_neightbl *b = (struct rtnl_neightbl *) _b;
- int diff = 0;
+ uint64_t diff = 0;
#define NT_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, NEIGHTBL_ATTR_##ATTR, a, b, EXPR)
diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c
index 4063c6f..0f52e00 100644
--- a/lib/route/route_obj.c
+++ b/lib/route/route_obj.c
@@ -343,13 +343,14 @@ static void route_keygen(struct nl_object *obj, uint32_t *hashkey,
return;
}
-static int route_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t route_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct rtnl_route *a = (struct rtnl_route *) _a;
struct rtnl_route *b = (struct rtnl_route *) _b;
struct rtnl_nexthop *nh_a, *nh_b;
- int i, diff = 0, found;
+ int i, found;
+ uint64_t diff = 0;
#define ROUTE_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, ROUTE_ATTR_##ATTR, a, b, EXPR)
diff --git a/lib/route/rule.c b/lib/route/rule.c
index 357cb1b..883df81 100644
--- a/lib/route/rule.c
+++ b/lib/route/rule.c
@@ -245,12 +245,12 @@ static void rule_dump_stats(struct nl_object *obj, struct nl_dump_params *p)
#define RULE_ATTR_FLAGS 0x0008
-static int rule_compare(struct nl_object *_a, struct nl_object *_b,
- uint32_t attrs, int flags)
+static uint64_t rule_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct rtnl_rule *a = (struct rtnl_rule *) _a;
struct rtnl_rule *b = (struct rtnl_rule *) _b;
- int diff = 0;
+ uint64_t diff = 0;
#define RULE_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, RULE_ATTR_##ATTR, a, b, EXPR)
diff --git a/lib/route/tc.c b/lib/route/tc.c
index 35daf15..384e857 100644
--- a/lib/route/tc.c
+++ b/lib/route/tc.c
@@ -932,12 +932,12 @@ void rtnl_tc_dump_stats(struct nl_object *obj, struct nl_dump_params *p)
tc->tc_stats[RTNL_TC_RATE_PPS]);
}
-int rtnl_tc_compare(struct nl_object *aobj, struct nl_object *bobj,
- uint32_t attrs, int flags)
+uint64_t rtnl_tc_compare(struct nl_object *aobj, struct nl_object *bobj,
+ uint64_t attrs, int flags)
{
struct rtnl_tc *a = TC_CAST(aobj);
struct rtnl_tc *b = TC_CAST(bobj);
- int diff = 0;
+ uint64_t diff = 0;
#define TC_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, TCA_ATTR_##ATTR, a, b, EXPR)
diff --git a/lib/xfrm/ae.c b/lib/xfrm/ae.c
index 4fe9647..bfe481f 100644
--- a/lib/xfrm/ae.c
+++ b/lib/xfrm/ae.c
@@ -181,11 +181,13 @@ static int xfrm_ae_clone(struct nl_object *_dst, struct nl_object *_src)
return 0;
}
-static int xfrm_ae_compare(struct nl_object *_a, struct nl_object *_b, uint32_t attrs, int flags)
+static uint64_t xfrm_ae_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct xfrmnl_ae* a = (struct xfrmnl_ae *) _a;
struct xfrmnl_ae* b = (struct xfrmnl_ae *) _b;
- int diff = 0, found = 0;
+ uint64_t diff = 0;
+ int found = 0;
#define XFRM_AE_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, XFRM_AE_ATTR_##ATTR, a, b, EXPR)
diff |= XFRM_AE_DIFF(DADDR, nl_addr_cmp(a->sa_id.daddr, b->sa_id.daddr));
diff --git a/lib/xfrm/sa.c b/lib/xfrm/sa.c
index 34d24cf..31c22ba 100644
--- a/lib/xfrm/sa.c
+++ b/lib/xfrm/sa.c
@@ -205,11 +205,12 @@ static int xfrm_sa_clone(struct nl_object *_dst, struct nl_object *_src)
return 0;
}
-static int xfrm_sa_compare(struct nl_object *_a, struct nl_object *_b, uint32_t attrs, int flags)
+static uint64_t xfrm_sa_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct xfrmnl_sa* a = (struct xfrmnl_sa *) _a;
struct xfrmnl_sa* b = (struct xfrmnl_sa *) _b;
- int diff = 0;
+ uint64_t diff = 0;
int found = 0;
#define XFRM_SA_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, XFRM_SA_ATTR_##ATTR, a, b, EXPR)
diff --git a/lib/xfrm/sp.c b/lib/xfrm/sp.c
index 943269a..cc2fcb1 100644
--- a/lib/xfrm/sp.c
+++ b/lib/xfrm/sp.c
@@ -138,12 +138,13 @@ static int xfrm_sp_clone(struct nl_object *_dst, struct nl_object *_src)
return 0;
}
-static int xfrm_sp_compare(struct nl_object *_a, struct nl_object *_b, uint32_t attrs, int flags)
+static uint64_t xfrm_sp_compare(struct nl_object *_a, struct nl_object *_b,
+ uint64_t attrs, int flags)
{
struct xfrmnl_sp* a = (struct xfrmnl_sp *) _a;
struct xfrmnl_sp* b = (struct xfrmnl_sp *) _b;
struct xfrmnl_user_tmpl *tmpl_a, *tmpl_b;
- int diff = 0;
+ uint64_t diff = 0;
#define XFRM_SP_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, XFRM_SP_ATTR_##ATTR, a, b, EXPR)
diff |= XFRM_SP_DIFF(SEL, xfrmnl_sel_cmp(a->sel, b->sel));