]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: lsp_install() failed due to ZEBRA_FLAG_SELECTED check
authorDaniel Walton <dwalton@cumulusnetworks.com>
Wed, 10 May 2017 13:42:00 +0000 (09:42 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 10 May 2017 14:06:47 +0000 (10:06 -0400)
ZEBRA_FLAG_SELECTED hasn't been set yet by the time lsp_install is
called.  The call path is:
rib_process -> rib_process_add_fib -> zebra_mpls_lsp_install -> lsp_install

but ZEBRA_FLAG_SELECTED is set in rib_process after it calls
rib_process_add_fib.  I can't think of anything that it would hurt to
install the LSP regardless of whether ZEBRA_FLAG_SELECTED is set later.

I also cleaned up some UI (json and display the pretty label names
instead of their numeric values).

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
zebra/zebra_mpls.c
zebra/zebra_mpls.h
zebra/zebra_mpls_null.c
zebra/zebra_vty.c

index 76263024c5416b789e94d1edc0fddca8851efe8a..bb9c913e3cf3504b3314cac32e66401df15e53cf 100644 (file)
@@ -185,10 +185,6 @@ lsp_install (struct zebra_vrf *zvrf, mpls_label_t label,
   if (!lsp_table)
     return -1;
 
-  /* See if route entry is selected; we really expect only 1 entry here. */
-  if (!CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
-    return 0;
-
   lsp_type = lsp_type_from_rib_type (rib->type);
   added = changed = 0;
 
@@ -1766,13 +1762,29 @@ mpls_str2label (const char *label_str, u_int8_t *num_labels,
  */
 char *
 mpls_label2str (u_int8_t num_labels, mpls_label_t *labels,
-                char *buf, int len)
+                char *buf, int len, int pretty)
 {
+  char *buf_ptr = buf;
   buf[0] = '\0';
-  if (num_labels == 1)
-    snprintf (buf, len, "%u", labels[0]);
-  else if (num_labels == 2)
-    snprintf (buf, len, "%u/%u", labels[0], labels[1]);
+
+  if (pretty) {
+    if (num_labels == 1) {
+      label2str(labels[0], buf, len);
+    } else if (num_labels == 2) {
+      label2str(labels[0], buf, len);
+      buf_ptr += strlen(buf);
+
+      snprintf (buf_ptr, len, "/");
+      buf_ptr++;
+
+      label2str(labels[1], buf_ptr, len);
+   }
+  } else {
+    if (num_labels == 1)
+      snprintf (buf, len, "%u", labels[0]);
+    else if (num_labels == 2)
+      snprintf (buf, len, "%u/%u", labels[0], labels[1]);
+  }
   return buf;
 }
 
index e271edd2eb4c78f5a89febb47740b73b7b30bba9..b5a8f3173e8fa38d7074b17069360bada9515b58 100644 (file)
@@ -184,7 +184,7 @@ mpls_str2label (const char *label_str, u_int8_t *num_labels,
  */
 char *
 mpls_label2str (u_int8_t num_labels, mpls_label_t *labels,
-                char *buf, int len);
+                char *buf, int len, int pretty);
 
 /*
  * Add/update global label block.
index 168c8d003c28572780e39128c2ecc8df47e0f803..0333b6e6b46226405cdc8e3593a452075102778c 100644 (file)
@@ -32,7 +32,7 @@ int mpls_enabled;
 
 char *
 mpls_label2str (u_int8_t num_labels, mpls_label_t *labels,
-                char *buf, int len)
+                char *buf, int len, int pretty)
 {
   return NULL;
 }
index 1708138d83e4f38591e31e729a15cfb17f3d487b..186a2d022ed7ce84722979cd6574c95bafb72194 100644 (file)
@@ -781,9 +781,9 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
           /* Label information */
          if (nexthop->nh_label && nexthop->nh_label->num_labels)
            {
-             vty_out (vty, " label %s",
+             vty_out (vty, ", label %s",
                       mpls_label2str (nexthop->nh_label->num_labels,
-                                      nexthop->nh_label->label, buf, BUFSIZ));
+                                      nexthop->nh_label->label, buf, BUFSIZ, 1));
            }
 
          vty_out (vty, "%s", VTY_NEWLINE);
@@ -803,6 +803,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
   json_object *json_nexthops = NULL;
   json_object *json_nexthop = NULL;
   json_object *json_route = NULL;
+  json_object *json_labels = NULL;
 
   if (json)
     {
@@ -932,6 +933,16 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
                 break;
             }
 
+          if (nexthop->nh_label && nexthop->nh_label->num_labels)
+            {
+              json_labels = json_object_new_array();
+
+              for (int label_index = 0; label_index < nexthop->nh_label->num_labels; label_index++)
+                json_object_array_add(json_labels, json_object_new_int(nexthop->nh_label->label[label_index]));
+
+              json_object_object_add(json_nexthop, "labels", json_labels);
+            }
+
           json_object_array_add(json_nexthops, json_nexthop);
         }
 
@@ -1030,9 +1041,9 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib,
       /* Label information */
       if (nexthop->nh_label && nexthop->nh_label->num_labels)
        {
-         vty_out (vty, " label %s",
+         vty_out (vty, ", label %s",
                   mpls_label2str (nexthop->nh_label->num_labels,
-                                  nexthop->nh_label->label, buf, BUFSIZ));
+                                  nexthop->nh_label->label, buf, BUFSIZ, 1));
        }
 
       if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
@@ -2319,7 +2330,7 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
             if (si->snh_label.num_labels)
               vty_out (vty, " label %s",
                        mpls_label2str (si->snh_label.num_labels,
-                                       si->snh_label.label, buf, sizeof buf));
+                                       si->snh_label.label, buf, sizeof buf, 0));
 
             vty_out (vty, "%s", VTY_NEWLINE);
 
@@ -3812,7 +3823,7 @@ static_config_ipv6 (struct vty *vty)
             if (si->snh_label.num_labels)
               vty_out (vty, " label %s",
                        mpls_label2str (si->snh_label.num_labels,
-                                       si->snh_label.label, buf, sizeof buf));
+                                       si->snh_label.label, buf, sizeof buf, 0));
 
             vty_out (vty, "%s", VTY_NEWLINE);