zebra: lsp_install() failed due to ZEBRA_FLAG_SELECTED check

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>
This commit is contained in:
Daniel Walton 2017-05-10 09:42:00 -04:00 committed by Donald Sharp
parent b5ab78e691
commit 4caac24b23
4 changed files with 40 additions and 17 deletions

View 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;
}

View 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.

View 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;
}

View 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);