0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Merge branch 'mq-aggregator-for-v3' into thread-next

This commit is contained in:
Maria Matejka 2023-11-09 16:34:04 +01:00
commit 4f2212ccf2
3 changed files with 61 additions and 18 deletions

View File

@ -78,7 +78,6 @@
* TODO:
* - protocols should do route refresh instead of restart when reconfiguration
* requires changing labels (e.g. different label range)
* - handle label allocation failures
* - special handling of reserved labels
*/
@ -719,17 +718,21 @@ struct mpls_fec *
mpls_get_fec_by_label(struct mpls_fec_map *m, u32 label)
{
struct mpls_fec *fec = HASH_FIND(m->label_hash, LABEL, label);
/* FIXME: check if (fec->policy == MPLS_POLICY_STATIC) */
if (fec)
return fec;
fec = sl_allocz(mpls_slab(m, 0));
if (!m->static_handle)
m->static_handle = mpls_new_handle(m->domain, m->domain->cf->static_range->range);
fec->label = mpls_new_label(m->domain, m->static_handle, label);
if (fec)
return (fec->policy == MPLS_POLICY_STATIC) ? fec : NULL;
label = mpls_new_label(m->domain, m->static_handle, label);
if (!label)
return NULL;
fec = sl_allocz(mpls_slab(m, 0));
fec->label = label;
fec->policy = MPLS_POLICY_STATIC;
DBG("New FEC lab %u\n", fec->label);
@ -751,13 +754,18 @@ mpls_get_fec_by_net(struct mpls_fec_map *m, const net_addr *net, u32 path_id)
if (fec)
return fec;
u32 label = mpls_new_label(m->domain, m->handle, 0);
if (!label)
return NULL;
fec = sl_allocz(mpls_slab(m, net->type));
fec->hash = hash;
fec->path_id = path_id;
net_copy(fec->net, net);
fec->label = mpls_new_label(m->domain, m->handle, 0);
fec->label = label;
fec->policy = MPLS_POLICY_PREFIX;
DBG("New FEC net %u\n", fec->label);
@ -784,12 +792,20 @@ mpls_get_fec_by_destination(struct mpls_fec_map *m, ea_list *dest)
return fec;
}
u32 label = mpls_new_label(m->domain, m->handle, 0);
if (!label)
{
ea_free(rta->l);
return NULL;
}
fec = sl_allocz(mpls_slab(m, 0));
fec->hash = hash;
fec->rta = rta;
fec->label = mpls_new_label(m->domain, m->handle, 0);
fec->label = label;
fec->policy = MPLS_POLICY_AGGREGATE;
DBG("New FEC rta %u\n", fec->label);
@ -808,9 +824,14 @@ mpls_get_fec_for_vrf(struct mpls_fec_map *m)
if (fec)
return fec;
u32 label = mpls_new_label(m->domain, m->handle, 0);
if (!label)
return NULL;
fec = sl_allocz(mpls_slab(m, 0));
fec->label = mpls_new_label(m->domain, m->handle, 0);
fec->label = label;
fec->policy = MPLS_POLICY_VRF;
fec->iface = m->vrf_iface;
@ -989,7 +1010,7 @@ mpls_apply_fec(rte *r, struct mpls_fec *fec)
}
void
int
mpls_handle_rte(struct mpls_fec_map *m, const net_addr *n, rte *r)
{
struct mpls_fec *fec = NULL;
@ -999,15 +1020,22 @@ mpls_handle_rte(struct mpls_fec_map *m, const net_addr *n, rte *r)
switch (policy)
{
case MPLS_POLICY_NONE:
return;
return 0;
case MPLS_POLICY_STATIC:;
uint label = ea_get_int(r->attrs, &ea_gen_mpls_label, 0);
if (label < 16)
return;
return 0;
fec = mpls_get_fec_by_label(m, label);
if (!fec)
{
log(L_WARN "Static label %u failed for %N from %s",
label, n, r->sender->req->name);
return -1;
}
mpls_damage_fec(m, fec);
break;
@ -1022,14 +1050,22 @@ mpls_handle_rte(struct mpls_fec_map *m, const net_addr *n, rte *r)
case MPLS_POLICY_VRF:
if (!m->vrf_iface)
return;
return 0;
fec = mpls_get_fec_for_vrf(m);
break;
default:
log(L_WARN "Route %N has invalid MPLS policy %u", n, policy);
return;
return -1;
}
/* Label allocation failure */
if (!fec)
{
log(L_WARN "Label allocation in range %s failed for %N from %s",
m->handle->range->name, n, r->sender->req->name);
return -1;
}
/* Temporarily lock FEC */
@ -1041,6 +1077,8 @@ mpls_handle_rte(struct mpls_fec_map *m, const net_addr *n, rte *r)
/* Announce MPLS rule for new/updated FEC */
if (fec->state != MPLS_FEC_CLEAN)
mpls_announce_fec(m, fec, r->attrs);
return 0;
}
static inline struct mpls_fec_tmp_lock

View File

@ -166,7 +166,7 @@ struct mpls_fec *mpls_get_fec_by_label(struct mpls_fec_map *m, u32 label);
struct mpls_fec *mpls_get_fec_by_net(struct mpls_fec_map *m, const net_addr *net, u32 path_id);
struct mpls_fec *mpls_get_fec_by_destination(struct mpls_fec_map *m, ea_list *dest);
void mpls_free_fec(struct mpls_fec_map *x, struct mpls_fec *fec);
void mpls_handle_rte(struct mpls_fec_map *m, const net_addr *n, rte *r);
int mpls_handle_rte(struct mpls_fec_map *m, const net_addr *n, rte *r);
void mpls_rte_preimport(rte *new, const rte *old);

View File

@ -1954,7 +1954,12 @@ rte_update(struct channel *c, const net_addr *n, rte *new, struct rte_src *src)
}
if (new && c->proto->mpls_map)
mpls_handle_rte(c->proto->mpls_map, n, new);
if (mpls_handle_rte(c->proto->mpls_map, n, new) < 0)
{
channel_rte_trace_in(D_FILTERS, c, new, "invalid");
stats->updates_invalid++;
new = NULL;
}
if (new)
if (net_is_flow(n))