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.
This commit is contained in:
parent
c8cafc8ebb
commit
261816b0d4
3 changed files with 23 additions and 3 deletions
23
nest/a-set.c
23
nest/a-set.c
|
@ -231,6 +231,26 @@ lc_set_contains(struct adata *list, lcomm val)
|
||||||
return 0;
|
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 *
|
struct adata *
|
||||||
int_set_add(struct linpool *pool, struct adata *list, u32 val)
|
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)
|
if (list)
|
||||||
memcpy(res->data, list->data, list->length);
|
memcpy(res->data, list->data, list->length);
|
||||||
|
|
||||||
u32 *c = (u32 *) (res->data + len);
|
* (u32 *) (res->data + len) = val;
|
||||||
*c = val;
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,6 +132,7 @@ int lc_set_format(struct adata *set, int from, byte *buf, uint size);
|
||||||
int int_set_contains(struct adata *list, u32 val);
|
int int_set_contains(struct adata *list, u32 val);
|
||||||
int ec_set_contains(struct adata *list, u64 val);
|
int ec_set_contains(struct adata *list, u64 val);
|
||||||
int lc_set_contains(struct adata *list, lcomm val);
|
int lc_set_contains(struct adata *list, lcomm val);
|
||||||
|
struct adata *int_set_prepend(struct linpool *pool, struct adata *list, u32 val);
|
||||||
struct adata *int_set_add(struct linpool *pool, struct adata *list, u32 val);
|
struct adata *int_set_add(struct linpool *pool, struct adata *list, u32 val);
|
||||||
struct adata *ec_set_add(struct linpool *pool, struct adata *list, u64 val);
|
struct adata *ec_set_add(struct linpool *pool, struct adata *list, u64 val);
|
||||||
struct adata *lc_set_add(struct linpool *pool, struct adata *list, lcomm val);
|
struct adata *lc_set_add(struct linpool *pool, struct adata *list, lcomm val);
|
||||||
|
|
|
@ -1077,7 +1077,7 @@ static inline void
|
||||||
bgp_cluster_list_prepend(rte *e, ea_list **attrs, struct linpool *pool, u32 cid)
|
bgp_cluster_list_prepend(rte *e, ea_list **attrs, struct linpool *pool, u32 cid)
|
||||||
{
|
{
|
||||||
eattr *a = ea_find(e->attrs->eattrs, EA_CODE(EAP_BGP, BA_CLUSTER_LIST));
|
eattr *a = ea_find(e->attrs->eattrs, EA_CODE(EAP_BGP, BA_CLUSTER_LIST));
|
||||||
bgp_attach_attr(attrs, pool, BA_CLUSTER_LIST, (uintptr_t) int_set_add(pool, a ? a->u.ptr : NULL, cid));
|
bgp_attach_attr(attrs, pool, BA_CLUSTER_LIST, (uintptr_t) int_set_prepend(pool, a ? a->u.ptr : NULL, cid));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in a new issue