From f2e725a76882ba6b75c3ce4fb3c760bd83462410 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Thu, 5 May 2022 19:28:56 +0200 Subject: All outstanding MPLS label stacks are stored as adata --- nest/rt-table.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'nest/rt-table.c') diff --git a/nest/rt-table.c b/nest/rt-table.c index 4f119ac0..37f17bbc 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -2385,7 +2385,7 @@ rt_preconfig(struct config *c) */ void -rta_apply_hostentry(rta *a, struct hostentry *he, mpls_label_stack *mls) +rta_apply_hostentry(rta *a, struct hostentry *he) { a->hostentry = he; a->dest = he->dest; @@ -2397,15 +2397,12 @@ rta_apply_hostentry(rta *a, struct hostentry *he, mpls_label_stack *mls) /* No nexthop */ no_nexthop: a->nh = (struct nexthop) {}; - if (mls) - { /* Store the label stack for later changes */ - a->nh.labels_orig = a->nh.labels = mls->len; - memcpy(a->nh.label, mls->stack, mls->len * sizeof(u32)); - } return; } - if (((!mls) || (!mls->len)) && he->nexthop_linkable) + eattr *mls_ea = ea_find(a->eattrs, &ea_mpls_labels); + + if (!mls_ea && he->nexthop_linkable) { /* Just link the nexthop chain, no label append happens. */ memcpy(&(a->nh), &(he->src->nh), nexthop_size(&(he->src->nh))); return; @@ -2414,6 +2411,9 @@ no_nexthop: struct nexthop *nhp = NULL, *nhr = NULL; int skip_nexthop = 0; + const struct adata *mls = mls_ea ? mls_ea->u.ptr : NULL; + uint mls_cnt = mls ? mls->length / sizeof(u32) : 0; + for (struct nexthop *nh = &(he->src->nh); nh; nh = nh->next) { if (skip_nexthop) @@ -2430,17 +2430,16 @@ no_nexthop: if (mls) { - nhp->labels = nh->labels + mls->len; - nhp->labels_orig = mls->len; + nhp->labels = nh->labels + mls_cnt; if (nhp->labels <= MPLS_MAX_LABEL_STACK) { memcpy(nhp->label, nh->label, nh->labels * sizeof(u32)); /* First the hostentry labels */ - memcpy(&(nhp->label[nh->labels]), mls->stack, mls->len * sizeof(u32)); /* Then the bottom labels */ + memcpy(&(nhp->label[nh->labels]), mls->data, mls->length); /* Then the bottom labels */ } else { log(L_WARN "Sum of label stack sizes %d + %d = %d exceedes allowed maximum (%d)", - nh->labels, mls->len, nhp->labels, MPLS_MAX_LABEL_STACK); + nh->labels, mls_cnt, nhp->labels, MPLS_MAX_LABEL_STACK); skip_nexthop++; continue; } @@ -2448,7 +2447,6 @@ no_nexthop: else if (nh->labels) { nhp->labels = nh->labels; - nhp->labels_orig = 0; memcpy(nhp->label, nh->label, nh->labels * sizeof(u32)); } @@ -2501,10 +2499,7 @@ rt_next_hop_update_rte(rtable *tab UNUSED, rte *old) rta *a = alloca(RTA_MAX_SIZE); memcpy(a, old->attrs, rta_size(old->attrs)); - mpls_label_stack mls = { .len = a->nh.labels_orig }; - memcpy(mls.stack, &a->nh.label[a->nh.labels - mls.len], mls.len * sizeof(u32)); - - rta_apply_hostentry(a, old->attrs->hostentry, &mls); + rta_apply_hostentry(a, old->attrs->hostentry); a->cached = 0; rte *e = sl_alloc(rte_slab); -- cgit v1.2.3