diff options
Diffstat (limited to 'zebra/zebra_vty.c')
| -rw-r--r-- | zebra/zebra_vty.c | 95 |
1 files changed, 45 insertions, 50 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 3bf20ff42e..b65097e725 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -370,7 +370,7 @@ static void show_nexthop_detail_helper(struct vty *vty, break; } - if (re->vrf_id != nexthop->vrf_id) { + if (re->vrf_id != nexthop->vrf_id && nexthop->type != NEXTHOP_TYPE_BLACKHOLE) { struct vrf *vrf = vrf_lookup_by_id(nexthop->vrf_id); vty_out(vty, "(vrf %s)", VRF_LOGNAME(vrf)); @@ -858,6 +858,27 @@ static void vty_show_ip_route_detail_json(struct vty *vty, vty_json(vty, json); } +static void zebra_vty_display_vrf_header(struct vty *vty, struct zebra_vrf *zvrf, uint32_t tableid) +{ + if (!tableid) + vty_out(vty, "VRF %s:\n", zvrf_name(zvrf)); + else { + if (vrf_is_backend_netns()) + vty_out(vty, "VRF %s table %u:\n", zvrf_name(zvrf), tableid); + else { + vrf_id_t vrf = zebra_vrf_lookup_by_table(tableid, zvrf->zns->ns_id); + + if (vrf == VRF_DEFAULT && tableid != RT_TABLE_ID_MAIN) + vty_out(vty, "table %u:\n", tableid); + else { + struct zebra_vrf *zvrf2 = zebra_vrf_lookup_by_id(vrf); + + vty_out(vty, "VRF %s table %u:\n", zvrf_name(zvrf2), tableid); + } + } + } +} + static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf, struct route_table *table, afi_t afi, bool use_fib, route_tag_t tag, @@ -937,17 +958,9 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf, } if (ctx->multi && ctx->header_done) vty_out(vty, "\n"); - if (ctx->multi || zvrf_id(zvrf) != VRF_DEFAULT - || tableid) { - if (!tableid) - vty_out(vty, "VRF %s:\n", - zvrf_name(zvrf)); - else - vty_out(vty, - "VRF %s table %u:\n", - zvrf_name(zvrf), - tableid); - } + if (ctx->multi || zvrf_id(zvrf) != VRF_DEFAULT || tableid) + zebra_vty_display_vrf_header(vty, zvrf, tableid); + ctx->header_done = true; first = 0; } @@ -3594,54 +3607,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 +3693,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 +3715,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, @@ -3802,6 +3793,10 @@ static int config_write_protocol(struct vty *vty) if (!zebra_nhg_recursive_use_backups()) vty_out(vty, "no zebra nexthop resolve-via-backup\n"); +#ifdef HAVE_SCRIPTING + frrscript_names_config_write(vty); +#endif + if (rnh_get_hide_backups()) vty_out(vty, "ip nht hide-backup-events\n"); |
