route should be installed as valid. */
static int
bgp_static_set (struct vty *vty, const char *ip_str,
- afi_t afi, safi_t safi, const char *rmap, int backdoor)
+ afi_t afi, safi_t safi, const char *rmap, int backdoor,
+ u_int32_t label_index)
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
/* Configuration change. */
bgp_static = rn->info;
+ /* Label index cannot be changed. */
+ if (bgp_static->label_index != label_index)
+ {
+ vty_out (vty, "%% Label index cannot be changed%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
/* Check previous routes are installed into BGP. */
if (bgp_static->valid && bgp_static->backdoor != backdoor)
need_update = 1;
bgp_static->valid = 0;
bgp_static->igpmetric = 0;
bgp_static->igpnexthop.s_addr = 0;
+ bgp_static->label_index = label_index;
if (rmap)
{
{
int idx_ipv4_prefixlen = 1;
return bgp_static_set (vty, argv[idx_ipv4_prefixlen]->arg,
- AFI_IP, bgp_node_safi (vty), NULL, 0);
+ AFI_IP, bgp_node_safi (vty), NULL, 0,
+ BGP_INVALID_LABEL_INDEX);
}
DEFUN (bgp_network_route_map,
int idx_ipv4_prefixlen = 1;
int idx_word = 3;
return bgp_static_set (vty, argv[idx_ipv4_prefixlen]->arg,
- AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0);
+ AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0,
+ BGP_INVALID_LABEL_INDEX);
}
DEFUN (bgp_network_backdoor,
{
int idx_ipv4_prefixlen = 1;
return bgp_static_set (vty, argv[idx_ipv4_prefixlen]->arg, AFI_IP, SAFI_UNICAST,
- NULL, 1);
+ NULL, 1, BGP_INVALID_LABEL_INDEX);
}
DEFUN (bgp_network_mask,
}
return bgp_static_set (vty, prefix_str,
- AFI_IP, bgp_node_safi (vty), NULL, 0);
+ AFI_IP, bgp_node_safi (vty), NULL, 0, BGP_INVALID_LABEL_INDEX);
}
DEFUN (bgp_network_mask_route_map,
}
return bgp_static_set (vty, prefix_str,
- AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0);
+ AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0, BGP_INVALID_LABEL_INDEX);
}
DEFUN (bgp_network_mask_backdoor,
}
return bgp_static_set (vty, prefix_str, AFI_IP, SAFI_UNICAST,
- NULL, 1);
+ NULL, 1,
+ BGP_INVALID_LABEL_INDEX);
}
DEFUN (bgp_network_mask_natural,
}
return bgp_static_set (vty, prefix_str,
- AFI_IP, bgp_node_safi (vty), NULL, 0);
+ AFI_IP, bgp_node_safi (vty), NULL, 0,
+ BGP_INVALID_LABEL_INDEX);
}
DEFUN (bgp_network_mask_natural_route_map,
}
return bgp_static_set (vty, prefix_str,
- AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0);
+ AFI_IP, bgp_node_safi (vty), argv[idx_word]->arg, 0,
+ BGP_INVALID_LABEL_INDEX);
}
DEFUN (bgp_network_mask_natural_backdoor,
}
return bgp_static_set (vty, prefix_str, AFI_IP, SAFI_UNICAST,
- NULL, 1);
+ NULL, 1, BGP_INVALID_LABEL_INDEX);
+}
+
+DEFUN (bgp_network_label_index,
+ bgp_network_label_index_cmd,
+ "network A.B.C.D/M label-index (0-4294967294)",
+ "Specify a network to announce via BGP\n"
+ "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+ "Label index to associate with the prefix\n"
+ "Label index value\n")
+{
+ u_int32_t label_index;
+
+ VTY_GET_INTEGER ("label-index", label_index, argv[3]->arg);
+ return bgp_static_set (vty, argv[1]->arg,
+ AFI_IP, bgp_node_safi (vty), NULL, 0, label_index);
+}
+
+DEFUN (bgp_network_label_index_route_map,
+ bgp_network_label_index_route_map_cmd,
+ "network A.B.C.D/M label-index (0-4294967294) route-map WORD",
+ "Specify a network to announce via BGP\n"
+ "IP prefix\n"
+ "Label index to associate with the prefix\n"
+ "Label index value\n"
+ "Route-map to modify the attributes\n"
+ "Name of the route map\n")
+{
+ u_int32_t label_index;
+
+ VTY_GET_INTEGER ("label-index", label_index, argv[3]->arg);
+ return bgp_static_set (vty, argv[1]->arg,
+ AFI_IP, bgp_node_safi (vty), argv[5]->arg, 0, label_index);
}
DEFUN (no_bgp_network,
bgp_node_safi (vty));
}
+ALIAS (no_bgp_network,
+ no_bgp_network_label_index_cmd,
+ "no network A.B.C.D/M label-index (0-4294967294)",
+ NO_STR
+ "Specify a network to announce via BGP\n"
+ "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+ "Label index to associate with the prefix\n"
+ "Label index value\n")
+
+ALIAS (no_bgp_network,
+ no_bgp_network_label_index_route_map_cmd,
+ "no network A.B.C.D/M label-index (0-4294967294)route-map WORD",
+ NO_STR
+ "Specify a network to announce via BGP\n"
+ "IP prefix\n"
+ "Label index to associate with the prefix\n"
+ "Label index value\n"
+ "Route-map to modify the attributes\n"
+ "Name of the route map\n")
+
DEFUN (ipv6_bgp_network,
ipv6_bgp_network_cmd,
"network X:X::X:X/M",
{
int idx_ipv6_prefixlen = 1;
return bgp_static_set (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, bgp_node_safi(vty),
- NULL, 0);
+ NULL, 0,
+ BGP_INVALID_LABEL_INDEX);
}
DEFUN (ipv6_bgp_network_route_map,
int idx_ipv6_prefixlen = 1;
int idx_word = 3;
return bgp_static_set (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6,
- bgp_node_safi (vty), argv[idx_word]->arg, 0);
+ bgp_node_safi (vty), argv[idx_word]->arg, 0,
+ BGP_INVALID_LABEL_INDEX);
+}
+
+DEFUN (ipv6_bgp_network_label_index,
+ ipv6_bgp_network_label_index_cmd,
+ "network X:X::X:X/M label-index (0-4294967294)",
+ "Specify a network to announce via BGP\n"
+ "IPv6 prefix <network>/<length>\n"
+ "Label index to associate with the prefix\n"
+ "Label index value\n")
+{
+ u_int32_t label_index;
+
+ VTY_GET_INTEGER ("label-index", label_index, argv[3]->arg);
+ return bgp_static_set (vty, argv[1]->arg,
+ AFI_IP6, bgp_node_safi (vty), NULL, 0, label_index);
+}
+
+DEFUN (ipv6_bgp_network_label_index_route_map,
+ ipv6_bgp_network_label_index_route_map_cmd,
+ "network X:X::X:X/M label-index (0-4294967294) route-map WORD",
+ "Specify a network to announce via BGP\n"
+ "IPv6 prefix\n"
+ "Label index to associate with the prefix\n"
+ "Label index value\n"
+ "Route-map to modify the attributes\n"
+ "Name of the route map\n")
+{
+ u_int32_t label_index;
+
+ VTY_GET_INTEGER ("label-index", label_index, argv[3]->arg);
+ return bgp_static_set (vty, argv[1]->arg,
+ AFI_IP6, bgp_node_safi (vty), argv[5]->arg, 0, label_index);
}
DEFUN (no_ipv6_bgp_network,
return bgp_static_unset (vty, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, bgp_node_safi(vty));
}
+ALIAS (no_ipv6_bgp_network,
+ no_ipv6_bgp_network_label_index_cmd,
+ "no network X:X::X:X/M label-index (0-4294967294)",
+ NO_STR
+ "Specify a network to announce via BGP\n"
+ "IPv6 prefix <network>/<length>\n"
+ "Label index to associate with the prefix\n"
+ "Label index value\n")
+
+ALIAS (no_ipv6_bgp_network,
+ no_ipv6_bgp_network_label_index_route_map_cmd,
+ "no network X:X::X:X/M label-index (0-4294967294) route-map WORD",
+ NO_STR
+ "Specify a network to announce via BGP\n"
+ "IPv6 prefix\n"
+ "Label index to associate with the prefix\n"
+ "Label index value\n"
+ "Route-map to modify the attributes\n"
+ "Name of the route map\n")
+
/* Aggreagete address:
advertise-map Set condition to advertise attribute
p->prefixlen);
}
+ if (bgp_static->label_index != BGP_INVALID_LABEL_INDEX)
+ vty_out (vty, " label-index %u", bgp_static->label_index);
+
if (bgp_static->rmap.name)
vty_out (vty, " route-map %s", bgp_static->rmap.name);
else
install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
+ install_element (BGP_IPV4_NODE, &no_bgp_network_label_index_cmd);
+ install_element (BGP_IPV4_NODE, &no_bgp_network_label_index_route_map_cmd);
install_element (BGP_IPV4_NODE, &no_bgp_table_map_cmd);
install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
install_element (BGP_IPV4L_NODE, &bgp_network_route_map_cmd);
install_element (BGP_IPV4L_NODE, &bgp_network_mask_route_map_cmd);
install_element (BGP_IPV4L_NODE, &bgp_network_mask_natural_route_map_cmd);
+ install_element (BGP_IPV4L_NODE, &bgp_network_label_index_cmd);
+ install_element (BGP_IPV4L_NODE, &bgp_network_label_index_route_map_cmd);
install_element (BGP_IPV4L_NODE, &no_bgp_table_map_cmd);
install_element (BGP_IPV4L_NODE, &no_bgp_network_cmd);
install_element (BGP_IPV4L_NODE, &no_bgp_network_mask_cmd);
install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
install_element (BGP_IPV6_NODE, &no_bgp_table_map_cmd);
install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
+ install_element (BGP_IPV6_NODE, &ipv6_bgp_network_label_index_cmd);
+ install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_label_index_cmd);
+ install_element (BGP_IPV6_NODE, &ipv6_bgp_network_label_index_route_map_cmd);
+ install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_label_index_route_map_cmd);
install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
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;
}
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 };
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);