summaryrefslogtreecommitdiff
path: root/nest/a-set.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2016-11-15 16:24:39 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2016-11-15 16:24:39 +0100
commit261816b0d4f3d4549a4402b95541b82fc7f10a4b (patch)
tree45fe0676d36e099c02cb44202bddd0bba6875da2 /nest/a-set.c
parentc8cafc8ebb5320ac7c6117c17e6460036f0fdf62 (diff)
BGP: Cluster list item should be prepended
Commit 3c09af41... changed behavior of int_set_add() from prepend to append, which makes more sense for community list, but prepend must be used for cluster list. Add int_set_prepend() and use it in cluster list handling code.
Diffstat (limited to 'nest/a-set.c')
-rw-r--r--nest/a-set.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/nest/a-set.c b/nest/a-set.c
index bd244e2e..a6c07f45 100644
--- a/nest/a-set.c
+++ b/nest/a-set.c
@@ -231,6 +231,26 @@ lc_set_contains(struct adata *list, lcomm val)
return 0;
}
+struct adata *
+int_set_prepend(struct linpool *pool, struct adata *list, u32 val)
+{
+ struct adata *res;
+ int len;
+
+ if (int_set_contains(list, val))
+ return list;
+
+ len = list ? list->length : 0;
+ res = lp_alloc(pool, sizeof(struct adata) + len + 4);
+ res->length = len + 4;
+
+ if (list)
+ memcpy(res->data + 4, list->data, list->length);
+
+ * (u32 *) res->data = val;
+
+ return res;
+}
struct adata *
int_set_add(struct linpool *pool, struct adata *list, u32 val)
@@ -248,8 +268,7 @@ int_set_add(struct linpool *pool, struct adata *list, u32 val)
if (list)
memcpy(res->data, list->data, list->length);
- u32 *c = (u32 *) (res->data + len);
- *c = val;
+ * (u32 *) (res->data + len) = val;
return res;
}