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.c54
1 files changed, 16 insertions, 38 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 309cde9a35..8c0d6df68a 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -3594,54 +3594,34 @@ static int zebra_ip_config(struct vty *vty)
return write;
}
-DEFUN (ip_zebra_import_table_distance,
+DEFPY (ip_zebra_import_table_distance,
ip_zebra_import_table_distance_cmd,
- "ip import-table (1-252) [distance (1-255)] [route-map RMAP_NAME]",
+ "ip import-table (1-252)$table_id [mrib]$mrib [distance (1-255)$distance] [route-map RMAP_NAME$rmap]",
IP_STR
"import routes from non-main kernel table\n"
"kernel routing table id\n"
+ "Import into the MRIB instead of the URIB\n"
"Distance for imported routes\n"
"Default distance value\n"
"route-map for filtering\n"
"route-map name\n")
{
- uint32_t table_id = 0;
-
- table_id = strtoul(argv[2]->arg, NULL, 10);
- int distance = ZEBRA_TABLE_DISTANCE_DEFAULT;
- char *rmap =
- strmatch(argv[argc - 2]->text, "route-map")
- ? XSTRDUP(MTYPE_ROUTE_MAP_NAME, argv[argc - 1]->arg)
- : NULL;
- int ret;
+ safi_t safi = mrib ? SAFI_MULTICAST : SAFI_UNICAST;
- if (argc == 7 || (argc == 5 && !rmap))
- distance = strtoul(argv[4]->arg, NULL, 10);
+ if (distance_str == NULL)
+ distance = ZEBRA_TABLE_DISTANCE_DEFAULT;
if (!is_zebra_valid_kernel_table(table_id)) {
- vty_out(vty,
- "Invalid routing table ID, %d. Must be in range 1-252\n",
- table_id);
- if (rmap)
- XFREE(MTYPE_ROUTE_MAP_NAME, rmap);
+ vty_out(vty, "Invalid routing table ID, %ld. Must be in range 1-252\n", table_id);
return CMD_WARNING;
}
if (is_zebra_main_routing_table(table_id)) {
- vty_out(vty,
- "Invalid routing table ID, %d. Must be non-default table\n",
- table_id);
- if (rmap)
- XFREE(MTYPE_ROUTE_MAP_NAME, rmap);
+ vty_out(vty, "Invalid routing table ID, %ld. Must be non-default table\n", table_id);
return CMD_WARNING;
}
- ret = zebra_import_table(AFI_IP, VRF_DEFAULT, table_id,
- distance, rmap, 1);
- if (rmap)
- XFREE(MTYPE_ROUTE_MAP_NAME, rmap);
-
- return ret;
+ return zebra_import_table(AFI_IP, safi, VRF_DEFAULT, table_id, distance, rmap, true);
}
DEFUN_HIDDEN (zebra_packet_process,
@@ -3700,20 +3680,20 @@ DEFUN_HIDDEN (no_zebra_workqueue_timer,
return CMD_SUCCESS;
}
-DEFUN (no_ip_zebra_import_table,
+DEFPY (no_ip_zebra_import_table,
no_ip_zebra_import_table_cmd,
- "no ip import-table (1-252) [distance (1-255)] [route-map NAME]",
+ "no ip import-table (1-252)$table_id [mrib]$mrib [distance (1-255)] [route-map NAME]",
NO_STR
IP_STR
"import routes from non-main kernel table\n"
"kernel routing table id\n"
+ "Import into the MRIB instead of the URIB\n"
"Distance for imported routes\n"
"Default distance value\n"
"route-map for filtering\n"
"route-map name\n")
{
- uint32_t table_id = 0;
- table_id = strtoul(argv[3]->arg, NULL, 10);
+ safi_t safi = mrib ? SAFI_MULTICAST : SAFI_UNICAST;
if (!is_zebra_valid_kernel_table(table_id)) {
vty_out(vty,
@@ -3722,16 +3702,14 @@ DEFUN (no_ip_zebra_import_table,
}
if (is_zebra_main_routing_table(table_id)) {
- vty_out(vty,
- "Invalid routing table ID, %d. Must be non-default table\n",
- table_id);
+ vty_out(vty, "Invalid routing table ID, %ld. Must be non-default table\n", table_id);
return CMD_WARNING;
}
- if (!is_zebra_import_table_enabled(AFI_IP, VRF_DEFAULT, table_id))
+ if (!is_zebra_import_table_enabled(AFI_IP, safi, VRF_DEFAULT, table_id))
return CMD_SUCCESS;
- return (zebra_import_table(AFI_IP, VRF_DEFAULT, table_id, 0, NULL, 0));
+ return (zebra_import_table(AFI_IP, safi, VRF_DEFAULT, table_id, 0, NULL, false));
}
DEFPY (zebra_nexthop_group_keep,