diff options
Diffstat (limited to 'zebra/zebra_vty.c')
| -rw-r--r-- | zebra/zebra_vty.c | 105 |
1 files changed, 53 insertions, 52 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 39695a148c..f35c9f65fb 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -76,7 +76,7 @@ static int do_show_ip_route(struct vty *vty, const char *vrf_name, afi_t afi, const struct prefix *longer_prefix_p, bool supernets_only, int type, unsigned short ospf_instance_id, uint32_t tableid, - struct route_show_ctx *ctx); + bool show_ng, struct route_show_ctx *ctx); static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn, int mcast, bool use_fib, bool show_ng); static void vty_show_ip_route_summary(struct vty *vty, @@ -158,7 +158,8 @@ DEFUN (show_ip_rpf, }; return do_show_ip_route(vty, VRF_DEFAULT_NAME, AFI_IP, SAFI_MULTICAST, - false, uj, 0, NULL, false, 0, 0, 0, &ctx); + false, uj, 0, NULL, false, 0, 0, 0, false, + &ctx); } DEFUN (show_ip_rpf_addr, @@ -565,8 +566,14 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn, vty_out(vty, " Last update %s ago\n", buf); - if (show_ng) + if (show_ng) { vty_out(vty, " Nexthop Group ID: %u\n", re->nhe_id); + if (re->nhe_installed_id != 0 + && re->nhe_id != re->nhe_installed_id) + vty_out(vty, + " Installed Nexthop Group ID: %u\n", + re->nhe_installed_id); + } for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) { /* Use helper to format each nexthop */ @@ -914,7 +921,7 @@ static void show_nexthop_json_helper(json_object *json_nexthop, static void vty_show_ip_route(struct vty *vty, struct route_node *rn, struct route_entry *re, json_object *json, - bool is_fib) + bool is_fib, bool show_ng) { const struct nexthop *nexthop; int len = 0; @@ -1002,6 +1009,11 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn, &(re->nhe->nhg))); json_object_int_add(json_route, "nexthopGroupId", re->nhe_id); + if (re->nhe_installed_id != 0) + json_object_int_add(json_route, + "installedNexthopGroupId", + re->nhe_installed_id); + json_object_string_add(json_route, "uptime", up_str); for (ALL_NEXTHOPS_PTR(nhg, nexthop)) { @@ -1075,6 +1087,9 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn, len += vty_out(vty, " [%u/%u]", re->distance, re->metric); + if (show_ng) + len += vty_out(vty, " (%u)", re->nhe_id); + /* Nexthop information. */ for (ALL_NEXTHOPS_PTR(nhg, nexthop)) { if (first_p) { @@ -1147,16 +1162,12 @@ static void vty_show_ip_route_detail_json(struct vty *vty, */ if (use_fib && re != dest->selected_fib) continue; - vty_show_ip_route(vty, rn, re, json_prefix, use_fib); + vty_show_ip_route(vty, rn, re, json_prefix, use_fib, false); } prefix2str(&rn->p, buf, sizeof(buf)); json_object_object_add(json, buf, json_prefix); - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY - | JSON_C_TO_STRING_NOSLASHESCAPE)); - json_object_free(json); + vty_json(vty, json); } static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf, @@ -1165,7 +1176,8 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf, const struct prefix *longer_prefix_p, bool supernets_only, int type, unsigned short ospf_instance_id, bool use_json, - uint32_t tableid, struct route_show_ctx *ctx) + uint32_t tableid, bool show_ng, + struct route_show_ctx *ctx) { struct route_node *rn; struct route_entry *re; @@ -1256,7 +1268,8 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf, first = 0; } - vty_show_ip_route(vty, rn, re, json_prefix, use_fib); + vty_show_ip_route(vty, rn, re, json_prefix, use_fib, + show_ng); } if (json_prefix) { @@ -1266,14 +1279,8 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf, } } - if (use_json) { - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json, - JSON_C_TO_STRING_PRETTY - | JSON_C_TO_STRING_NOSLASHESCAPE)); - json_object_free(json); - } + if (use_json) + vty_json(vty, json); } static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf, @@ -1281,7 +1288,7 @@ static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf, route_tag_t tag, const struct prefix *longer_prefix_p, bool supernets_only, int type, - unsigned short ospf_instance_id, + unsigned short ospf_instance_id, bool show_ng, struct route_show_ctx *ctx) { struct zebra_router_table *zrt; @@ -1300,7 +1307,7 @@ static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf, do_show_ip_route(vty, zvrf_name(zvrf), afi, SAFI_UNICAST, use_fib, use_json, tag, longer_prefix_p, supernets_only, type, ospf_instance_id, - zrt->tableid, ctx); + zrt->tableid, show_ng, ctx); } } @@ -1310,7 +1317,7 @@ static int do_show_ip_route(struct vty *vty, const char *vrf_name, afi_t afi, const struct prefix *longer_prefix_p, bool supernets_only, int type, unsigned short ospf_instance_id, uint32_t tableid, - struct route_show_ctx *ctx) + bool show_ng, struct route_show_ctx *ctx) { struct route_table *table; struct zebra_vrf *zvrf = NULL; @@ -1343,7 +1350,7 @@ static int do_show_ip_route(struct vty *vty, const char *vrf_name, afi_t afi, do_show_route_helper(vty, zvrf, table, afi, use_fib, tag, longer_prefix_p, supernets_only, type, - ospf_instance_id, use_json, tableid, ctx); + ospf_instance_id, use_json, tableid, show_ng, ctx); return CMD_SUCCESS; } @@ -1827,7 +1834,7 @@ DEFPY (show_route, }]\ [" FRR_IP6_REDIST_STR_ZEBRA "$type_str]\ >\ - [json$json]", + [<json$json|nexthop-group$ng>]", SHOW_STR IP_STR "IP forwarding table\n" @@ -1856,7 +1863,8 @@ DEFPY (show_route, "IPv6 prefix\n" "Show route matching the specified Network/Mask pair only\n" FRR_IP6_REDIST_HELP_STR_ZEBRA - JSON_STR) + JSON_STR + "Nexthop Group Information\n") { afi_t afi = ipv4 ? AFI_IP : AFI_IP6; struct vrf *vrf; @@ -1892,18 +1900,18 @@ DEFPY (show_route, continue; if (table_all) - do_show_ip_route_all(vty, zvrf, afi, !!fib, - !!json, tag, - prefix_str ? prefix : NULL, - !!supernets_only, type, - ospf_instance_id, &ctx); + do_show_ip_route_all( + vty, zvrf, afi, !!fib, !!json, tag, + prefix_str ? prefix : NULL, + !!supernets_only, type, + ospf_instance_id, !!ng, &ctx); else - do_show_ip_route(vty, zvrf_name(zvrf), afi, - SAFI_UNICAST, !!fib, !!json, - tag, - prefix_str ? prefix : NULL, - !!supernets_only, type, - ospf_instance_id, table, &ctx); + do_show_ip_route( + vty, zvrf_name(zvrf), afi, SAFI_UNICAST, + !!fib, !!json, tag, + prefix_str ? prefix : NULL, + !!supernets_only, type, + ospf_instance_id, table, !!ng, &ctx); } } else { vrf_id_t vrf_id = VRF_DEFAULT; @@ -1922,13 +1930,13 @@ DEFPY (show_route, do_show_ip_route_all(vty, zvrf, afi, !!fib, !!json, tag, prefix_str ? prefix : NULL, !!supernets_only, type, - ospf_instance_id, &ctx); + ospf_instance_id, !!ng, &ctx); else do_show_ip_route(vty, vrf->name, afi, SAFI_UNICAST, !!fib, !!json, tag, prefix_str ? prefix : NULL, !!supernets_only, type, - ospf_instance_id, table, &ctx); + ospf_instance_id, table, !!ng, &ctx); } return CMD_SUCCESS; @@ -2505,10 +2513,7 @@ static void vty_show_ip_route_summary(struct vty *vty, json_object_int_add(json_route_summary, "routesTotalFib", fib_cnt[ZEBRA_ROUTE_TOTAL]); - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json_route_summary, JSON_C_TO_STRING_PRETTY)); - json_object_free(json_route_summary); + vty_json(vty, json_route_summary); } else { vty_out(vty, "------\n"); vty_out(vty, "%-20s %-20d %-20d \n", "Totals", @@ -2656,10 +2661,7 @@ static void vty_show_ip_route_summary_prefix(struct vty *vty, json_object_int_add(json_route_summary, "prefixRoutesTotalFib", fib_cnt[ZEBRA_ROUTE_TOTAL]); - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json_route_summary, JSON_C_TO_STRING_PRETTY)); - json_object_free(json_route_summary); + vty_json(vty, json_route_summary); } else { vty_out(vty, "------\n"); vty_out(vty, "%-20s %-20d %-20d \n", "Totals", @@ -2700,7 +2702,7 @@ DEFUN (show_ipv6_mroute, vty_out(vty, SHOW_ROUTE_V6_HEADER); first = 0; } - vty_show_ip_route(vty, rn, re, NULL, false); + vty_show_ip_route(vty, rn, re, NULL, false, false); } return CMD_SUCCESS; } @@ -2732,7 +2734,8 @@ DEFUN (show_ipv6_mroute_vrf_all, vty_out(vty, SHOW_ROUTE_V6_HEADER); first = 0; } - vty_show_ip_route(vty, rn, re, NULL, false); + vty_show_ip_route(vty, rn, re, NULL, false, + false); } } return CMD_SUCCESS; @@ -3031,9 +3034,7 @@ DEFUN (show_vrf_vni, if (uj) { json_object_object_add(json, "vrfs", json_vrfs); - vty_out(vty, "%s\n", json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); - json_object_free(json); + vty_json(vty, json); } return CMD_SUCCESS; |
