]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
L3VPN: using FIB's internal allocator of MPLS labels mpls-new
authorJan Moskyto Matejka <mq@ucw.cz>
Mon, 25 Apr 2016 08:41:04 +0000 (10:41 +0200)
committerJan Moskyto Matejka <mq@ucw.cz>
Mon, 25 Apr 2016 08:41:04 +0000 (10:41 +0200)
proto/l3vpn/l3vpn.c
proto/l3vpn/l3vpn.h

index 9b2c29f0f7e519de080fedd52f3e4bcfe9ddaa58..de5e189ec1417a2f22cd9e289a01891416447712 100644 (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;
-  }
-
-  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;
+  net *n = net_get(p->mpls->table, NULL);
+  if (!n) {
+    log(L_ERR "%s: Couldn't allocate MPLS label.", p->p.name);
+    return;
   }
 
-  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;
 
index 7ed297063f0ea2e0af66fc2f022323d43161e4eb..6bf608ced4249db4cd802b5908aadfae2f7a2620 100644 (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;