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

L3VPN: using FIB's internal allocator of MPLS labels

This commit is contained in:
Jan Moskyto Matejka 2016-04-25 10:41:04 +02:00
parent 6adf16ca1b
commit 9667c798fc
2 changed files with 6 additions and 23 deletions

View File

@ -3,36 +3,21 @@
static void
l3vpn_alloc_mpls_label(struct l3vpn_proto *p, struct l3vpn_ip_to_mpls *litm, ip_addr gw, struct iface *iface)
{
u32 label;
net_addr_union nu;
for (label = p->last_label + 1; label <= MPLS_LABEL_MAX; label++) {
nu.mpls = NET_ADDR_MPLS(label);
net *n = net_get(p->mpls->table, &nu.n);
if (!n->routes)
goto have_label;
net *n = net_get(p->mpls->table, NULL);
if (!n) {
log(L_ERR "%s: Couldn't allocate MPLS label.", p->p.name);
return;
}
for (label = 16; label <= p->last_label; label++) {
nu.mpls = NET_ADDR_MPLS(label);
net *n = net_get(p->mpls->table, &nu.n);
if (!n->routes)
goto have_label;
}
return;
have_label:;
p->last_label = label;
rta a = {};
a.gw = gw;
a.src = p->p.main_source;
a.iface = iface;
rte *e = rte_get_temp(rta_lookup(&a));
rte_update2(p->mpls, &nu.n, e, p->p.main_source);
rte_update2(p->mpls, n->n.addr, e, p->p.main_source);
litm->ad.length = sizeof(u32);
memcpy(litm->ad.data, &label, sizeof(u32));
memcpy(litm->ad.data, &((net_addr_mpls *)n->n.addr)->label, sizeof(u32));
}
static ea_list *
@ -157,7 +142,6 @@ l3vpn_init(struct proto_config *CF)
p->ip = proto_add_channel(P, cf->ip);
p->mpls = proto_add_channel(P, cf->mpls);
p->rd = cf->rd;
p->last_label = 16;
P->rt_notify = l3vpn_rt_notify;

View File

@ -32,7 +32,6 @@ struct l3vpn_proto {
struct fib iptompls; /* FIB to lookup IP->MPLS mappings */
u64 rd; /* VPN route distinguisher */
u32 last_label; /* Last allocated label */
};
extern struct protocol proto_l3vpn;