summaryrefslogtreecommitdiff
path: root/proto/static
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-05-05 19:28:56 +0200
committerMaria Matejka <mq@ucw.cz>2022-05-05 19:28:56 +0200
commitf2e725a76882ba6b75c3ce4fb3c760bd83462410 (patch)
tree48883d91d8cdfaba9420efe33e1b81778e70b0a8 /proto/static
parent1c30b689ddd032ef8000fb7836348a48ba3184ff (diff)
All outstanding MPLS label stacks are stored as adata
Diffstat (limited to 'proto/static')
-rw-r--r--proto/static/static.c28
-rw-r--r--proto/static/static.h2
2 files changed, 10 insertions, 20 deletions
diff --git a/proto/static/static.c b/proto/static/static.c
index 1400e985..e792a148 100644
--- a/proto/static/static.c
+++ b/proto/static/static.c
@@ -76,8 +76,8 @@ static_announce_rte(struct static_proto *p, struct static_route *r)
nh->weight = r2->weight;
if (r2->mls)
{
- nh->labels = r2->mls->len;
- memcpy(nh->label, r2->mls->stack, r2->mls->len * sizeof(u32));
+ nh->labels = r2->mls->length / sizeof(u32);
+ memcpy(nh->label, r2->mls->data, r2->mls->length);
}
nexthop_insert(&nhs, nh);
@@ -92,7 +92,11 @@ static_announce_rte(struct static_proto *p, struct static_route *r)
if (r->dest == RTDX_RECURSIVE)
{
rtable *tab = ipa_is_ip4(r->via) ? p->igp_table_ip4 : p->igp_table_ip6;
- rta_set_recursive_next_hop(p->p.main_channel->table, a, tab, r->via, IPA_NONE, r->mls);
+ if (r->mls)
+ ea_set_attr(&a->eattrs,
+ EA_LITERAL_DIRECT_ADATA(&ea_mpls_labels, 0, r->mls));
+
+ rta_set_recursive_next_hop(p->p.main_channel->table, a, tab, r->via, IPA_NONE);
}
/* Already announced */
@@ -314,31 +318,17 @@ static_same_dest(struct static_route *x, struct static_route *y)
(x->weight != y->weight) ||
(x->use_bfd != y->use_bfd) ||
(!x->mls != !y->mls) ||
- ((x->mls) && (y->mls) && (x->mls->len != y->mls->len)))
+ ((x->mls) && (y->mls) && adata_same(x->mls, y->mls)))
return 0;
-
- if (!x->mls)
- continue;
-
- for (uint i = 0; i < x->mls->len; i++)
- if (x->mls->stack[i] != y->mls->stack[i])
- return 0;
}
return !x && !y;
case RTDX_RECURSIVE:
if (!ipa_equal(x->via, y->via) ||
(!x->mls != !y->mls) ||
- ((x->mls) && (y->mls) && (x->mls->len != y->mls->len)))
+ ((x->mls) && (y->mls) && adata_same(x->mls, y->mls)))
return 0;
- if (!x->mls)
- return 1;
-
- for (uint i = 0; i < x->mls->len; i++)
- if (x->mls->stack[i] != y->mls->stack[i])
- return 0;
-
return 1;
default:
diff --git a/proto/static/static.h b/proto/static/static.h
index d99f7ebd..ea7ca33b 100644
--- a/proto/static/static.h
+++ b/proto/static/static.h
@@ -49,7 +49,7 @@ struct static_route {
byte weight; /* Multipath next hop weight */
byte use_bfd; /* Configured to use BFD */
struct bfd_request *bfd_req; /* BFD request, if BFD is used */
- mpls_label_stack *mls; /* MPLS label stack; may be NULL */
+ struct adata *mls; /* MPLS label stack; may be NULL */
};
/*