summaryrefslogtreecommitdiff
path: root/zebra/zebra_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_vty.c')
-rw-r--r--zebra/zebra_vty.c876
1 files changed, 175 insertions, 701 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index e6563c4f54..73f0717124 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -50,11 +50,16 @@ extern int allow_delete;
static int do_show_ip_route(struct vty *vty, const char *vrf_name, afi_t afi,
safi_t safi, bool use_fib, u_char use_json,
- route_tag_t tag, struct prefix *longer_prefix_p,
+ route_tag_t tag,
+ const struct prefix *longer_prefix_p,
bool supernets_only, int type,
u_short ospf_instance_id);
static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
int mcast);
+static void vty_show_ip_route_summary(struct vty *vty,
+ struct route_table *table);
+static void vty_show_ip_route_summary_prefix(struct vty *vty,
+ struct route_table *table);
/* VNI range as per RFC 7432 */
#define CMD_VNI_RANGE "(1-16777215)"
@@ -936,14 +941,10 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
}
}
-static bool use_fib(struct cmd_token *token)
-{
- return strncmp(token->arg, "route", strlen(token->arg));
-}
-
static int do_show_ip_route(struct vty *vty, const char *vrf_name, afi_t afi,
safi_t safi, bool use_fib, u_char use_json,
- route_tag_t tag, struct prefix *longer_prefix_p,
+ route_tag_t tag,
+ const struct prefix *longer_prefix_p,
bool supernets_only, int type,
u_short ospf_instance_id)
{
@@ -1201,14 +1202,33 @@ DEFUN (no_ipv6_nht_default_route,
return CMD_SUCCESS;
}
-DEFUN (show_ip_route,
- show_ip_route_cmd,
- "show ip <fib|route> [vrf NAME] [tag (1-4294967295)|A.B.C.D/M longer-prefixes|supernets-only|" FRR_IP_REDIST_STR_ZEBRA "|ospf (1-65535)] [json]",
+DEFPY (show_route,
+ show_route_cmd,
+ "show\
+ <\
+ ip$ipv4 <fib$fib|route> [vrf <NAME$vrf_name|all$vrf_all>]\
+ [{\
+ tag (1-4294967295)\
+ |A.B.C.D/M$prefix longer-prefixes\
+ |supernets-only$supernets_only\
+ }]\
+ [<\
+ " FRR_IP_REDIST_STR_ZEBRA "$type_str\
+ |ospf$type_str (1-65535)$ospf_instance_id\
+ >]\
+ |ipv6$ipv6 <fib$fib|route> [vrf <NAME$vrf_name|all$vrf_all>]\
+ [{\
+ tag (1-4294967295)\
+ |X:X::X:X/M$prefix longer-prefixes\
+ }]\
+ [" FRR_IP6_REDIST_STR_ZEBRA "$type_str]\
+ >\
+ [json$json]",
SHOW_STR
IP_STR
"IP forwarding table\n"
"IP routing table\n"
- VRF_CMD_HELP_STR
+ VRF_FULL_CMD_HELP_STR
"Show only routes with tag\n"
"Tag value\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
@@ -1217,75 +1237,23 @@ DEFUN (show_ip_route,
FRR_IP_REDIST_HELP_STR_ZEBRA
"Open Shortest Path First (OSPFv2)\n"
"Instance ID\n"
+ IPV6_STR
+ "IP forwarding table\n"
+ "IP routing table\n"
+ VRF_FULL_CMD_HELP_STR
+ "Show only routes with tag\n"
+ "Tag value\n"
+ "IPv6 prefix\n"
+ "Show route matching the specified Network/Mask pair only\n"
+ FRR_IP6_REDIST_HELP_STR_ZEBRA
JSON_STR)
{
- bool uf = use_fib(argv[2]);
- struct route_table *table;
- int vrf_all = 0;
- route_tag_t tag = 0;
- vrf_id_t vrf_id = VRF_DEFAULT;
+ afi_t afi = ipv4 ? AFI_IP : AFI_IP6;
struct vrf *vrf;
- struct zebra_vrf *zvrf;
- int uj = use_json(argc, argv);
- int idx = 0;
- struct prefix p;
- bool longer_prefixes = false;
- bool supernets_only = false;
int type = 0;
- u_short ospf_instance_id = 0;
-
- if (argv_find(argv, argc, "vrf", &idx)) {
- if (strmatch(argv[idx + 1]->arg, "all"))
- vrf_all = 1;
- else
- VRF_GET_ID(vrf_id, argv[idx + 1]->arg);
- }
-
- if (argv_find(argv, argc, "tag", &idx))
- tag = strtoul(argv[idx + 1]->arg, NULL, 10);
-
- else if (argv_find(argv, argc, "A.B.C.D/M", &idx)) {
- if (str2prefix(argv[idx]->arg, &p) <= 0) {
- vty_out(vty, "%% Malformed prefix\n");
- return CMD_WARNING;
- }
- longer_prefixes = true;
- }
-
- else if (argv_find(argv, argc, "supernets_only", &idx))
- supernets_only = true;
-
- else {
- if (argv_find(argv, argc, "kernel", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
- else if (argv_find(argv, argc, "babel", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
- else if (argv_find(argv, argc, "connected", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
- else if (argv_find(argv, argc, "static", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
- else if (argv_find(argv, argc, "rip", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
- else if (argv_find(argv, argc, "ospf", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
- else if (argv_find(argv, argc, "isis", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
- else if (argv_find(argv, argc, "bgp", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
- else if (argv_find(argv, argc, "pim", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
- else if (argv_find(argv, argc, "eigrp", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
- else if (argv_find(argv, argc, "nhrp", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
- else if (argv_find(argv, argc, "table", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
- else if (argv_find(argv, argc, "vnc", &idx))
- type = proto_redistnum(AFI_IP, argv[idx]->text);
-
- if (argv_find(argv, argc, "(1-65535)", &idx))
- ospf_instance_id = strtoul(argv[idx]->arg, NULL, 10);
+ if (type_str) {
+ type = proto_redistnum(afi, type_str);
if (type < 0) {
vty_out(vty, "Unknown route type\n");
return CMD_WARNING;
@@ -1294,114 +1262,178 @@ DEFUN (show_ip_route,
if (vrf_all) {
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
+ struct zebra_vrf *zvrf;
+ struct route_table *table;
+
if ((zvrf = vrf->info) == NULL
- || (table = zvrf->table[AFI_IP][SAFI_UNICAST])
- == NULL)
+ || (table = zvrf->table[afi][SAFI_UNICAST]) == NULL)
continue;
do_show_ip_route(
- vty, zvrf_name(zvrf), AFI_IP, SAFI_UNICAST, uf,
- uj, tag, longer_prefixes ? &p : NULL,
- supernets_only, type, ospf_instance_id);
+ vty, zvrf_name(zvrf), afi, SAFI_UNICAST, !!fib,
+ !!json, tag, prefix_str ? prefix : NULL,
+ !!supernets_only, type, ospf_instance_id);
}
} else {
+ vrf_id_t vrf_id = VRF_DEFAULT;
+
+ if (vrf_name)
+ VRF_GET_ID(vrf_id, vrf_name);
vrf = vrf_lookup_by_id(vrf_id);
- do_show_ip_route(vty, vrf->name, AFI_IP, SAFI_UNICAST, uf, uj,
- tag, longer_prefixes ? &p : NULL,
- supernets_only, type, ospf_instance_id);
+ do_show_ip_route(vty, vrf->name, afi, SAFI_UNICAST, !!fib,
+ !!json, tag, prefix_str ? prefix : NULL,
+ !!supernets_only, type, ospf_instance_id);
}
+
return CMD_SUCCESS;
}
-DEFUN (show_ip_route_addr,
- show_ip_route_addr_cmd,
- "show ip route [vrf NAME] A.B.C.D",
+DEFPY (show_route_detail,
+ show_route_detail_cmd,
+ "show\
+ <\
+ ip$ipv4 route [vrf <NAME$vrf_name|all$vrf_all>]\
+ <\
+ A.B.C.D$address\
+ |A.B.C.D/M$prefix\
+ >\
+ |ipv6$ipv6 route [vrf <NAME$vrf_name|all$vrf_all>]\
+ <\
+ X:X::X:X$address\
+ |X:X::X:X/M$prefix\
+ >\
+ >",
SHOW_STR
IP_STR
"IP routing table\n"
- VRF_CMD_HELP_STR
- "Network in the IP routing table to display\n")
+ VRF_FULL_CMD_HELP_STR
+ "Network in the IP routing table to display\n"
+ "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+ IP6_STR
+ "IP routing table\n"
+ VRF_FULL_CMD_HELP_STR
+ "IPv6 Address\n"
+ "IPv6 prefix\n")
{
- int ret;
- struct prefix_ipv4 p;
+ afi_t afi = ipv4 ? AFI_IP : AFI_IP6;
struct route_table *table;
+ struct prefix p;
struct route_node *rn;
- vrf_id_t vrf_id = VRF_DEFAULT;
- if (strmatch(argv[3]->text, "vrf")) {
- VRF_GET_ID(vrf_id, argv[4]->arg);
- ret = str2prefix_ipv4(argv[5]->arg, &p);
- } else {
- ret = str2prefix_ipv4(argv[3]->arg, &p);
- }
-
- if (ret <= 0) {
- vty_out(vty, "%% Malformed IPv4 address\n");
+ if (address_str)
+ prefix_str = address_str;
+ if (str2prefix(prefix_str, &p) < 0) {
+ vty_out(vty, "%% Malformed address\n");
return CMD_WARNING;
}
- table = zebra_vrf_table(AFI_IP, SAFI_UNICAST, vrf_id);
- if (!table)
- return CMD_SUCCESS;
+ if (vrf_all) {
+ struct vrf *vrf;
+ struct zebra_vrf *zvrf;
- rn = route_node_match(table, (struct prefix *)&p);
- if (!rn) {
- vty_out(vty, "%% Network not in table\n");
- return CMD_WARNING;
- }
+ RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
+ if ((zvrf = vrf->info) == NULL
+ || (table = zvrf->table[afi][SAFI_UNICAST]) == NULL)
+ continue;
+
+ rn = route_node_match(table, &p);
+ if (!rn)
+ continue;
+ if (!address_str && rn->p.prefixlen != p.prefixlen) {
+ route_unlock_node(rn);
+ continue;
+ }
+
+ vty_show_ip_route_detail(vty, rn, 0);
+
+ route_unlock_node(rn);
+ }
+ } else {
+ vrf_id_t vrf_id = VRF_DEFAULT;
+
+ if (vrf_name)
+ VRF_GET_ID(vrf_id, vrf_name);
+
+ table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id);
+ if (!table)
+ return CMD_SUCCESS;
+
+ rn = route_node_match(table, &p);
+ if (!rn) {
+ vty_out(vty, "%% Network not in table\n");
+ return CMD_WARNING;
+ }
+ if (!address_str && rn->p.prefixlen != p.prefixlen) {
+ vty_out(vty, "%% Network not in table\n");
+ route_unlock_node(rn);
+ return CMD_WARNING;
+ }
- vty_show_ip_route_detail(vty, rn, 0);
+ vty_show_ip_route_detail(vty, rn, 0);
- route_unlock_node(rn);
+ route_unlock_node(rn);
+ }
return CMD_SUCCESS;
}
-DEFUN (show_ip_route_prefix,
- show_ip_route_prefix_cmd,
- "show ip route [vrf NAME] A.B.C.D/M",
+DEFPY (show_route_summary,
+ show_route_summary_cmd,
+ "show\
+ <\
+ ip$ipv4 route [vrf <NAME$vrf_name|all$vrf_all>]\
+ summary [prefix$prefix]\
+ |ipv6$ipv6 route [vrf <NAME$vrf_name|all$vrf_all>]\
+ summary [prefix$prefix]\
+ >",
SHOW_STR
IP_STR
"IP routing table\n"
- VRF_CMD_HELP_STR
- "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
+ VRF_FULL_CMD_HELP_STR
+ "Summary of all routes\n"
+ "Prefix routes\n"
+ IP6_STR
+ "IP routing table\n"
+ VRF_FULL_CMD_HELP_STR
+ "Summary of all routes\n"
+ "Prefix routes\n")
{
- int ret;
- struct prefix_ipv4 p;
+ afi_t afi = ipv4 ? AFI_IP : AFI_IP6;
struct route_table *table;
- struct route_node *rn;
- vrf_id_t vrf_id = VRF_DEFAULT;
- if (strmatch(argv[3]->text, "vrf")) {
- VRF_GET_ID(vrf_id, argv[4]->arg);
- ret = str2prefix_ipv4(argv[5]->arg, &p);
- } else {
- ret = str2prefix_ipv4(argv[3]->arg, &p);
- }
+ if (vrf_all) {
+ struct vrf *vrf;
+ struct zebra_vrf *zvrf;
- if (ret <= 0) {
- vty_out(vty, "%% Malformed IPv4 address\n");
- return CMD_WARNING;
- }
+ RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) {
+ if ((zvrf = vrf->info) == NULL
+ || (table = zvrf->table[afi][SAFI_UNICAST]) == NULL)
+ continue;
- table = zebra_vrf_table(AFI_IP, SAFI_UNICAST, vrf_id);
- if (!table)
- return CMD_SUCCESS;
+ if (prefix)
+ vty_show_ip_route_summary_prefix(vty, table);
+ else
+ vty_show_ip_route_summary(vty, table);
+ }
+ } else {
+ vrf_id_t vrf_id = VRF_DEFAULT;
- rn = route_node_match(table, (struct prefix *)&p);
- if (!rn || rn->p.prefixlen != p.prefixlen) {
- vty_out(vty, "%% Network not in table\n");
- return CMD_WARNING;
- }
+ if (vrf_name)
+ VRF_GET_ID(vrf_id, vrf_name);
- vty_show_ip_route_detail(vty, rn, 0);
+ table = zebra_vrf_table(afi, SAFI_UNICAST, vrf_id);
+ if (!table)
+ return CMD_SUCCESS;
- route_unlock_node(rn);
+ if (prefix)
+ vty_show_ip_route_summary_prefix(vty, table);
+ else
+ vty_show_ip_route_summary(vty, table);
+ }
return CMD_SUCCESS;
}
-
static void vty_show_ip_route_summary(struct vty *vty,
struct route_table *table)
{
@@ -1540,183 +1572,6 @@ static void vty_show_ip_route_summary_prefix(struct vty *vty,
vty_out(vty, "\n");
}
-/* Show route summary. */
-DEFUN (show_ip_route_summary,
- show_ip_route_summary_cmd,
- "show ip route [vrf NAME] summary",
- SHOW_STR
- IP_STR
- "IP routing table\n"
- VRF_CMD_HELP_STR
- "Summary of all routes\n")
-{
- struct route_table *table;
- vrf_id_t vrf_id = VRF_DEFAULT;
-
- if (strmatch(argv[3]->text, "vrf"))
- VRF_GET_ID(vrf_id, argv[4]->arg);
-
- table = zebra_vrf_table(AFI_IP, SAFI_UNICAST, vrf_id);
- if (!table)
- return CMD_SUCCESS;
-
- vty_show_ip_route_summary(vty, table);
-
- return CMD_SUCCESS;
-}
-
-/* Show route summary prefix. */
-DEFUN (show_ip_route_summary_prefix,
- show_ip_route_summary_prefix_cmd,
- "show ip route [vrf NAME] summary prefix",
- SHOW_STR
- IP_STR
- "IP routing table\n"
- VRF_CMD_HELP_STR
- "Summary of all routes\n"
- "Prefix routes\n")
-{
- struct route_table *table;
- vrf_id_t vrf_id = VRF_DEFAULT;
-
- if (strmatch(argv[3]->text, "vrf"))
- VRF_GET_ID(vrf_id, argv[4]->arg);
-
- table = zebra_vrf_table(AFI_IP, SAFI_UNICAST, vrf_id);
- if (!table)
- return CMD_SUCCESS;
-
- vty_show_ip_route_summary_prefix(vty, table);
-
- return CMD_SUCCESS;
-}
-
-
-DEFUN (show_ip_route_vrf_all_addr,
- show_ip_route_vrf_all_addr_cmd,
- "show ip route vrf all A.B.C.D",
- SHOW_STR
- IP_STR
- "IP routing table\n"
- VRF_ALL_CMD_HELP_STR
- "Network in the IP routing table to display\n")
-{
- int idx_ipv4 = 5;
- int ret;
- struct prefix_ipv4 p;
- struct route_table *table;
- struct route_node *rn;
- struct vrf *vrf;
- struct zebra_vrf *zvrf;
-
- ret = str2prefix_ipv4(argv[idx_ipv4]->arg, &p);
- if (ret <= 0) {
- vty_out(vty, "%% Malformed IPv4 address\n");
- return CMD_WARNING;
- }
-
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
- if ((zvrf = vrf->info) == NULL
- || (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
- continue;
-
- rn = route_node_match(table, (struct prefix *)&p);
- if (!rn)
- continue;
-
- vty_show_ip_route_detail(vty, rn, 0);
-
- route_unlock_node(rn);
- }
-
- return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_route_vrf_all_prefix,
- show_ip_route_vrf_all_prefix_cmd,
- "show ip route vrf all A.B.C.D/M",
- SHOW_STR
- IP_STR
- "IP routing table\n"
- VRF_ALL_CMD_HELP_STR
- "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
-{
- int idx_ipv4_prefixlen = 5;
- int ret;
- struct prefix_ipv4 p;
- struct route_table *table;
- struct route_node *rn;
- struct vrf *vrf;
- struct zebra_vrf *zvrf;
-
- ret = str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p);
- if (ret <= 0) {
- vty_out(vty, "%% Malformed IPv4 address\n");
- return CMD_WARNING;
- }
-
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
- if ((zvrf = vrf->info) == NULL
- || (table = zvrf->table[AFI_IP][SAFI_UNICAST]) == NULL)
- continue;
-
- rn = route_node_match(table, (struct prefix *)&p);
- if (!rn)
- continue;
- if (rn->p.prefixlen != p.prefixlen) {
- route_unlock_node(rn);
- continue;
- }
-
- vty_show_ip_route_detail(vty, rn, 0);
-
- route_unlock_node(rn);
- }
-
- return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_route_vrf_all_summary,
- show_ip_route_vrf_all_summary_cmd,
- "show ip route vrf all summary ",
- SHOW_STR
- IP_STR
- "IP routing table\n"
- VRF_ALL_CMD_HELP_STR
- "Summary of all routes\n")
-{
- struct vrf *vrf;
- struct zebra_vrf *zvrf;
-
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
- if ((zvrf = vrf->info) != NULL)
- vty_show_ip_route_summary(
- vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (show_ip_route_vrf_all_summary_prefix,
- show_ip_route_vrf_all_summary_prefix_cmd,
- "show ip route vrf all summary prefix",
- SHOW_STR
- IP_STR
- "IP routing table\n"
- VRF_ALL_CMD_HELP_STR
- "Summary of all routes\n"
- "Prefix routes\n")
-{
- struct vrf *vrf;
- struct zebra_vrf *zvrf;
-
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
- if ((zvrf = vrf->info) != NULL)
- vty_show_ip_route_summary_prefix(
- vty, zvrf->table[AFI_IP][SAFI_UNICAST]);
-
- return CMD_SUCCESS;
-}
-
/* Write static route configuration. */
static int static_config(struct vty *vty, afi_t afi, safi_t safi,
const char *cmd)
@@ -1901,245 +1756,6 @@ DEFPY(ipv6_route,
tag_str, distance_str, vrf, label);
}
-DEFUN (show_ipv6_route,
- show_ipv6_route_cmd,
- "show ipv6 <fib|route> [vrf NAME] [tag (1-4294967295)|X:X::X:X/M longer-prefixes|" FRR_IP6_REDIST_STR_ZEBRA "] [json]",
- SHOW_STR
- IP_STR
- "IP forwarding table\n"
- "IP routing table\n"
- VRF_CMD_HELP_STR
- "Show only routes with tag\n"
- "Tag value\n"
- "IPv6 prefix\n"
- "Show route matching the specified Network/Mask pair only\n"
- FRR_IP6_REDIST_HELP_STR_ZEBRA
- JSON_STR)
-{
- bool uf = use_fib(argv[2]);
- struct route_table *table;
- int vrf_all = 0;
- route_tag_t tag = 0;
- vrf_id_t vrf_id = VRF_DEFAULT;
- struct vrf *vrf;
- struct zebra_vrf *zvrf;
- int uj = use_json(argc, argv);
- int idx = 0;
- struct prefix p;
- bool longer_prefixes = false;
- bool supernets_only = false;
- int type = 0;
-
- if (argv_find(argv, argc, "vrf", &idx)) {
- if (strmatch(argv[idx + 1]->arg, "all"))
- vrf_all = 1;
- else
- VRF_GET_ID(vrf_id, argv[idx + 1]->arg);
- }
-
- if (argv_find(argv, argc, "tag", &idx))
- tag = strtoul(argv[idx + 1]->arg, NULL, 10);
-
- else if (argv_find(argv, argc, "X:X::X:X/M", &idx)) {
- if (str2prefix(argv[idx]->arg, &p) <= 0) {
- vty_out(vty, "%% Malformed prefix\n");
- return CMD_WARNING;
- }
- longer_prefixes = true;
- }
-
- else {
- if (argv_find(argv, argc, "kernel", &idx))
- type = proto_redistnum(AFI_IP6, argv[idx]->text);
- else if (argv_find(argv, argc, "babel", &idx))
- type = proto_redistnum(AFI_IP6, argv[idx]->text);
- else if (argv_find(argv, argc, "connected", &idx))
- type = proto_redistnum(AFI_IP6, argv[idx]->text);
- else if (argv_find(argv, argc, "static", &idx))
- type = proto_redistnum(AFI_IP6, argv[idx]->text);
- else if (argv_find(argv, argc, "ripng", &idx))
- type = proto_redistnum(AFI_IP6, argv[idx]->text);
- else if (argv_find(argv, argc, "ospf6", &idx))
- type = proto_redistnum(AFI_IP6, argv[idx]->text);
- else if (argv_find(argv, argc, "isis", &idx))
- type = proto_redistnum(AFI_IP6, argv[idx]->text);
- else if (argv_find(argv, argc, "bgp", &idx))
- type = proto_redistnum(AFI_IP6, argv[idx]->text);
- else if (argv_find(argv, argc, "nhrp", &idx))
- type = proto_redistnum(AFI_IP6, argv[idx]->text);
- else if (argv_find(argv, argc, "table", &idx))
- type = proto_redistnum(AFI_IP6, argv[idx]->text);
- else if (argv_find(argv, argc, "vnc", &idx))
- type = proto_redistnum(AFI_IP6, argv[idx]->text);
-
- if (type < 0) {
- vty_out(vty, "Unknown route type\n");
- return CMD_WARNING;
- }
- }
-
- if (vrf_all) {
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
- if ((zvrf = vrf->info) == NULL
- || (table = zvrf->table[AFI_IP6][SAFI_UNICAST])
- == NULL)
- continue;
-
- do_show_ip_route(vty, zvrf_name(zvrf), AFI_IP6,
- SAFI_UNICAST, uf, uj, tag,
- longer_prefixes ? &p : NULL,
- supernets_only, type, 0);
- }
- } else {
- vrf = vrf_lookup_by_id(vrf_id);
- do_show_ip_route(vty, vrf->name, AFI_IP6, SAFI_UNICAST, uf, uj,
- tag, longer_prefixes ? &p : NULL,
- supernets_only, type, 0);
- }
- return CMD_SUCCESS;
-}
-
-DEFUN (show_ipv6_route_addr,
- show_ipv6_route_addr_cmd,
- "show ipv6 route [vrf NAME] X:X::X:X",
- SHOW_STR
- IP_STR
- "IPv6 routing table\n"
- VRF_CMD_HELP_STR
- "IPv6 Address\n")
-{
- int ret;
- struct prefix_ipv6 p;
- struct route_table *table;
- struct route_node *rn;
- vrf_id_t vrf_id = VRF_DEFAULT;
-
- if (strmatch(argv[3]->text, "vrf")) {
- VRF_GET_ID(vrf_id, argv[4]->arg);
- ret = str2prefix_ipv6(argv[5]->arg, &p);
- } else {
- ret = str2prefix_ipv6(argv[3]->arg, &p);
- }
-
- if (ret <= 0) {
- vty_out(vty, "Malformed IPv6 address\n");
- return CMD_WARNING;
- }
-
- table = zebra_vrf_table(AFI_IP6, SAFI_UNICAST, vrf_id);
- if (!table)
- return CMD_SUCCESS;
-
- rn = route_node_match(table, (struct prefix *)&p);
- if (!rn) {
- vty_out(vty, "%% Network not in table\n");
- return CMD_WARNING;
- }
-
- vty_show_ip_route_detail(vty, rn, 0);
-
- route_unlock_node(rn);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (show_ipv6_route_prefix,
- show_ipv6_route_prefix_cmd,
- "show ipv6 route [vrf NAME] X:X::X:X/M",
- SHOW_STR
- IP_STR
- "IPv6 routing table\n"
- VRF_CMD_HELP_STR
- "IPv6 prefix\n")
-{
- int ret;
- struct prefix_ipv6 p;
- struct route_table *table;
- struct route_node *rn;
- vrf_id_t vrf_id = VRF_DEFAULT;
-
- if (strmatch(argv[3]->text, "vrf")) {
- VRF_GET_ID(vrf_id, argv[4]->arg);
- ret = str2prefix_ipv6(argv[5]->arg, &p);
- } else
- ret = str2prefix_ipv6(argv[3]->arg, &p);
-
- if (ret <= 0) {
- vty_out(vty, "Malformed IPv6 prefix\n");
- return CMD_WARNING;
- }
-
- table = zebra_vrf_table(AFI_IP6, SAFI_UNICAST, vrf_id);
- if (!table)
- return CMD_SUCCESS;
-
- rn = route_node_match(table, (struct prefix *)&p);
- if (!rn || rn->p.prefixlen != p.prefixlen) {
- vty_out(vty, "%% Network not in table\n");
- return CMD_WARNING;
- }
-
- vty_show_ip_route_detail(vty, rn, 0);
-
- route_unlock_node(rn);
-
- return CMD_SUCCESS;
-}
-
-
-/* Show route summary. */
-DEFUN (show_ipv6_route_summary,
- show_ipv6_route_summary_cmd,
- "show ipv6 route [vrf NAME] summary",
- SHOW_STR
- IP_STR
- "IPv6 routing table\n"
- VRF_CMD_HELP_STR
- "Summary of all IPv6 routes\n")
-{
- struct route_table *table;
- vrf_id_t vrf_id = VRF_DEFAULT;
-
- if (strmatch(argv[3]->text, "vrf"))
- VRF_GET_ID(vrf_id, argv[4]->arg);
-
- table = zebra_vrf_table(AFI_IP6, SAFI_UNICAST, vrf_id);
- if (!table)
- return CMD_SUCCESS;
-
- vty_show_ip_route_summary(vty, table);
-
- return CMD_SUCCESS;
-}
-
-
-/* Show ipv6 route summary prefix. */
-DEFUN (show_ipv6_route_summary_prefix,
- show_ipv6_route_summary_prefix_cmd,
- "show ipv6 route [vrf NAME] summary prefix",
- SHOW_STR
- IP_STR
- "IPv6 routing table\n"
- VRF_CMD_HELP_STR
- "Summary of all IPv6 routes\n"
- "Prefix routes\n")
-{
- struct route_table *table;
- vrf_id_t vrf_id = VRF_DEFAULT;
-
- if (strmatch(argv[3]->text, "vrf"))
- VRF_GET_ID(vrf_id, argv[4]->arg);
-
- table = zebra_vrf_table(AFI_IP6, SAFI_UNICAST, vrf_id);
- if (!table)
- return CMD_SUCCESS;
-
- vty_show_ip_route_summary_prefix(vty, table);
-
- return CMD_SUCCESS;
-}
-
-
/*
* Show IPv6 mroute command.Used to dump
* the Multicast routing table.
@@ -2177,110 +1793,6 @@ DEFUN (show_ipv6_mroute,
return CMD_SUCCESS;
}
-DEFUN (show_ipv6_route_vrf_all_addr,
- show_ipv6_route_vrf_all_addr_cmd,
- "show ipv6 route vrf all X:X::X:X",
- SHOW_STR
- IP_STR
- "IPv6 routing table\n"
- VRF_ALL_CMD_HELP_STR
- "IPv6 Address\n")
-{
- int idx_ipv6 = 5;
- int ret;
- struct prefix_ipv6 p;
- struct route_table *table;
- struct route_node *rn;
- struct vrf *vrf;
- struct zebra_vrf *zvrf;
-
- ret = str2prefix_ipv6(argv[idx_ipv6]->arg, &p);
- if (ret <= 0) {
- vty_out(vty, "Malformed IPv6 address\n");
- return CMD_WARNING;
- }
-
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
- if ((zvrf = vrf->info) == NULL
- || (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
- continue;
-
- rn = route_node_match(table, (struct prefix *)&p);
- if (!rn)
- continue;
-
- vty_show_ip_route_detail(vty, rn, 0);
-
- route_unlock_node(rn);
- }
-
- return CMD_SUCCESS;
-}
-
-DEFUN (show_ipv6_route_vrf_all_prefix,
- show_ipv6_route_vrf_all_prefix_cmd,
- "show ipv6 route vrf all X:X::X:X/M",
- SHOW_STR
- IP_STR
- "IPv6 routing table\n"
- VRF_ALL_CMD_HELP_STR
- "IPv6 prefix\n")
-{
- int idx_ipv6_prefixlen = 5;
- int ret;
- struct prefix_ipv6 p;
- struct route_table *table;
- struct route_node *rn;
- struct vrf *vrf;
- struct zebra_vrf *zvrf;
-
- ret = str2prefix_ipv6(argv[idx_ipv6_prefixlen]->arg, &p);
- if (ret <= 0) {
- vty_out(vty, "Malformed IPv6 prefix\n");
- return CMD_WARNING;
- }
-
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
- if ((zvrf = vrf->info) == NULL
- || (table = zvrf->table[AFI_IP6][SAFI_UNICAST]) == NULL)
- continue;
-
- rn = route_node_match(table, (struct prefix *)&p);
- if (!rn)
- continue;
- if (rn->p.prefixlen != p.prefixlen) {
- route_unlock_node(rn);
- continue;
- }
-
- vty_show_ip_route_detail(vty, rn, 0);
-
- route_unlock_node(rn);
- }
-
- return CMD_SUCCESS;
-}
-
-DEFUN (show_ipv6_route_vrf_all_summary,
- show_ipv6_route_vrf_all_summary_cmd,
- "show ipv6 route vrf all summary",
- SHOW_STR
- IP_STR
- "IPv6 routing table\n"
- VRF_ALL_CMD_HELP_STR
- "Summary of all IPv6 routes\n")
-{
- struct vrf *vrf;
- struct zebra_vrf *zvrf;
-
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
- if ((zvrf = vrf->info) != NULL)
- vty_show_ip_route_summary(
- vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
-
- return CMD_SUCCESS;
-}
-
DEFUN (show_ipv6_mroute_vrf_all,
show_ipv6_mroute_vrf_all_cmd,
"show ipv6 mroute vrf all",
@@ -2314,27 +1826,6 @@ DEFUN (show_ipv6_mroute_vrf_all,
return CMD_SUCCESS;
}
-DEFUN (show_ipv6_route_vrf_all_summary_prefix,
- show_ipv6_route_vrf_all_summary_prefix_cmd,
- "show ipv6 route vrf all summary prefix",
- SHOW_STR
- IP_STR
- "IPv6 routing table\n"
- VRF_ALL_CMD_HELP_STR
- "Summary of all IPv6 routes\n"
- "Prefix routes\n")
-{
- struct vrf *vrf;
- struct zebra_vrf *zvrf;
-
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
- if ((zvrf = vrf->info) != NULL)
- vty_show_ip_route_summary_prefix(
- vty, zvrf->table[AFI_IP6][SAFI_UNICAST]);
-
- return CMD_SUCCESS;
-}
-
DEFUN (allow_external_route_update,
allow_external_route_update_cmd,
"allow-external-route-update",
@@ -2848,24 +2339,17 @@ void zebra_vty_init(void)
install_element(CONFIG_NODE, &no_zebra_packet_process_cmd);
install_element(VIEW_NODE, &show_vrf_cmd);
- install_element(VIEW_NODE, &show_ip_route_cmd);
+ install_element(VIEW_NODE, &show_route_cmd);
+ install_element(VIEW_NODE, &show_route_detail_cmd);
+ install_element(VIEW_NODE, &show_route_summary_cmd);
install_element(VIEW_NODE, &show_ip_nht_cmd);
install_element(VIEW_NODE, &show_ip_nht_vrf_all_cmd);
install_element(VIEW_NODE, &show_ipv6_nht_cmd);
install_element(VIEW_NODE, &show_ipv6_nht_vrf_all_cmd);
- install_element(VIEW_NODE, &show_ip_route_addr_cmd);
- install_element(VIEW_NODE, &show_ip_route_prefix_cmd);
- install_element(VIEW_NODE, &show_ip_route_summary_cmd);
- install_element(VIEW_NODE, &show_ip_route_summary_prefix_cmd);
install_element(VIEW_NODE, &show_ip_rpf_cmd);
install_element(VIEW_NODE, &show_ip_rpf_addr_cmd);
- install_element(VIEW_NODE, &show_ip_route_vrf_all_addr_cmd);
- install_element(VIEW_NODE, &show_ip_route_vrf_all_prefix_cmd);
- install_element(VIEW_NODE, &show_ip_route_vrf_all_summary_cmd);
- install_element(VIEW_NODE, &show_ip_route_vrf_all_summary_prefix_cmd);
-
install_element(CONFIG_NODE, &ipv6_route_blackhole_cmd);
install_element(CONFIG_NODE, &ipv6_route_address_interface_cmd);
install_element(CONFIG_NODE, &ipv6_route_cmd);
@@ -2873,19 +2357,9 @@ void zebra_vty_init(void)
install_element(CONFIG_NODE, &no_ip_nht_default_route_cmd);
install_element(CONFIG_NODE, &ipv6_nht_default_route_cmd);
install_element(CONFIG_NODE, &no_ipv6_nht_default_route_cmd);
- install_element(VIEW_NODE, &show_ipv6_route_cmd);
- install_element(VIEW_NODE, &show_ipv6_route_summary_cmd);
- install_element(VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
- install_element(VIEW_NODE, &show_ipv6_route_addr_cmd);
- install_element(VIEW_NODE, &show_ipv6_route_prefix_cmd);
install_element(VIEW_NODE, &show_ipv6_mroute_cmd);
/* Commands for VRF */
- install_element(VIEW_NODE, &show_ipv6_route_vrf_all_summary_cmd);
- install_element(VIEW_NODE, &show_ipv6_route_vrf_all_summary_prefix_cmd);
- install_element(VIEW_NODE, &show_ipv6_route_vrf_all_addr_cmd);
- install_element(VIEW_NODE, &show_ipv6_route_vrf_all_prefix_cmd);
-
install_element(VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
install_element(VIEW_NODE, &show_evpn_vni_cmd);