From c98e741100c1ef943d537e9d438814597cf9d43b Mon Sep 17 00:00:00 2001 From: Sarita Patra Date: Tue, 17 Mar 2020 21:47:32 -0700 Subject: [PATCH] pimd: Modified rp-info & igmp groups json o/p Fix 1: Added group as array in the o/p "show ip igmp groups json" Before: "225.1.1.1":{ "source":"20.0.0.1", "group":"225.1.1.1", "timer":"00:04:11", "sourcesCount":1, "version":2, "uptime":"00:00:15" }, After: "groups":[ { "source":"20.0.0.1", "group":"225.1.1.2", "timer":"00:03:50", "sourcesCount":1, "version":2, "uptime":"00:00:29" }, Fix 2: Added a new field "rp_address" in "show ip igmp groups json" Before: "40.0.0.2":[ { "outboundInterface":"ens224", "group":"224.0.0.0\/4", "source":"Static" } After: "40.0.0.2":[ { "rp_address":"40.0.0.2", "outboundInterface":"ens224", "group":"224.0.0.0\/4", "source":"Static" } Signed-off-by: Sarita Patra --- pimd/pim_cmd.c | 43 +++++++++++++++++++++++-------------------- pimd/pim_rp.c | 4 ++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index af25d930d1a3..d159d96eda82 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -3411,13 +3411,15 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj) time_t now; json_object *json = NULL; json_object *json_iface = NULL; - json_object *json_row = NULL; + json_object *json_group = NULL; + json_object *json_groups = NULL; now = pim_time_monotonic_sec(); - if (uj) + if (uj) { json = json_object_new_object(); - else + json_groups = json_object_new_array(); + } else vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime \n"); @@ -3468,35 +3470,34 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj) json_iface); } - json_row = json_object_new_object(); - json_object_string_add( - json_row, "source", ifaddr_str); + json_group = json_object_new_object(); + json_object_string_add(json_group, + "source", + ifaddr_str); json_object_string_add( - json_row, "group", group_str); + json_group, "group", group_str); if (grp->igmp_version == 3) json_object_string_add( - json_row, "mode", + json_group, "mode", grp->group_filtermode_isexcl ? "EXCLUDE" : "INCLUDE"); - json_object_string_add(json_row, + json_object_string_add(json_group, "timer", hhmmss); json_object_int_add( - json_row, "sourcesCount", - grp->group_source_list - ? listcount( - grp->group_source_list) - : 0); - json_object_int_add(json_row, "version", + json_group, "sourcesCount", + grp->group_source_list ? listcount( + grp->group_source_list) + : 0); + json_object_int_add(json_group, + "version", grp->igmp_version); json_object_string_add( - json_row, "uptime", uptime); - json_object_object_add(json_iface, - group_str, - json_row); - + json_group, "uptime", uptime); + json_object_array_add(json_groups, + json_group); } else { vty_out(vty, "%-16s %-15s %-15s %4s %8s %4d %d %8s\n", @@ -3519,6 +3520,8 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj) } /* scan interfaces */ if (uj) { + if (json_iface) + json_object_object_add(json_iface, "groups", json_groups); vty_out(vty, "%s\n", json_object_to_json_string_ext( json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 355aa0704816..c16e99d66482 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -1289,6 +1289,10 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj) json_rp_rows = json_object_new_array(); json_row = json_object_new_object(); + json_object_string_add( + json_row, "rp_address", + inet_ntoa(rp_info->rp.rpf_addr.u + .prefix4)); if (rp_info->rp.source_nexthop.interface) json_object_string_add( json_row, "outboundInterface",