summaryrefslogtreecommitdiff
path: root/proto/static
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-05-30 17:36:36 +0200
committerMaria Matejka <mq@ucw.cz>2022-05-30 17:37:08 +0200
commit1493695c6ba2b169523f7c2097fac8e8343352fe (patch)
tree0a0e5296b7b53d79a99aa3ebf254c124e1373414 /proto/static
parent7b0c89a47fa1f63248ceaa1e9c1b3948dd29a68d (diff)
parentf15f2fcee7eeb5a100bd204a0e67018e25953420 (diff)
Merge commit 'f15f2fcee7eeb5a100bd204a0e67018e25953420' into haugesund
Diffstat (limited to 'proto/static')
-rw-r--r--proto/static/static.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/proto/static/static.c b/proto/static/static.c
index dffc4882..8e389390 100644
--- a/proto/static/static.c
+++ b/proto/static/static.c
@@ -61,32 +61,40 @@ static_announce_rte(struct static_proto *p, struct static_route *r)
if (r->dest == RTD_UNICAST)
{
- struct static_route *r2;
- struct nexthop *nhs = NULL;
+ uint sz = 0;
+ for (struct static_route *r2 = r; r2; r2 = r2->mp_next)
+ if (r2->active)
+ sz += NEXTHOP_SIZE_CNT(r2->mls ? r2->mls->length / sizeof(u32) : 0);
- for (r2 = r; r2; r2 = r2->mp_next)
+ if (!sz)
+ goto withdraw;
+
+ struct nexthop_adata *nhad = allocz(sz + sizeof *nhad);
+ struct nexthop *nh = &nhad->nh;
+
+ for (struct static_route *r2 = r; r2; r2 = r2->mp_next)
{
if (!r2->active)
continue;
- struct nexthop *nh = allocz(NEXTHOP_MAX_SIZE);
- nh->gw = r2->via;
- nh->iface = r2->neigh->iface;
- nh->flags = r2->onlink ? RNF_ONLINK : 0;
- nh->weight = r2->weight;
+ *nh = (struct nexthop) {
+ .gw = r2->via,
+ .iface = r2->neigh->iface,
+ .flags = r2->onlink ? RNF_ONLINK : 0,
+ .weight = r2->weight,
+ };
+
if (r2->mls)
{
nh->labels = r2->mls->length / sizeof(u32);
memcpy(nh->label, r2->mls->data, r2->mls->length);
}
- nexthop_insert(&nhs, nh);
+ nh = NEXTHOP_NEXT(nh);
}
- if (!nhs)
- goto withdraw;
-
- nexthop_link(a, nhs);
+ ea_set_attr_data(&a->eattrs, &ea_gen_nexthop, 0,
+ nhad->ad.data, (void *) nh - (void *) nhad->ad.data);
}
if (r->dest == RTDX_RECURSIVE)