summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_mpls_vty.c
diff options
context:
space:
mode:
authorVivek Venkatraman <vivek@cumulusnetworks.com>2017-03-09 17:43:59 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-04-06 16:32:07 +0200
commit1b6d5c7e0873e34bb8674ed0d41795eac7a79960 (patch)
tree48bfeb0483ea57f1a8ed0b31f0228c75d905b4b8 /zebra/zebra_mpls_vty.c
parentbgpd: labeled unicast display (diff)
downloadfrr-1b6d5c7e0873e34bb8674ed0d41795eac7a79960.tar.xz
frr-1b6d5c7e0873e34bb8674ed0d41795eac7a79960.zip
bgpd, zebra: Implement BGP Prefix-SID IETF draft
Implement BGP Prefix-SID IETF draft to be able to signal a labeled-unicast prefix with a label index (segment ID). This makes it easier to deploy global MPLS labels with BGP, even without other aspects of Segment Routing implemented. This patch implements configuration of the global label block (SRGB) and configuration of a label-index for a network in BGP. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_mpls_vty.c')
-rw-r--r--zebra/zebra_mpls_vty.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/zebra/zebra_mpls_vty.c b/zebra/zebra_mpls_vty.c
index 8d8025682..f46037487 100644
--- a/zebra/zebra_mpls_vty.c
+++ b/zebra/zebra_mpls_vty.c
@@ -873,6 +873,7 @@ zebra_mpls_config (struct vty *vty)
write += zebra_mpls_write_lsp_config(vty, zvrf);
write += zebra_mpls_write_fec_config(vty, zvrf);
+ write += zebra_mpls_write_label_block_config (vty, zvrf);
return write;
}
@@ -957,6 +958,85 @@ DEFUN (show_mpls_status,
return CMD_SUCCESS;
}
+static int
+zebra_mpls_global_block (struct vty *vty, int add_cmd,
+ const char *start_label_str, const char *end_label_str)
+{
+ int ret;
+ u_int32_t start_label;
+ u_int32_t end_label;
+ struct zebra_vrf *zvrf;
+
+ zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
+ if (!zvrf)
+ {
+ vty_out (vty, "%% Default VRF does not exist%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if (add_cmd)
+ {
+ if (!start_label_str || !end_label_str)
+ {
+ vty_out (vty, "%% Labels not specified%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ start_label = atoi(start_label_str);
+ end_label = atoi(end_label_str);
+ if (!IS_MPLS_UNRESERVED_LABEL(start_label) ||
+ !IS_MPLS_UNRESERVED_LABEL(end_label))
+ {
+ vty_out (vty, "%% Invalid label%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ if (end_label < start_label)
+ {
+ vty_out (vty, "%% End label is less than Start label%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ ret = zebra_mpls_label_block_add (zvrf, start_label, end_label);
+ }
+ else
+ ret = zebra_mpls_label_block_del (zvrf);
+
+ if (ret)
+ {
+ vty_out (vty, "%% Global label block could not be %s%s",
+ add_cmd ? "added" : "deleted", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ return CMD_SUCCESS;
+}
+
+DEFUN (mpls_label_global_block,
+ mpls_label_global_block_cmd,
+ "mpls label global-block (16-1048575) (16-1048575)",
+ MPLS_STR
+ "Label configuration\n"
+ "Configure global label block\n"
+ "Start label\n"
+ "End label\n")
+{
+ return zebra_mpls_global_block (vty, 1, argv[3]->arg, argv[4]->arg);
+}
+
+DEFUN (no_mpls_label_global_block,
+ no_mpls_label_global_block_cmd,
+ "no mpls label global-block [(16-1048575) (16-1048575)]",
+ NO_STR
+ MPLS_STR
+ "Label configuration\n"
+ "Configure global label block\n"
+ "Start label\n"
+ "End label\n")
+{
+ return zebra_mpls_global_block (vty, 0, NULL, NULL);
+}
+
/* MPLS node for MPLS LSP. */
static struct cmd_node mpls_node = { MPLS_NODE, "", 1 };
@@ -1009,6 +1089,9 @@ zebra_mpls_vty_init (void)
install_element (CONFIG_NODE, &mpls_label_bind_cmd);
install_element (CONFIG_NODE, &no_mpls_label_bind_cmd);
+ install_element (CONFIG_NODE, &mpls_label_global_block_cmd);
+ install_element (CONFIG_NODE, &no_mpls_label_global_block_cmd);
+
install_element (VIEW_NODE, &show_mpls_table_cmd);
install_element (VIEW_NODE, &show_mpls_table_lsp_cmd);
install_element (VIEW_NODE, &show_mpls_fec_cmd);